emacs-devel
[Top][All Lists]
Advanced

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

Re: xref-find-matches and stuff


From: Eli Zaretskii
Subject: Re: xref-find-matches and stuff
Date: Sun, 10 May 2015 17:48:49 +0300

> Cc: address@hidden, address@hidden
> From: Dmitry Gutov <address@hidden>
> Date: Sun, 10 May 2015 00:56:36 +0300
> 
> On 05/09/2015 04:22 PM, Eli Zaretskii wrote:
> 
> > C is a hard language to parse with ad-hoc parsers.  If you know of a
> > better tool that doesn't get confused by the source at that point of
> > lisp.h (did you look at it?), name it.
> 
> GNU Global doesn't, at least not in this example:
> 
> ~/v/e/src> global -x Lisp_Object
> Lisp_Object 567 lisp.h typedef struct { EMACS_INT i; } Lisp_Object;
> Lisp_Object 577 lisp.h typedef EMACS_INT Lisp_Object;

With the patch below, neither will etags.

Francesco, do you see any problems with it?

--- lib-src/etags.c~0   2015-03-29 08:32:03 +0300
+++ lib-src/etags.c     2015-05-10 12:15:23 +0300
@@ -2862,7 +2862,10 @@ consider_token (char *str, int len, int
      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]