]> code.delx.au - gnu-emacs/commitdiff
* lib-src/etags.c (Perl_functions): Support "use constant".
authorKevin Ryde <user42@zip.com.au>
Sat, 1 Dec 2012 01:22:28 +0000 (09:22 +0800)
committerChong Yidong <cyd@gnu.org>
Sat, 1 Dec 2012 01:22:28 +0000 (09:22 +0800)
* doc/emacs/maintaining.texi (Tag Syntax): Mention Perl's "use constant".

Fixes: debbugs:5055
doc/emacs/ChangeLog
doc/emacs/maintaining.texi
lib-src/ChangeLog
lib-src/etags.c

index 5c4ae2e1ee0491f5ce46c1e28abdfab84e0568d4..fd54378975105ac2c09b88546cc7a6b47be64815 100644 (file)
@@ -1,3 +1,7 @@
+2012-12-01  Kevin Ryde  <user42@zip.com.au>
+
+       * maintaining.texi (Tag Syntax): Mention Perl's "use constant".
+
 2012-11-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        * doclicense.texi, gpl.texi: Update to latest version from FSF.
index 67214bde22c47e9dd2f9c54019d548c4b14bb596..06680a6b4e38fd549214bc144e362464902eee06 100644 (file)
@@ -1766,11 +1766,11 @@ the file.
 
 @item
 In Perl code, the tags are the packages, subroutines and variables
-defined by the @code{package}, @code{sub}, @code{my} and @code{local}
-keywords.  Use @samp{--globals} if you want to tag global variables.
-Tags for subroutines are named @samp{@var{package}::@var{sub}}.  The
-name for subroutines defined in the default package is
-@samp{main::@var{sub}}.
+defined by the @code{package}, @code{sub}, @code{use constant},
+@code{my}, and @code{local} keywords.  Use @samp{--globals} if you
+want to tag global variables.  Tags for subroutines are named
+@samp{@var{package}::@var{sub}}.  The name for subroutines defined in
+the default package is @samp{main::@var{sub}}.
 
 @item
 In PHP code, tags are functions, classes and defines.  Vars are tags
index a74d4b90b9f8df2883ff2e340094d4647af0dfbc..294661a6cb3a13154bb4290b1cc2477c74158f08 100644 (file)
@@ -1,3 +1,7 @@
+2012-12-01  Kevin Ryde  <user42@zip.com.au>
+
+       * etags.c (Perl_functions): Support "use constant" (Bug#5055).
+
 2012-11-27  Paul Eggert  <eggert@cs.ucla.edu>
 
        Assume POSIX 1003.1-1988 or later for errno.h (Bug#12968).
index b6af17b8edf74042b1d9d8331cd1616c24a0afb0..ec185c9819f7a6ff4315287824b92313330268d7 100644 (file)
@@ -4269,6 +4269,7 @@ Asm_labels (FILE *inf)
 /*
  * Perl support
  * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/
+ *                 /^use constant[ \t\n]+[^ \t\n{=,;]+/
  * Perl variable names: /^(my|local).../
  * Original code by Bart Robinson <lomew@cs.utah.edu> (1995)
  * Additions by Michael Ernst <mernst@alum.mit.edu> (1997)
@@ -4291,9 +4292,10 @@ Perl_functions (FILE *inf)
        }
       else if (LOOKING_AT (cp, "sub"))
        {
-         char *pos;
-         char *sp = cp;
+         char *pos, *sp;
 
+       subr:
+         sp = cp;
          while (!notinname (*cp))
            cp++;
          if (cp == sp)
@@ -4316,8 +4318,21 @@ Perl_functions (FILE *inf)
                        lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
              free (name);
            }
+       }
+      else if (LOOKING_AT (cp, "use constant")
+              || LOOKING_AT (cp, "use constant::defer"))
+       {
+         /* For hash style multi-constant like
+               use constant { FOO => 123,
+                              BAR => 456 };
+            only the first FOO is picked up.  Parsing across the value
+            expressions would be difficult in general, due to possible nested
+            hashes, here-documents, etc.  */
+         if (*cp == '{')
+           cp = skip_spaces (cp+1);
+         goto subr;
        }
-       else if (globals)       /* only if we are tagging global vars */
+      else if (globals)        /* only if we are tagging global vars */
        {
          /* Skip a qualifier, if any. */
          bool qual = LOOKING_AT (cp, "my") || LOOKING_AT (cp, "local");