> It seems that the latest patch also includes a problem.

I forgot to reply-all again and Shigio pointed out yet another problem (sheesh, 
I'm useless), so here's hopefully the final patch, based on the original 6.3.3 
source.

-- 
Jason.
diff -urp global-6.3.3/libparser/Cpp.c global-6.3-3/libparser/Cpp.c
--- global-6.3.3/libparser/Cpp.c        2014-11-26 12:49:36 +1000
+++ global-6.3-3/libparser/Cpp.c        2014-12-03 17:24:28 +1000
@@ -79,7 +79,8 @@ Cpp(const struct parser_param *param)
                char *terminate;
                int level;
        } stack[MAXCLASSSTACK];
-       const char *interested = "{}=;~";
+       const char *interested_class = "<:{}=;~";
+       const char *interested = interested_class + 2;
        STRBUF *sb = strbuf_open(0);
 
        *classname = *completename = 0;
@@ -182,19 +183,37 @@ Cpp(const struct parser_param *param)
                        else
                                pushbacktoken();
                        break;
+               case CPP_STRUCT:
                case CPP_CLASS:
-                       DBG_PRINT(level, "class");
-                       if ((c = nexttoken(interested, cpp_reserved_word)) == 
SYMBOL) {
-                               strlimcpy(classname, token, sizeof(classname));
+                       DBG_PRINT(level, cc == CPP_CLASS ? "class" : "struct");
+                       while ((c = nexttoken(interested_class, 
cpp_reserved_word)) == CPP___ATTRIBUTE__ || c == '\n')
+                               if (c == CPP___ATTRIBUTE__)
+                                       process_attribute(param);
+                       if (c == SYMBOL) {
+                               char *saveline;
+                               int savelineno;
+                               do {
+                                       if (c == SYMBOL) {
+                                               savelineno = lineno;
+                                               strbuf_reset(sb);
+                                               strbuf_puts(sb, sp);
+                                               saveline = strbuf_value(sb);
+                                               strlimcpy(classname, token, 
sizeof(classname));
+                                       }
+                                       c = nexttoken(interested_class, 
cpp_reserved_word);
+                               } while (c == SYMBOL || c == '\n');
                                /*
                                 * Ignore forward definitions.
                                 * "class name;"
                                 */
-                               if (peekc(0) != ';') {
+                               if (c == '<' || c == ':' || c == '{') /* } */ {
                                        startclass = 1;
-                                       PUT(PARSER_DEF, token, lineno, sp);
-                               }
+                                       PUT(PARSER_DEF, classname, savelineno, 
saveline);
+                               } else if (c != ';')
+                                       PUT(PARSER_REF_SYM, classname, 
savelineno, saveline);
                        }
+                       if (c != '<' && c != ':')
+                               pushbacktoken();
                        break;
                case '{':  /* } */
                        DBG_PRINT(level, "{"); /* } */
@@ -309,7 +328,6 @@ Cpp(const struct parser_param *param)
                        if ((c = nexttoken(interested, cpp_reserved_word)) == 
SYMBOL)
                                PUT(PARSER_REF_SYM, token, lineno, sp);
                        break;
-               case CPP_STRUCT:
                case CPP_ENUM:
                case CPP_UNION:
                        while ((c = nexttoken(interested, cpp_reserved_word)) 
== CPP___ATTRIBUTE__)
diff -urp global-6.3.3/libutil/token.c global-6.3-3/libutil/token.c
--- global-6.3.3/libutil/token.c        2014-11-26 12:49:37 +1000
+++ global-6.3-3/libutil/token.c        2014-12-01 17:47:04 +1000
@@ -179,15 +179,13 @@ nexttoken(const char *interested, int (*
                                sharp = 1;
                                continue;
                        }
-               } else if (c == ':' && cppmode) {
-                       if (peekc(1) == ':') {
-                               p = token;
-                               *p++ = c;
-                               *p++ = nextchar();
-                               *p   = 0;
-                               if (reserved && (c = (*reserved)(token, tlen)) 
== 0)
-                                       break;
-                       }
+               } else if (c == ':' && cppmode && peekc(1) == ':') {
+                       p = token;
+                       *p++ = c;
+                       *p++ = nextchar();
+                       *p   = 0;
+                       if (reserved && (c = (*reserved)(token, tlen)) == 0)
+                               break;
                } else if (c == '%' && ymode) {
                        /* recognize '%%' as a token if it is reserved word. */
                        if (atfirst) {
_______________________________________________
Bug-global mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global

Reply via email to