emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c03c195: Fix tagging of symbols in C enumerations


From: Eli Zaretskii
Subject: [Emacs-diffs] master c03c195: Fix tagging of symbols in C enumerations
Date: Tue, 12 May 2015 16:37:03 +0000

branch: master
commit c03c195a274ab4092cc5f2a881a87cb2643d9b3b
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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.
---
 lib-src/etags.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib-src/etags.c b/lib-src/etags.c
index b1361db..f243821 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,
      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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]