]> code.delx.au - gnu-emacs/blobdiff - lib-src/etags.c
(decode_options): New function.
[gnu-emacs] / lib-src / etags.c
index 8463e01443e787ee10caa0969509ac910159a4f3..35e396c3be70b8fc387d2efd65e888873b65615f 100644 (file)
@@ -31,7 +31,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  *     Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
  */
 
-char pot_etags_version[] = "@(#) pot revision number is 11.59";
+char pot_etags_version[] = "@(#) pot revision number is 11.66";
 
 #define        TRUE    1
 #define        FALSE   0
@@ -50,6 +50,7 @@ char pot_etags_version[] = "@(#) pot revision number is 11.59";
 # include <stdlib.h>
 # include <fcntl.h>
 # include <string.h>
+# include <io.h>
 # define MAXPATHLEN _MAX_PATH
 #endif
 
@@ -215,9 +216,7 @@ char searchar = '/';                /* use /.../ searches */
 
 int lineno;                    /* line number of current line */
 long charno;                   /* current character number */
-
-long linecharno;               /* charno of start of line; not used by C,
-                                  but by every other language. */
+long linecharno;               /* charno of start of line */
 
 char *curfile;                 /* current input file name */
 char *tagfile;                 /* output file */
@@ -694,7 +693,7 @@ char *massage_name (s)
 #endif /* VMS */
 
 \f
-void
+int
 main (argc, argv)
      int argc;
      char *argv[];
@@ -857,8 +856,8 @@ main (argc, argv)
   if (tagfile == NULL)
     tagfile = CTAGS ? "tags" : "TAGS";
   cwd = etags_getcwd ();       /* the current working directory */
-  if (cwd[strlen(cwd)-1] != '/')
-    strcat (cwd, "/");
+  if (cwd[strlen (cwd) - 1] != '/')
+    cwd = concat (cwd, "/", "");
   if (streq (tagfile, "-"))
     tagfiledir = cwd;
   else
@@ -879,7 +878,7 @@ main (argc, argv)
          tagf = stdout;
 #ifdef DOS_NT
          /* Switch redirected `stdout' to binary mode (setting `_fmode'
-            doesn't take effect until after `stdout' is already open) */
+            doesn't take effect until after `stdout' is already open). */
          if (!isatty (fileno (stdout)))
            setmode (fileno (stdout), O_BINARY);
 #endif /* DOS_NT */
@@ -1070,15 +1069,11 @@ process_file (file)
   struct stat stat_buf;
   FILE *inf;
 #ifdef DOS_NT
-  /* The rest of the program can't grok `\\'-style slashes.  */
-  char *p = file;
+  char *p;
 
-  while (*p)
-    {
-      if (*p == '\\')
-       *p = '/';
-      ++p;
-    }
+  for (p = file; *p != '\0'; p++)
+    if (*p == '\\')
+      *p = '/';
 #endif
 
   if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
@@ -1503,7 +1498,7 @@ enum sym_type
 };
 
 /* Feed stuff between (but not including) %[ and %] lines to:
-      gperf -c -k1,3 -o -p -r -t
+      gperf -c -k 1,3 -o -p -r -t
 %[
 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
 %%
@@ -1512,12 +1507,14 @@ struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
 @implementation,0,     st_C_objimpl
 @end,          0,      st_C_objend
 class,         C_PLPL, st_C_struct
+namespace,     C_PLPL, st_C_struct
 domain,        C_STAR, st_C_struct
 union,         0,      st_C_struct
 struct,        0,      st_C_struct
 enum,          0,      st_C_enum
 typedef,       0,      st_C_typedef
 define,        0,      st_C_define
+bool,          C_PLPL, st_C_typespec
 long,          0,      st_C_typespec
 short,         0,      st_C_typespec
 int,           0,      st_C_typespec
@@ -1532,6 +1529,9 @@ extern,   0,      st_C_typespec
 static,        0,      st_C_typespec
 const,         0,      st_C_typespec
 volatile,      0,      st_C_typespec
+explicit,      C_PLPL, st_C_typespec
+mutable,       C_PLPL, st_C_typespec
+typename,      C_PLPL, st_C_typespec
 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
 DEFUN,         0,      st_C_gnumacro
 SYSCALL,       0,      st_C_gnumacro
@@ -1544,94 +1544,107 @@ PSEUDO,                0,      st_C_gnumacro
 %]
 and replace lines between %< and %> with its output. */
 /*%<*/
