calc-math.el (math-largest-emacs-expt): Handle the cases when expt
[bpt/emacs.git] / lib-src / etags.c
index 1d1f16d..0412137 100644 (file)
@@ -36,8 +36,8 @@ This file is not considered part of GNU Emacs.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -45,8 +45,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software Foundation,
-Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+along with this program; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
 
 
 /* NB To comply with the above BSD license, copyright information is
@@ -60,10 +61,10 @@ University of California, as described above. */
 
 /*
  * Authors:
- *     Ctags originally by Ken Arnold.
- *     Fortran added by Jim Kleckner.
- *     Ed Pelegri-Llopart added C typedefs.
- *     Gnu Emacs TAGS format and modifications by RMS?
+ * 1983        Ctags originally by Ken Arnold.
+ * 1984        Fortran added by Jim Kleckner.
+ * 1984        Ed Pelegri-Llopart added C typedefs.
+ * 1985        Emacs TAGS format by Richard Stallman.
  * 1989        Sam Kendall added C++.
  * 1992 Joseph B. Wells improved C and C++ parsing.
  * 1993        Francesco Potortì reorganised C and C++.
@@ -80,7 +81,7 @@ University of California, as described above. */
  * configuration file containing regexp definitions for etags.
  */
 
-char pot_etags_version[] = "@(#) pot revision number is 17.26";
+char pot_etags_version[] = "@(#) pot revision number is 17.34";
 
 #define        TRUE    1
 #define        FALSE   0
@@ -159,7 +160,14 @@ char pot_etags_version[] = "@(#) pot revision number is 17.26";
 #  include <stdlib.h>
 #  include <string.h>
 # else /* no standard C headers */
-    extern char *getenv ();
+   extern char *getenv ();
+   extern char *strcpy ();
+   extern char *strncpy ();
+   extern char *strcat ();
+   extern char *strncat ();
+   extern unsigned long strlen ();
+   extern PTR malloc ();
+   extern PTR realloc ();
 #  ifdef VMS
 #   define EXIT_SUCCESS        1
 #   define EXIT_FAILURE        0
@@ -483,7 +491,7 @@ static char
   *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
 
 static bool append_to_tagfile; /* -a: append to tags */
-/* The next four default to TRUE for etags, but to FALSE for ctags.  */
+/* The next five default to TRUE for etags, but to FALSE for ctags.  */
 static bool typedefs;          /* -t: create tags for C and Ada typedefs */
 static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
                                /* 0 struct/enum/union decls, and C++ */
@@ -875,18 +883,25 @@ etags --help --lang=ada.");
 # define EMACS_NAME "standalone"
 #endif
 #ifndef VERSION
-# define VERSION "version"
+# define VERSION "17.34"
 #endif
 static void
 print_version ()
 {
+  /* Makes it easier to update automatically. */
+  char emacs_copyright[] = "Copyright (C) 2007 Free Software Foundation, Inc.";
+
   printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
-  puts ("Copyright (C) 2007 Free Software Foundation, Inc.");
+  puts (emacs_copyright);
   puts ("This program is distributed under the terms in ETAGS.README");
 
   exit (EXIT_SUCCESS);
 }
 
+#ifndef PRINT_UNDOCUMENTED_OPTIONS_HELP
+# define PRINT_UNDOCUMENTED_OPTIONS_HELP FALSE
+#endif
+
 static void
 print_help (argbuffer)
      argument *argbuffer;
@@ -969,7 +984,16 @@ Relative ones are stored relative to the output file's directory.\n");
     puts ("--no-globals\n\
        Do not create tag entries for global variables in some\n\
        languages.  This makes the tags file smaller.");
