emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lib-src/etags.c


From: Francesco Potortì
Subject: [Emacs-diffs] Changes to emacs/lib-src/etags.c
Date: Sat, 15 Dec 2001 11:07:31 -0500

Index: emacs/lib-src/etags.c
diff -c emacs/lib-src/etags.c:3.5 emacs/lib-src/etags.c:3.6
*** emacs/lib-src/etags.c:3.5   Mon Sep 17 11:47:23 2001
--- emacs/lib-src/etags.c       Sat Dec 15 11:07:31 2001
***************
*** 32,38 ****
   *    Francesco Potortì <address@hidden> has maintained it since 1993.
   */
  
! char pot_etags_version[] = "@(#) pot revision number is 14.21";
  
  #define       TRUE    1
  #define       FALSE   0
--- 32,38 ----
   *    Francesco Potortì <address@hidden> has maintained it since 1993.
   */
  
! char pot_etags_version[] = "@(#) pot revision number is 14.26";
  
  #define       TRUE    1
  #define       FALSE   0
***************
*** 61,66 ****
--- 61,67 ----
  #else
  # ifndef __STDC__
  #   define static             /* remove static for old compilers' sake */
+ #   define const              /* same for const */
  # endif
  #endif /* !HAVE_CONFIG_H */
  
***************
*** 148,153 ****
--- 149,162 ----
  #endif /* LONG_OPTIONS */
  
  #ifdef ETAGS_REGEXPS
+ # ifndef HAVE_CONFIG_H                /* this is a standalone compilation */
+ #   ifdef __CYGWIN__          /* compiling on Cygwin */
+                            !!! NOTICE !!!
+  the regex.h distributed with Cygwin is not compatible with etags, alas!
+ If you want regular expression support, you should delete this notice and
+             arrange to use the GNU regex.h and regex.c.
+ #   endif
+ # endif
  # include <regex.h>
  #endif /* ETAGS_REGEXPS */
  
***************
*** 272,277 ****
--- 281,287 ----
  static void Makefile_targets P_((FILE *));
  static void Pascal_functions P_((FILE *));
  static void Perl_functions P_((FILE *));
+ static void PHP_functions P_((FILE *));
  static void Postscript_functions P_((FILE *));
  static void Prolog_functions P_((FILE *));
  static void Python_functions P_((FILE *));
***************
*** 521,526 ****
--- 531,539 ----
  char *Perl_interpreters [] =
    { "perl", "@PERL@", NULL };
  
+ char *PHP_suffixes [] =
+   { "php", "php3", "php4", NULL };
+ 
  char *plain_C_suffixes [] =
    { "lm",                     /* Objective lex file */
      "m",                      /* Objective C file */
***************
*** 571,576 ****
--- 584,590 ----
    { "makefile",   Makefile_targets,     Makefile_filenames, NULL,             
NULL },
    { "pascal",           Pascal_functions,     NULL, Pascal_suffixes,          
NULL },
    { "perl",             Perl_functions,     NULL, Perl_suffixes, 
Perl_interpreters },
+   { "php",      PHP_functions,        NULL, PHP_suffixes,             NULL },
    { "postscript", Postscript_functions, NULL, Postscript_suffixes,    NULL },
    { "proc",             plain_C_entries,      NULL, plain_C_suffixes,         
NULL },
    { "prolog",           Prolog_functions,     NULL, Prolog_suffixes,          
NULL },
***************
*** 3582,3588 ****
  }
  
  
! /* A useful macro. */
  #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer)  \
    for (lineno = charno = 0;   /* loop initialization */               \
         !feof (file_pointer)   /* loop test */                         \
--- 3596,3602 ----
  }
  
  
! /* Useful macros. */
  #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer)  \
    for (lineno = charno = 0;   /* loop initialization */               \
         !feof (file_pointer)   /* loop test */                         \
***************
*** 3592,3598 ****
           char_pointer = lb.buffer,                                    \
           TRUE);                                                       \
        )
