aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorEli Zaretskii2015-05-12 19:35:54 +0300
committerEli Zaretskii2015-05-12 19:35:54 +0300
commitc03c195a274ab4092cc5f2a881a87cb2643d9b3b (patch)
treebc4d33dcb429e5cf18269de837c3e9a8130ce5ed /lib-src
parent20cca4738aae1e90c6ca7770135fc2b30c08e0f3 (diff)
downloademacs-c03c195a274ab4092cc5f2a881a87cb2643d9b3b.tar.gz
emacs-c03c195a274ab4092cc5f2a881a87cb2643d9b3b.zip
Fix tagging of symbols in C enumerations
* lib-src/etags.c (consider_token): Don't tag symbols in expressions that assign values to enum constants. See http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00291.html for details. (C_entries): Reset fvdef to fvnone after processing a preprocessor conditional and after a comma outside of parentheses.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index b1361dbe7ad..f2438213d04 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -2862,7 +2862,10 @@ consider_token (char *str, int len, int c, int *c_extp,
2862 case st_none: 2862 case st_none:
2863 if (constantypedefs 2863 if (constantypedefs
2864 && structdef == snone 2864 && structdef == snone
2865 && structtype == st_C_enum && bracelev > structbracelev) 2865 && structtype == st_C_enum && bracelev > structbracelev
2866 /* Don't tag tokens in expressions that assign values to enum
2867 constants. */
2868 && fvdef != vignore)
2866 return true; /* enum constant */ 2869 return true; /* enum constant */
2867 switch (fvdef) 2870 switch (fvdef)
2868 { 2871 {
@@ -3176,7 +3179,19 @@ C_entries (int c_ext, FILE *inf)
3176 cpptoken = false; 3179 cpptoken = false;
3177 } 3180 }
3178 if (cpptoken) 3181 if (cpptoken)
3179 definedef = dsharpseen; 3182 {
3183 definedef = dsharpseen;
3184 /* This is needed for tagging enum values: when there are
3185 preprocessor conditionals inside the enum, we need to
3186 reset the value of fvdef so that the next enum value is
3187 tagged even though the one before it did not end in a
3188 comma. */
3189 if (fvdef == vignore && instruct && parlev == 0)
3190 {
3191 if (strneq (cp, "#if", 3) || strneq (cp, "#el", 3))
3192 fvdef = fvnone;
3193 }
3194 }
3180 } /* if (definedef == dnone) */ 3195 } /* if (definedef == dnone) */
3181 continue; 3196 continue;
3182 case '[': 3197 case '[':
@@ -3507,7 +3522,10 @@ C_entries (int c_ext, FILE *inf)
3507 case fstartlist: 3522 case fstartlist:
3508 case finlist: 3523 case finlist:
3509 case fignore: 3524 case fignore:
3525 break;
3510 case vignore: 3526 case vignore:
3527 if (instruct && parlev == 0)
3528 fvdef = fvnone;
3511 break; 3529 break;
3512 case fdefunname: 3530 case fdefunname:
3513 fvdef = fignore; 3531 fvdef = fignore;