* etags.c (C_entries): Properly skip over string and character
authorAndreas Schwab <schwab@linux-m68k.org>
Sun, 25 Dec 2011 09:55:37 +0000 (10:55 +0100)
committerAndreas Schwab <schwab@linux-m68k.org>
Sun, 25 Dec 2011 09:55:37 +0000 (10:55 +0100)
constants inside brackets.  (Bug#10357)

lib-src/ChangeLog
lib-src/etags.c

index 4040482..e989473 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-25  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * etags.c (C_entries): Properly skip over string and character
+       constants and comments inside brackets.  (Bug#10357)
+
 2011-12-04  Juanma Barranquero  <lekktu@gmail.com>
 
        * emacsclient.c (decode_options) [WINDOWSNT]: Don't force tty = 0;
index 30d90e9..8852c9f 100644 (file)
@@ -3189,24 +3189,12 @@ C_entries (int c_ext, FILE *inf)
            }
          continue;
        }
-      else if (bracketlev > 0)
-       {
-         switch (c)
-           {
-           case ']':
-             if (--bracketlev > 0)
-               continue;
-             break;
-           case '\0':
-             CNL_SAVE_DEFINEDEF ();
-             break;
-           }
-         continue;
-       }
       else switch (c)
        {
        case '"':
          inquote = TRUE;
+         if (bracketlev > 0)
+           continue;
          if (inattribute)
            break;
          switch (fvdef)
@@ -3224,9 +3212,11 @@ C_entries (int c_ext, FILE *inf)
          continue;
        case '\'':
          inchar = TRUE;
+         if (bracketlev > 0)
+           continue;
          if (inattribute)
            break;
-         if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
+         if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
            {
              fvextern = FALSE;
              fvdef = fvnone;
@@ -3238,6 +3228,8 @@ C_entries (int c_ext, FILE *inf)
              incomm = TRUE;
              lp++;
              c = ' ';
+             if (bracketlev > 0)
+               continue;
            }
          else if (/* cplpl && */ *lp == '/')
            {
@@ -3270,7 +3262,7 @@ C_entries (int c_ext, FILE *inf)
              for (cp = newlb.buffer; cp < lp-1; cp++)
                if (!iswhite (*cp))
                  {
-                   if (*cp == '*' && *(cp+1) == '/')
+                   if (*cp == '*' && cp[1] == '/')
                      {
                        cp++;
                        cpptoken = TRUE;
@@ -3284,7 +3276,17 @@ C_entries (int c_ext, FILE *inf)
          continue;
        case '[':
          bracketlev++;
-           continue;
+         continue;
+       default:
+         if (bracketlev > 0)
+           {
+             if (c == ']')
+               --bracketlev;
+             else if (c == '\0')
+               CNL_SAVE_DEFINEDEF ();
+             continue;
+           }
+         break;
        } /* switch (c) */