! 
  
  /*
   * Read a file, but do no processing.  This is used to do regexp
--- 3606,3615 ----
           char_pointer = lb.buffer,                                    \
           TRUE);                                                       \
        )
! #define LOOKING_AT(cp, keyword)       /* keyword is a constant string */      
\
!   (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at kyword */        
\
!    && iswhite((cp)[sizeof(keyword)-1])        /* followed by a blank */       
\
!    && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip blanks */
  
  /*
   * Read a file, but do no processing.  This is used to do regexp
***************
*** 3971,3981 ****
  
    LOOP_ON_INPUT_LINES (inf, lb, cp)
      {
!       if (*cp++ == 's'
!         && *cp++ == 'u'
!         && *cp++ == 'b' && iswhite (*cp++))
        {
-         cp = skip_spaces (cp);
          if (*cp != '\0')
            {
              char *sp = cp;
--- 3988,3995 ----
  
    LOOP_ON_INPUT_LINES (inf, lb, cp)
      {
!       if (LOOKING_AT (cp, "sub"))
        {
          if (*cp != '\0')
            {
              char *sp = cp;
***************
*** 3987,4001 ****
            }
        }
         else if (globals               /* only if tagging global vars is 
enabled */
!               && ((cp = lb.buffer,
!                    *cp++ == 'm'
!                    && *cp++ == 'y')
!                   || (cp = lb.buffer,
!                       *cp++ == 'l'
!                       && *cp++ == 'o'
!                       && *cp++ == 'c'
!                       && *cp++ == 'a'
!                       && *cp++ == 'l'))
                && (*cp == '(' || iswhite (*cp)))
        {
          /* After "my" or "local", but before any following paren or space. */
--- 4001,4008 ----
            }
        }
         else if (globals               /* only if tagging global vars is 
enabled */
!               && ((strneq (cp, "my", 2) && (cp+=2))
!                   || (strneq (cp, "local", 5) && (cp+=5)))
                && (*cp == '(' || iswhite (*cp)))
        {
          /* After "my" or "local", but before any following paren or space. */
***************
*** 4025,4031 ****
      }
  }
  
! 
  /*
   * Python support
   * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
--- 4032,4038 ----
      }
  }
  
! 
  /*
   * Python support
   * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
***************
*** 4038,4066 ****
    register char *cp;
  
    LOOP_ON_INPUT_LINES (inf, lb, cp)
      {
!       if (*cp++ == 'd'
!         && *cp++ == 'e'
!         && *cp++ == 'f' && iswhite (*cp++))
        {
!         cp = skip_spaces (cp);
!         while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
            cp++;
          pfnote (NULL, TRUE,
                  lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
        }
! 
!       cp = lb.buffer;
!       if (*cp++ == 'c'
!         && *cp++ == 'l'
!         && *cp++ == 'a'
!         && *cp++ == 's'
!         && *cp++ == 's' && iswhite (*cp++))
        {
!         cp = skip_spaces (cp);
!         while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
            cp++;
!         pfnote (NULL, TRUE,
                  lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
        }
      }
--- 4045,4133 ----
    register char *cp;
  
    LOOP_ON_INPUT_LINES (inf, lb, cp)
+     if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
+       {
+       while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
+         cp++;
+       pfnote (NULL, TRUE,
+               lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+       }
+ }
+ 
+ 
+ /*
+  * PHP support
+  * Look for:
+  *  - /^[ \t]*function[ \t\n]+[^ \t\n(]+/
+  *  - /^[ \t]*class[ \t\n]+[^ \t\n]+/
+  *  - /^[ \t]*define\(\"[^\"]+/
+  * Only with --members:
+  *  - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
+  * originally by Diez B. Roggisch 2001-06-06
+  */
+ static void
+ PHP_functions (inf)
+      FILE *inf;
+ {
+   register char *cp;
+   bool search_identifier = FALSE;
+ 
+   LOOP_ON_INPUT_LINES (inf, lb, cp)
      {
!       cp = skip_spaces (cp);
!       if (search_identifier
!         && *cp != '\0')
        {
!         while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
            cp++;
          pfnote (NULL, TRUE,
                  lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+         search_identifier = FALSE;
        }
!       else if (LOOKING_AT (cp, "function"))
!       {
!         if(*cp == '&')
!           cp = skip_spaces (cp+1);
!         if(*cp != '\0')
!           {
!             while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
!               cp++;
!             pfnote (NULL, TRUE,
!                     lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
!           }
!         else
!           search_identifier = TRUE;
!       }
!       else if (LOOKING_AT (cp, "class"))
!       {
!         if (*cp != '\0')
!           {
!             while (*cp != '\0' && !iswhite (*cp))
!               cp++;
!             pfnote (NULL, FALSE,
!                     lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
!           }
!         else
!           search_identifier = TRUE;
!       }
!       else if (strneq (cp, "define", 6)
!              && (cp = skip_spaces (cp+6))
!              && *cp++ == '('
!              && (*cp == '"' || *cp == '\''))
        {
!         char quote = *cp++;
!         while (*cp != quote && *cp != '\0')
            cp++;
!         pfnote (NULL, FALSE,
!                 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
!       }
!       else if (members
!              && LOOKING_AT (cp, "var")
!              && *cp == '$')
!       {
!         while (*cp != '=' && *cp != ';' && *cp != '\0' && !iswhite(*cp))
!           cp++;
!         pfnote (NULL, FALSE,
                  lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
        }
      }
***************
*** 4461,4477 ****
            bp++;
          get_tag (bp);
        }
!       if (bp[0] == '('
!         && (bp[1] == 'S' || bp[1] == 's')
!         && (bp[2] == 'E' || bp[2] == 'e')
!         && (bp[3] == 'T' || bp[3] == 't')
!         && (bp[4] == '!' || bp[4] == '!')
!         && (iswhite (bp[5])))
!       {
!         bp = skip_non_spaces (bp);
!         bp = skip_spaces (bp);
!         get_tag (bp);
!       }
      }
  }
  
--- 4528,4535 ----
            bp++;
          get_tag (bp);
        }
!       if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!"))
!       get_tag (bp);
      }
  }
  
