On 26/11/2014 10:28, Shigio YAMAGUCHI wrote: > Hi, > I have recovered the previous version, because the patch brought > the following error [struct {};].
Fixed; I also allowed for extra newlines. C:\test>cat -n test.cpp 1 class {}; 2 class Ignore1; 3 class EXTERN Ignore2; 4 class C1 {}; 5 class EXTERN C2 {}; 6 class 7 {}; 8 class 9 C3 {}; 10 class 11 C4 12 {}; 13 class 14 EXTERNAL 15 C5 16 {}; C:\test>gtags C:\test>global -x .* C1 4 test.cpp class C1 {}; C2 5 test.cpp class EXTERN C2 {}; C3 9 test.cpp C3 {}; C4 11 test.cpp C4 C5 15 test.cpp C5 -- Jason.
diff -urp global-6.3.2/libparser/Cpp.c global-6.3-2/libparser/Cpp.c --- global-6.3.2/libparser/Cpp.c 2014-09-04 15:46:14 +1000 +++ global-6.3-2/libparser/Cpp.c 2014-11-26 15:21:33 +1000 @@ -182,19 +182,41 @@ 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, cpp_reserved_word)) == CPP___ATTRIBUTE__ || c == '\n') + if (c == CPP___ATTRIBUTE__) + process_attribute(param); + if (c == SYMBOL) { + int newlines = 0; + char *saveline; + strbuf_reset(sb); + strbuf_puts(sb, sp); + saveline = strbuf_value(sb); + for (;;) { + strlimcpy(classname, token, sizeof(classname)); + c = nexttoken(interested, cpp_reserved_word); + if (c == SYMBOL) { + newlines = 0; + strbuf_reset(sb); + strbuf_puts(sb, sp); + saveline = strbuf_value(sb); + } else if (c == '\n') + ++newlines; + else + break; + } /* * Ignore forward definitions. * "class name;" */ - if (peekc(0) != ';') { + if (c != ';') { startclass = 1; - PUT(PARSER_DEF, token, lineno, sp); + PUT(PARSER_DEF, classname, lineno - newlines, saveline); } } + pushbacktoken(); break; case '{': /* } */ DBG_PRINT(level, "{"); /* } */ @@ -309,7 +331,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__)
_______________________________________________ Bug-global mailing list Bug-global@gnu.org https://lists.gnu.org/mailman/listinfo/bug-global