-/* C code produced by gperf version 1.8.1 (K&R C version) */
-/* Command-line: gperf -c -k1,3 -o -p -r -t  */
+/* C code produced by gperf version 2.1 (K&R C version) */
+/* Command-line: gperf -c -k 1,3 -o -p -r -t  */
 
 
 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
 
 #define MIN_WORD_LENGTH 3
 #define MAX_WORD_LENGTH 15
-#define MIN_HASH_VALUE 7
-#define MAX_HASH_VALUE 63
+#define MIN_HASH_VALUE 34
+#define MAX_HASH_VALUE 121
 /*
-   29 keywords
-   57 is the maximum key range
+   34 keywords
+   88 is the maximum key range
 */
 
 static int
 hash (str, len)
-     register char  *str;
-     register int  len;
+     register char *str;
+     register unsigned int  len;
 {
   static unsigned char hash_table[] =
     {
-     63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 17, 63, 63, 63,  4, 14,
-      4, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-      8, 63, 63,  0, 23, 63, 63, 63, 63, 63,
-     63, 63, 63, 63, 63, 63, 63, 28, 63, 28,
-     10, 31, 27, 18, 63,  6, 63, 63, 26,  1,
-     11,  2, 29, 63, 29, 16, 26, 13, 15, 63,
-     63, 63, 63, 63, 63, 63, 63, 63,
+     121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+     121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+     121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+     121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+     121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+     121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+     121, 121, 121, 121,  45, 121, 121, 121,  16,  19,
+      61, 121, 121, 121, 121, 121, 121, 121, 121, 121,
+      10, 121, 121,  20,  53, 121, 121, 121, 121, 121,
+     121, 121, 121, 121, 121, 121, 121,  41,  45,  22,
+      60,  47,  37,  28, 121,  55, 121, 121,  20,  14,
+      29,  30,   5, 121,  50,  59,  30,  54,   6, 121,
+     121, 121, 121, 121, 121, 121, 121, 121,
   };
   return len + hash_table[str[2]] + hash_table[str[0]];
 }
 
 struct C_stab_entry *
-in_word_set  (str, len)
+in_word_set (str, len)
      register char *str;
-     register int len;
+     register unsigned int len;
 {
 
   static struct C_stab_entry  wordlist[] =
     {
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"volatile",     0,      st_C_typespec},
+      {"PSEUDO",               0,      st_C_gnumacro},
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"typedef",      0,      st_C_typedef},
+      {"typename",     C_PLPL, st_C_typespec},
+      {"",}, {"",}, {"",}, 
       {"SYSCALL",      0,      st_C_gnumacro},