***************
*** 4666,4685 ****
  {
    char *cp, *start;
    LOOP_ON_INPUT_LINES (inf, lb, cp)
!     {
!       if ((*cp++ == '@'
!          && *cp++ == 'n'
!          && *cp++ == 'o'
!          && *cp++ == 'd'
!          && *cp++ == 'e' && iswhite (*cp++)))
!       {
!         start = cp = skip_spaces(cp);
!         while (*cp != '\0' && *cp != ',')
!           cp++;
!         pfnote (savenstr (start, cp - start), TRUE,
!                 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
!       }
!     }
  }
  
  
--- 4724,4737 ----
  {
    char *cp, *start;
    LOOP_ON_INPUT_LINES (inf, lb, cp)
!     if (LOOKING_AT (cp, "@node"))
!       {
!       start = cp;
!       while (*cp != '\0' && *cp != ',')
!         cp++;
!       pfnote (savenstr (start, cp - start), TRUE,
!               lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
!       }
  }
  
  
***************
*** 4689,4695 ****
   * Assumes that the predicate starts at column 0.
   * Only the first clause of a predicate is added.
   */
! static int prolog_pred P_((char *, char *));
  static void prolog_skip_comment P_((linebuffer *, FILE *));
  static int prolog_atom P_((char *, int));
  
--- 4741,4747 ----
   * Assumes that the predicate starts at column 0.
   * Only the first clause of a predicate is added.
   */
! static int prolog_pr P_((char *, char *));
  static void prolog_skip_comment P_((linebuffer *, FILE *));
  static int prolog_atom P_((char *, int));
  
***************
*** 4713,4719 ****
        continue;
        else if (cp[0] == '/' && cp[1] == '*')  /* comment. */
        prolog_skip_comment (&lb, inf);
!       else if ((len = prolog_pred (cp, last)) > 0)
        {
          /* Predicate.  Store the function name so that we only
             generate a tag for the first clause.  */
--- 4765,4771 ----
        continue;
        else if (cp[0] == '/' && cp[1] == '*')  /* comment. */
        prolog_skip_comment (&lb, inf);
!       else if ((len = prolog_pr (cp, last)) > 0)
        {
          /* Predicate.  Store the function name so that we only
             generate a tag for the first clause.  */
***************
*** 4748,4764 ****
  }
  
  /*
!  * A predicate definition is added if it matches:
   *     <beginning of line><Prolog Atom><whitespace>(
   *
   * It is added to the tags database if it doesn't match the
   * name of the previous clause header.
   *
!  * Return the size of the name of the predicate, or 0 if no header
!  * was found.
   */
  static int
! prolog_pred (s, last)
       char *s;
       char *last;              /* Name of last clause. */
  {
--- 4800,4817 ----
  }
  
  /*
!  * A predicate or rule definition is added if it matches:
   *     <beginning of line><Prolog Atom><whitespace>(
+  * or  <beginning of line><Prolog Atom><whitespace>:-
   *
   * It is added to the tags database if it doesn't match the
   * name of the previous clause header.
   *
!  * Return the size of the name of the predicate or rule, or 0 if no
!  * header was found.
   */
  static int
! prolog_pr (s, last)
       char *s;
       char *last;              /* Name of last clause. */
  {
***************
*** 4772,4792 ****
    len = pos;
    pos = skip_spaces (s + pos) - s;
  
!   if ((s[pos] == '(') || (s[pos] == '.'))
!     {
!       if (s[pos] == '(')
!       pos++;
! 
!       /* Save only the first clause. */
!       if (last == NULL
!         || len != (int)strlen (last)
!         || !strneq (s, last, len))
        {
          pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
          return len;
        }
!     }
!   return 0;
  }
  
  /*
--- 4825,4842 ----
    len = pos;
    pos = skip_spaces (s + pos) - s;
  
!   if ((s[pos] == '.'
!        || (s[pos] == '(' && (pos += 1))
!        || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
!       && (last == NULL                /* save only the first clause */
!         || len != strlen (last)
!         || !strneq (s, last, len)))
        {
          pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
          return len;
        }
!   else
!     return 0;
  }
  
  /*
***************
*** 5817,5819 ****
--- 5867,5878 ----
      fatal ("virtual memory exhausted", (char *)NULL);
    return result;
  }
+ 
+ /*
+  * Local Variables:
+  * c-indentation-style: gnu
+  * indent-tabs-mode: t
+  * tab-width: 8
+  * c-font-lock-extra-types: ("FILE" "bool" "linebuffer")
+  * End:
+  */



reply via email to

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