]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix tagging of symbols in C enumerations
authorEli Zaretskii <eliz@gnu.org>
Tue, 12 May 2015 16:35:54 +0000 (19:35 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 12 May 2015 16:35:54 +0000 (19:35 +0300)
* 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.

lib-src/etags.c

index b1361dbe7ad6f197847b59fd1ed23d3fd366901c..f2438213d046f0b90ce66d74277a6b1a5e27e72c 100644 (file)
@@ -2862,7 +2862,10 @@ consider_token (char *str, int len, int c, int *c_extp,
      case st_none:
        if (constantypedefs
           && structdef == snone
-          && structtype == st_C_enum && bracelev > structbracelev)
+          && structtype == st_C_enum && bracelev > structbracelev
+          /* Don't tag tokens in expressions that assign values to enum
+             constants.  */
+          && fvdef != vignore)
         return true;           /* enum constant */
        switch (fvdef)
         {
@@ -3176,7 +3179,19 @@ C_entries (int c_ext, FILE *inf)
                      cpptoken = false;
                  }
              if (cpptoken)
-               definedef = dsharpseen;
+               {
+                 definedef = dsharpseen;
+                 /* This is needed for tagging enum values: when there are
+                    preprocessor conditionals inside the enum, we need to
+                    reset the value of fvdef so that the next enum value is
+                    tagged even though the one before it did not end in a
+                    comma.  */
+                 if (fvdef == vignore && instruct && parlev == 0)
+                   {
+                     if (strneq (cp, "#if", 3) || strneq (cp, "#el", 3))
+                       fvdef = fvnone;
+                   }
+               }
            } /* if (definedef == dnone) */
          continue;
        case '[':
@@ -3507,7 +3522,10 @@ C_entries (int c_ext, FILE *inf)
            case fstartlist:
            case finlist:
            case fignore:
+             break;
            case vignore:
+             if (instruct && parlev == 0)
+               fvdef = fvnone;
              break;
            case fdefunname:
              fvdef = fignore;