On 17/11/2014 0:05, Julien Montmartin wrote:
>
> Looking at the code, I found an easy way to fix it. Not sure if it's the best
> way to go, but at least "It works on my machine" ;)
I think you and Shigio are both overthinking it, as it seems ctags & pygments
simply take the identifier before the brace, so that's what I've done, too (as
well as doing it for struct).
C:\test>cat test.cpp
class EXTERNAL1 EXTERNAL2 Class {};
struct EXTERNAL1 EXTERNAL2 Struct {};
C:\test>gtags % the current version %
C:\test>global -x .*
EXTERNAL1 1 test.cpp class EXTERNAL1 EXTERNAL2 Class {};
C:\test>gtags % the patched version %
C:\test>global -x .*
Class 1 test.cpp class EXTERNAL1 EXTERNAL2 Class {};
Struct 2 test.cpp struct EXTERNAL1 EXTERNAL2 Struct {};
Testing has been *really* minimal (just the above :) ), so I hope it doesn't
break anything else.
--
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-18 18:10:30 +1000
@@ -182,19 +182,25 @@ 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) {
+ DBG_PRINT(level, cc == CPP_CLASS ? "class" : "struct");
+ while ((c = nexttoken(interested, cpp_reserved_word))
== CPP___ATTRIBUTE__)
+ process_attribute(param);
+ while (c == SYMBOL) {
strlimcpy(classname, token, sizeof(classname));
- /*
- * Ignore forward definitions.
- * "class name;"
- */
- if (peekc(0) != ';') {
- startclass = 1;
- PUT(PARSER_DEF, token, lineno, sp);
- }
+ c = nexttoken(interested, cpp_reserved_word);
}
+ /*
+ * Ignore forward definitions.
+ * "class name;"
+ */
+ if (c != ';') {
+ startclass = 1;
+ PUT(PARSER_DEF, classname, lineno, sp);
+ } else
+ pushbacktoken();
+
break;
case '{': /* } */
DBG_PRINT(level, "{"); /* } */
@@ -309,7 +315,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
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-global