-  puts ("--no-members\n\
+
+  if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
+    puts ("--no-line-directive\n\
+        Ignore #line preprocessor directives in C and derived languages.");
+
+  if (CTAGS)
+    puts ("--members\n\
+       Create tag entries for members of structures in some languages.");
+  else
+    puts ("--no-members\n\
        Do not create tag entries for members of structures\n\
        in some languages.");
 
@@ -985,13 +1009,17 @@ Relative ones are stored relative to the output file's directory.\n");
        MODS are optional one-letter modifiers: `i' means to ignore case,\n\
        `m' means to allow multi-line matches, `s' implies `m' and\n\
        causes dot to match any character, including newline.");
+
   puts ("-R, --no-regex\n\
         Don't create tags from regexps for the following files.");
+
   puts ("-I, --ignore-indentation\n\
         In C and C++ do not assume that a closing brace in the first\n\
         column is the final brace of a function or structure definition.");
+
   puts ("-o FILE, --output=FILE\n\
         Write the tags to FILE.");
+
   puts ("--parse-stdin=NAME\n\
         Read from standard input and record tags as belonging to file NAME.");
 
@@ -1019,13 +1047,16 @@ Relative ones are stored relative to the output file's directory.\n");
         Print on the standard output an index of items intended for\n\
         human consumption, similar to the output of vgrind.  The index\n\
         is sorted, and gives the page number of each item.");
-# if PRINT_UNDOCUMENTED_OPTIONS_HELP
-      puts ("-w, --no-duplicates\n\
+
+      if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
+       puts ("-w, --no-duplicates\n\
         Do not create duplicate tag entries, for compatibility with\n\
        traditional ctags.");
-      puts ("-w, --no-warn\n\
+
+      if (PRINT_UNDOCUMENTED_OPTIONS_HELP)
+       puts ("-w, --no-warn\n\
         Suppress warning messages about duplicate tag entries.");
-# endif /* PRINT_UNDOCUMENTED_OPTIONS_HELP */
+
       puts ("-x, --cxref\n\
         Like --vgrind, but in the style of cxref, rather than vgrind.\n\
         The output uses line numbers instead of page numbers, but\n\
@@ -1215,7 +1246,7 @@ main (argc, argv)
   if (!CTAGS)
     {
       typedefs = typedefs_or_cplusplus = constantypedefs = TRUE;
-      globals = TRUE;
+      globals = members = TRUE;
     }
 
   /* When the optstring begins with a '-' getopt_long does not rearrange the
@@ -2852,7 +2883,7 @@ static void make_C_tag __P((bool));
  *     function or variable, or corresponds to a typedef, or
  *     is a struct/union/enum tag, or #define, or an enum constant.
  *
- *     *IS_FUNC gets TRUE iff the token is a function or #define macro
+ *     *IS_FUNC gets TRUE if the token is a function or #define macro
  *     with args.  C_EXTP points to which language we are looking at.
  *
  * Globals
@@ -3397,17 +3428,15 @@ C_entries (c_ext, inf)
        case '/':
          if (*lp == '*')
            {
-             lp++;
              incomm = TRUE;
-             continue;
+             lp++;
+             c = ' ';
            }
          else if (/* cplpl && */ *lp == '/')
            {
              c = '\0';
-             break;
            }
-         else
-           break;
+         break;
        case '%':
          if ((c_ext & YACC) && *lp == '%')
            {
@@ -3970,10 +3999,16 @@ C_entries (c_ext, inf)
              bracelev = 0;     /* reset brace level if first column */
              parlev = 0;       /* also reset paren level, just in case... */
            }
-         else if (bracelev > 0)
-           bracelev--;
          else
-           token.valid = FALSE; /* something gone amiss, token unreliable */
+           {
+             if (--bracelev < 0)
+               {
+                 bracelev = 0;
+                 token.valid = FALSE; /* something gone amiss, token unreliable */
+               }
+             if (bracelev == 0 && fvdef == vignore)
+               fvdef = fvnone;         /* end of function */
+           }
          popclass_above (bracelev);
          structdef = snone;
          /* Only if typdef == tinbody is typdefbracelev significant. */
@@ -4768,7 +4803,7 @@ Pascal_functions (inf)
   int save_lineno, namelen, taglen;
   char c, *name;
 
-  bool                         /* each of these flags is TRUE iff: */
+  bool                         /* each of these flags is TRUE if: */
     incomment,                 /* point is inside a comment */
     inquote,                   /* point is inside '..' string */
     get_tagname,               /* point is after PROCEDURE/FUNCTION