-      {"",}, {"",}, {"",}, {"",}, {"",},
-      {"DEFUN",                0,      st_C_gnumacro},
-      {"",}, {"",}, {"",},
-      {"domain",       C_STAR, st_C_struct},
-      {"",}, {"",}, {"",}, {"",}, {"",},
-      {"short",        0,      st_C_typespec},
-      {"union",        0,      st_C_struct},
+      {"",}, {"",}, {"",}, 
+      {"mutable",      C_PLPL, st_C_typespec},
+      {"namespace",    C_PLPL, st_C_struct},
+      {"long",         0,      st_C_typespec},
+      {"",}, {"",}, 
+      {"const",        0,      st_C_typespec},
+      {"",}, {"",}, {"",}, 
+      {"explicit",     C_PLPL, st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
       {"void",         0,      st_C_typespec},
-      {"",}, {"",},
-      {"PSEUDO",               0,      st_C_gnumacro},
-      {"double",       0,      st_C_typespec},
-      {"",}, {"",},
-      {"@end",                 0,      st_C_objend},
-      {"@implementation", 0,   st_C_objimpl},
+      {"",}, 
+      {"char",         0,      st_C_typespec},
+      {"class",        C_PLPL, st_C_struct},
+      {"",}, {"",}, {"",}, 
       {"float",        0,      st_C_typespec},
-      {"int",          0,      st_C_typespec},
-      {"",},
-      {"unsigned",     0,      st_C_typespec},
+      {"",}, 
+      {"@implementation", 0,   st_C_objimpl},
+      {"auto",         0,      st_C_typespec},
+      {"",}, 
+      {"ENTRY",                0,      st_C_gnumacro},
+      {"@end",                 0,      st_C_objend},
+      {"bool",                 C_PLPL, st_C_typespec},
+      {"domain",       C_STAR, st_C_struct},
+      {"",}, 
+      {"DEFUN",                0,      st_C_gnumacro},
+      {"extern",       0,      st_C_typespec},
       {"@interface",   0,      st_C_objprot},
-      {"",},
+      {"",}, {"",}, {"",}, 
+      {"int",          0,      st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
       {"signed",       0,      st_C_typespec},
-      {"long",         0,      st_C_typespec},
-      {"ENTRY",                0,      st_C_gnumacro},
+      {"short",        0,      st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
       {"define",       0,      st_C_define},
-      {"const",        0,      st_C_typespec},
-      {"",}, {"",}, {"",},
+      {"@protocol",    0,      st_C_objprot},
       {"enum",         0,      st_C_enum},
-      {"volatile",     0,      st_C_typespec},
       {"static",       0,      st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"union",        0,      st_C_struct},
       {"struct",       0,      st_C_struct},
-      {"",}, {"",}, {"",},
-      {"@protocol",    0,      st_C_objprot},
-      {"",}, {"",},
-      {"auto",         0,      st_C_typespec},
-      {"",},
-      {"char",         0,      st_C_typespec},
-      {"class",        C_PLPL, st_C_struct},
-      {"typedef",      0,      st_C_typedef},
-      {"extern",       0,      st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
+      {"double",       0,      st_C_typespec},
+      {"unsigned",     0,      st_C_typespec},
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -2055,6 +2068,7 @@ typedef struct
 do {                                                                   \
   curlinepos = charno;                                                 \
   lineno++;                                                            \
+  linecharno = charno;                                                 \
   charno += readline (&curlb, inf);                                    \
   lp = curlb.buffer;                                                   \
   quotednl = FALSE;                                                    \
@@ -2922,13 +2936,6 @@ Perl_functions (inf)
 /* Added by Mosur Mohan, 4/22/88 */
 /* Pascal parsing                */
 
-#define GET_NEW_LINE \
-{ \
-  linecharno = charno; lineno++; \
-  charno += 1 + readline (&lb, inf); \
-  dbp = lb.buffer; \
-}
-
 /*
  *  Locates tags for procedures & functions.  Doesn't do any type- or
  *  var-definitions.  It does look for the keyword "extern" or
@@ -2975,7 +2982,10 @@ Pascal_functions (inf)
       c = *dbp++;
       if (c == '\0')           /* if end of line */
        {
-         GET_NEW_LINE;
+         lineno++;
+         linecharno = charno;
+         charno += readline (&lb, inf);
+         dbp = lb.buffer;
          if (*dbp == '\0')
            continue;
          if (!((found_tag && verify_tag) ||
@@ -4095,7 +4105,16 @@ readline_internal (linebuffer, stream)
          if (p > buffer && p[-1] == '\r')
            {
              *--p = '\0';
+#ifdef DOS_NT
+             /* Assume CRLF->LF translation will be performed by Emacs
+                when loading this file, so CRs won't appear in the buffer.
+                It would be cleaner to compensate within Emacs;
+                however, Emacs does not know how many CRs were deleted
+                before any given point in the file.  */
+             chars_deleted = 1;
+#else
              chars_deleted = 2;
+#endif
            }
          else
            {
@@ -4313,21 +4332,18 @@ concat (s1, s2, s3)
 char *
 etags_getcwd ()
 {
-#ifdef DOS_NT
+#ifdef MSDOS
   char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS.  */
 
   getwd (path);
-  p = path;
-  while (*p)
-    {
-      if (*p == '\\')
-       *p++ = '/';
-      else
-       *p++ = lowcase (*p);
-    }
+  for (p = path; *p != '\0'; p++)
+    if (*p == '\\')
+      *p = '/';
+    else
+      *p = lowcase (*p);
 
   return strdup (path);
-#else /* not DOS_NT */
+#else /* not MSDOS */
 #if HAVE_GETCWD
   int bufsize = 200;
   char *path = xnew (bufsize, char);
@@ -4341,7 +4357,7 @@ etags_getcwd ()
     }
 
   return path;
-#else /* not DOS_NT and not HAVE_GETCWD */
+#else /* not MSDOS and not HAVE_GETCWD */
   struct linebuffer path;
   FILE *pipe;
 
@@ -4353,7 +4369,7 @@ etags_getcwd ()
 
   return path.buffer;
 #endif /* not HAVE_GETCWD */
-#endif /* not DOS_NT */
+#endif /* not MSDOS */
 }
 
 /* Return a newly allocated string containing the filename
@@ -4470,14 +4486,11 @@ absolute_dirname (file, cwd)
   char *slashp, *res;
   char save;
 #ifdef DOS_NT
-  char *p = file;
+  char *p;
 
-  while (*p)
-    {
-      if (*p == '\\')
-       *p = '/';
-      ++p;
-    }
+  for (p = file; *p != '\0'; p++)
+    if (*p == '\\')
+      *p = '/';
 #endif
 
   slashp = etags_strrchr (file, '/');