changeset 18042:c378dd0b8de7

Various cleanups on TeX, Erlang, Prolog, C. New function new_pfnote will be used for "optimised tags", but it depends on a constant that disables it for now. New possibility of tagging global variables in C/C++/ObjC/Java is enabled by default. Tags of member variables is disabled by default. Options --(no-)members and --(no-)globals control them. New symbol table entries for "import", "package" and "friend".
author Francesco Potortì <pot@gnu.org>
date Fri, 30 May 1997 14:53:42 +0000
parents 263f17563fa5
children c2d71b9b8f75
files lib-src/etags.c
diffstat 1 files changed, 585 insertions(+), 438 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/etags.c	Fri May 30 07:30:02 1997 +0000
+++ b/lib-src/etags.c	Fri May 30 14:53:42 1997 +0000
@@ -31,7 +31,7 @@
  *	Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
  */
 
-char pot_etags_version[] = "@(#) pot revision number is 11.91";
+char pot_etags_version[] = "@(#) pot revision number is 12.11";
 
 #define	TRUE	1
 #define	FALSE	0
@@ -40,10 +40,6 @@
 # define DEBUG FALSE
 #endif
 
-#ifndef TeX_named_tokens
-# define TeX_named_tokens FALSE
-#endif
-
 #ifdef MSDOS
 # include <string.h>
 # include <fcntl.h>
@@ -63,6 +59,8 @@
   /* On some systems, Emacs defines static as nothing for the sake
      of unexec.  We don't want that here since we don't use unexec. */
 # undef static
+# define ETAGS_REGEXPS
+# define LONG_OPTIONS
 #endif
 
 #if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS)
@@ -83,7 +81,13 @@
 # define S_ISREG(m)	(((m) & S_IFMT) == S_IFREG)
 #endif
 
-#include <getopt.h>
+#ifdef LONG_OPTIONS
+# include <getopt.h>
+#else
+# define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
+  extern char *optarg;
+  extern int optind, opterr;
+#endif /* LONG_OPTIONS */
 
 #ifdef ETAGS_REGEXPS
 # include <regex.h>
@@ -121,10 +125,13 @@
 
 #define lowcase(c)	tolower ((char)c)
 
-#define	iswhite(arg)	(_wht[arg])	/* T if char is white		*/
-#define	begtoken(arg)	(_btk[arg])	/* T if char can start token	*/
-#define	intoken(arg)	(_itk[arg])	/* T if char can be in token	*/
-#define	endtoken(arg)	(_etk[arg])	/* T if char ends tokens	*/
+#define CHARS 256		/* 2^sizeof(char) */
+#define CHAR(x)		((int)x & (CHARS - 1))
+#define	iswhite(c)	(_wht[CHAR(c)]) /* c is white */
+#define notinname(c)	(_nin[CHAR(c)]) /* c is not in a name */
+#define	begtoken(c)	(_btk[CHAR(c)]) /* c can start token */
+#define	intoken(c)	(_itk[CHAR(c)]) /* c can be in token */
+#define	endtoken(c)	(_etk[CHAR(c)]) /* c ends tokens */
 
 #ifdef DOS_NT
 # define absolutefn(fn) (fn[0] == '/' \
@@ -147,14 +154,14 @@
 # define xnew(n,Type)	((Type *) xmalloc ((n) * sizeof (Type)))
 #endif
 
-typedef int logical;
+typedef int bool;
 
 typedef struct nd_st
 {				/* sorting structure		*/
   char *name;			/* function or type name	*/
   char *file;			/* file name			*/
-  logical is_func;		/* use pattern or line no	*/
-  logical been_warned;		/* set if noticed dup		*/
+  bool is_func;			/* use pattern or line no	*/
+  bool been_warned;		/* set if noticed dup		*/
   int lno;			/* line number tag is on	*/
   long cno;			/* character number line starts on */
   char *pat;			/* search pattern		*/
@@ -172,30 +179,15 @@
 long *xmalloc (), *xrealloc ();
 
 typedef void Lang_function ();
-#if FALSE				/* many compilers barf on this */
-Lang_function Asm_labels;
-Lang_function default_C_entries;
-Lang_function C_entries;
-Lang_function Cplusplus_entries;
-Lang_function Cjava_entries;
-Lang_function Cstar_entries;
-Lang_function Erlang_functions;
-Lang_function Fortran_functions;
-Lang_function Yacc_entries;
-Lang_function Lisp_functions;
-Lang_function Pascal_functions;
-Lang_function Perl_functions;
-Lang_function Postscript_functions;
-Lang_function Prolog_functions;
-Lang_function Scheme_functions;
-Lang_function TeX_functions;
-Lang_function just_read_file;
-#else				/* so let's write it this way */
+/* Many compilers barf on this:
+	Lang_function Asm_labels;
+   so let's write it this way */
 void Asm_labels ();
 void C_entries ();
 void default_C_entries ();
 void plain_C_entries ();
 void Cjava_entries ();
+void Cobol_paragraphs ();
 void Cplusplus_entries ();
 void Cstar_entries ();
 void Erlang_functions ();
@@ -209,7 +201,6 @@
 void Scheme_functions ();
 void TeX_functions ();
 void just_read_file ();
-#endif
 
 Lang_function *get_language_from_name ();
 Lang_function *get_language_from_interpreter ();
@@ -220,7 +211,7 @@
 #ifdef ETAGS_REGEXPS
 void analyse_regex ();
 void add_regex ();
-#endif
+#endif /* ETAGS_REGEXPS */
 void add_node ();
 void error ();
 void suggest_asking_for_help ();
@@ -230,7 +221,7 @@
 void getit ();
 void init ();
 void initbuffer ();
-void pfnote ();
+void pfnote (), new_pfnote ();
 void process_file ();
 void put_entries ();
 void takeprec ();
@@ -274,57 +265,69 @@
 } lbs[2];
 
 /* boolean "functions" (see init)	*/
-logical _wht[0177], _etk[0177], _itk[0177], _btk[0177];
+bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
 char
   /* white chars */
   *white = " \f\t\n\013",
+  /* not in a name */
+  *nonam =" \f\t\n\013(=,[;",
   /* token ending chars */
   *endtk = " \t\n\013\"'#()[]{}=-+%*/&|^~!<>;,.:?",
   /* token starting chars */
   *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
   /* valid in-token chars */
-  *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
-
-logical append_to_tagfile;	/* -a: append to tags */
-/* The following three default to TRUE for etags, but to FALSE for ctags.  */
-logical typedefs;		/* -t: create tags for typedefs */
-logical typedefs_and_cplusplus;	/* -T: create tags for typedefs, level */
+  *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
+
+bool append_to_tagfile;		/* -a: append to tags */
+/* The following four default to TRUE for etags, but to FALSE for ctags.  */
+bool typedefs;			/* -t: create tags for C typedefs */
+bool typedefs_and_cplusplus;	/* -T: create tags for C typedefs, level */
 				/* 0 struct/enum/union decls, and C++ */
 				/* member functions. */
-logical constantypedefs;	/* -d: create tags for C #define and enum */
-				/* constants. */
+bool constantypedefs;		/* -d: create tags for C #define, enum */
+				/* constants and variables. */
 				/* -D: opposite of -d.  Default under ctags. */
-logical update;			/* -u: update tags */
-logical vgrind_style;		/* -v: create vgrind style index output */
-logical no_warnings;		/* -w: suppress warnings */
-logical cxref_style;		/* -x: create cxref style output */
-logical cplusplus;		/* .[hc] means C++, not C */
-logical noindentypedefs;	/* -I: ignore indentation in C */
-
+bool globals;			/* create tags for C global variables */
+bool members;			/* create tags for C member variables */
+bool update;			/* -u: update tags */
+bool vgrind_style;		/* -v: create vgrind style index output */
+bool no_warnings;		/* -w: suppress warnings */
+bool cxref_style;		/* -x: create cxref style output */
+bool cplusplus;			/* .[hc] means C++, not C */
+bool noindentypedefs;		/* -I: ignore indentation in C */
+
+#ifdef LONG_OPTIONS
 struct option longopts[] =
 {
-  { "append",			no_argument,	   NULL, 'a' },
-  { "backward-search",		no_argument,	   NULL, 'B' },
-  { "c++",			no_argument,	   NULL, 'C' },
-  { "cxref",			no_argument,	   NULL, 'x' },
-  { "defines",			no_argument,	   NULL, 'd' },
-  { "help",			no_argument,	   NULL, 'h' },
-  { "help",			no_argument,	   NULL, 'H' },
-  { "ignore-indentation",	no_argument,	   NULL, 'I' },
-  { "include",			required_argument, NULL, 'i' },
-  { "language",                 required_argument, NULL, 'l' },
-  { "no-defines",		no_argument,	   NULL, 'D' },
-  { "no-regex",			no_argument,	   NULL, 'R' },
-  { "no-warn",			no_argument,	   NULL, 'w' },
-  { "output",			required_argument, NULL, 'o' },
-  { "regex",			required_argument, NULL, 'r' },
-  { "typedefs",			no_argument,	   NULL, 't' },
-  { "typedefs-and-c++",		no_argument,	   NULL, 'T' },
-  { "update",			no_argument,	   NULL, 'u' },
-  { "version",			no_argument,	   NULL, 'V' },
-  { "vgrind",			no_argument,	   NULL, 'v' },
+  { "append",			no_argument,	   NULL,     'a'   },
+  { "backward-search",		no_argument,	   NULL,     'B'   },
+  { "c++",			no_argument,	   NULL,     'C'   },
+  { "cxref",			no_argument,	   NULL,     'x'   },
+  { "defines",			no_argument,	   NULL,     'd'   },
+  { "no-defines",		no_argument,	   NULL,     'D'   },
+  { "globals",			no_argument,	   &globals, TRUE  },
+  { "no-globals",		no_argument,	   &globals, FALSE },
+  { "help",			no_argument,	   NULL,     'h'   },
+  { "help",			no_argument,	   NULL,     'H'   },
+  { "ignore-indentation",	no_argument,	   NULL,     'I'   },
+  { "include",			required_argument, NULL,     'i'   },
+  { "language",                 required_argument, NULL,     'l'   },
+  { "members",			no_argument,	   &members, TRUE  },
+  { "no-members",		no_argument,	   &members, FALSE },
+  { "no-warn",			no_argument,	   NULL,     'w'   },
+  { "output",			required_argument, NULL,     'o'   },
+#ifdef ETAGS_REGEXPS  
+  { "regex",			required_argument, NULL,     'r'   },
+  { "no-regex",			no_argument,	   NULL,     'R'   },
+#endif /* ETAGS_REGEXPS */  
+  { "typedefs",			no_argument,	   NULL,     't'   },
+  { "typedefs-and-c++",		no_argument,	   NULL,     'T'   },
+  { "update",			no_argument,	   NULL,     'u'   },
+  { "version",			no_argument,	   NULL,     'V'   },
+  { "vgrind",			no_argument,	   NULL,     'v'   },
   { 0 }
 };
+#endif /* LONG_OPTIONS */
 
 #ifdef ETAGS_REGEXPS
 /* Structure defining a regular expression.  Elements are
@@ -334,7 +337,7 @@
   struct re_pattern_buffer *pattern;
   struct re_registers regs;
   char *name_pattern;
-  logical error_signaled;
+  bool error_signaled;
 };
 
 /* Number of regexps found. */
@@ -376,6 +379,9 @@
 char *Cjava_suffixes [] =
   { "java", NULL };
 
+char *Cobol_suffixes [] =
+  { "COB", "cob", NULL };
+
 char *Cstar_suffixes [] =
   { "cs", "hs", NULL };
 
@@ -436,6 +442,7 @@
   { "c",       default_C_entries,   default_C_suffixes,   NULL              },
   { "c++",     Cplusplus_entries,   Cplusplus_suffixes,   NULL              },
   { "c*",      Cstar_entries,       Cstar_suffixes,       NULL              },
+  { "cobol",   Cobol_paragraphs,    Cobol_suffixes,       NULL              },
   { "erlang",  Erlang_functions,    Erlang_suffixes,      NULL              },
   { "fortran", Fortran_functions,   Fortran_suffixes,     NULL              },
   { "java",    Cjava_entries,       Cjava_suffixes,       NULL              },
@@ -494,9 +501,16 @@
 void
 print_help ()
 {
-  printf ("These are the options accepted by %s.  You may use unambiguous\n\
-abbreviations for the long option names.  A - as file name means read\n\
-names from stdin.", progname);
+  printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
+\n\
+These are the options accepted by %s.\n", progname, progname);
+#ifdef LONG_OPTIONS
+  puts ("You may use unambiguous abbreviations for the long option names.");
+#else
+  puts ("Long option names do not work with this executable, as it is not\n\
+linked with GNU getopt.");
+#endif /* LONG_OPTIONS */
+  puts ("A - as file name means read names from stdin.");
   if (!CTAGS)
     printf ("  Absolute names are stored in the output file as they\n\
 are.  Relative ones are stored relative to the output file's directory.");
@@ -532,6 +546,16 @@
 	named language up to the next --language=LANG option.");
     }
 
+  if (CTAGS)
+    puts ("--globals\n\
+	Create tag entries for global variables in C and derived languages.");
+  else
+    puts ("--no-globals\n\
+	Do not create tag entries for global variables in C and\n\
+	derived languages.  This makes the tags file smaller.");
+  puts ("--members\n\
+	Create tag entries for member variables in C and derived languages.");
+
 #ifdef ETAGS_REGEXPS
   puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
         Make a tag for each line matching pattern REGEXP in the\n\
@@ -648,7 +672,7 @@
   static long context = 0;
   static struct dsc$descriptor_s o;
   static struct dsc$descriptor_s i;
-  static logical pass1 = TRUE;
+  static bool pass1 = TRUE;
   long status;
   short retval;
 
@@ -688,7 +712,7 @@
 char *
 gfnames (arg, p_error)
      char *arg;
-     logical *p_error;
+     bool *p_error;
 {
   static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
 
@@ -746,7 +770,7 @@
   int current_arg, file_count;
   struct linebuffer filename_lb;
 #ifdef VMS
-  logical got_err;
+  bool got_err;
 #endif
 
 #ifdef DOS_NT
@@ -770,16 +794,32 @@
 
   /*
    * If etags, always find typedefs and structure tags.  Why not?
-   * Also default is to find macro constants and enum constants.
+   * Also default is to find macro constants, enum constants and
+   * global variables. 
    */
   if (!CTAGS)
-    typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
+    {
+      typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
+      globals = TRUE;
+      members = FALSE;
+    }
 
   while (1)
     {
-      int opt = getopt_long (argc, argv,
-			     "-aCdDf:Il:o:r:RStTi:BuvxwVhH", longopts, 0);
-
+      int opt;
+      char *optstring;
+
+#ifdef ETAGS_REGEXPS
+      optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH";
+#else
+      optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
+#endif /* ETAGS_REGEXPS */
+
+#ifndef LONG_OPTIONS
+      optstring = optstring + 1;
+#endif /* LONG_OPTIONS */
+
+      opt = getopt_long (argc, argv, optstring, longopts, 0);
       if (opt == EOF)
 	break;
 
@@ -799,18 +839,10 @@
 	  break;
 
 	  /* Common options. */
-	case 'a':
-	  append_to_tagfile = TRUE;
-	  break;
-	case 'C':
-	  cplusplus = TRUE;
-	  break;
-	case 'd':
-	  constantypedefs = TRUE;
-	  break;
-	case 'D':
-	  constantypedefs = FALSE;
-	  break;
+	case 'a': append_to_tagfile = TRUE;	break;
+	case 'C': cplusplus = TRUE;		break;
+	case 'd': constantypedefs = TRUE;	break;
+	case 'D': constantypedefs = FALSE;	break;
 	case 'f':		/* for compatibility with old makefiles */
 	case 'o':
 	  if (tagfile)
@@ -861,21 +893,11 @@
 	  break;
 #else /* CTAGS */
 	  /* Ctags options. */
-	case 'B':
-	  searchar = '?';
-	  break;
-	case 'u':
-	  update = TRUE;
-	  break;
-	case 'v':
-	  vgrind_style = TRUE;
-	  /*FALLTHRU*/
-	case 'x':
-	  cxref_style = TRUE;
-	  break;
-	case 'w':
-	  no_warnings = TRUE;
-	  break;
+	case 'B': searchar = '?';	break;
+	case 'u': update = TRUE;	break;
+	case 'v': vgrind_style = TRUE;	/*FALLTHRU*/
+	case 'x': cxref_style = TRUE;	break;
+	case 'w': no_warnings = TRUE;	break;
 #endif /* CTAGS */
 	default:
 	  suggest_asking_for_help ();
@@ -892,7 +914,7 @@
 
   if (nincluded_files == 0 && file_count == 0)
     {
-      error ("%s", "No input files specified.");
+      error ("no input files specified.", 0);
       suggest_asking_for_help ();
     }
 
@@ -957,7 +979,7 @@
 	    {
 	      if (got_err)
 		{
-		  error ("Can't find file %s\n", this_file);
+		  error ("can't find file %s\n", this_file);
 		  argc--, argv++;
 		}
 	      else
@@ -1121,12 +1143,12 @@
 
   if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
     {
-      error ("Skipping %s: it is not a regular file.", file);
+      error ("skipping %s: it is not a regular file.", file);
       return;
     }
   if (streq (file, tagfile) && !streq (tagfile, "-"))
     {
-      error ("Skipping inclusion of %s in self.", file);
+      error ("skipping inclusion of %s in self.", file);
       return;
     }
   inf = fopen (file, "r");
@@ -1175,20 +1197,13 @@
   register char *sp;
   register int i;
 
-  for (i = 0; i < 0177; i++)
-    _wht[i] = _etk[i] = _itk[i] = _btk[i] = FALSE;
-  for (sp = white; *sp; sp++)
-    _wht[*sp] = TRUE;
-  for (sp = endtk; *sp; sp++)
-    _etk[*sp] = TRUE;
-  for (sp = intk; *sp; sp++)
-    _itk[*sp] = TRUE;
-  for (sp = begtk; *sp; sp++)
-    _btk[*sp] = TRUE;
-  _wht[0] = _wht['\n'];
-  _etk[0] = _etk['\n'];
-  _btk[0] = _btk['\n'];
-  _itk[0] = _itk['\n'];
+  for (i = 0; i < CHARS; i++)
+    _wht[i] = _nin[i] = _etk[i] = _itk[i] = _btk[i] = FALSE;
+  for (sp = white; *sp; sp++) _wht[*sp] = TRUE;    _wht[0] = _wht['\n'];
+  for (sp = nonam; *sp; sp++) _nin[*sp] = TRUE;    _nin[0] = _nin['\n'];
+  for (sp = endtk; *sp; sp++) _etk[*sp] = TRUE;    _etk[0] = _etk['\n'];
+  for (sp = midtk; *sp; sp++) _itk[*sp] = TRUE;    _btk[0] = _btk['\n'];
+  for (sp = begtk; *sp; sp++) _btk[*sp] = TRUE;    _itk[0] = _itk['\n'];
 }
 
 /*
@@ -1285,7 +1300,7 @@
 void
 pfnote (name, is_func, linestart, linelen, lno, cno)
      char *name;		/* tag name, or NULL if unnamed */
-     logical is_func;		/* tag is a function */
+     bool is_func;		/* tag is a function */
      char *linestart;		/* start of the line where tag is */
      int linelen;		/* length of the line where tag is */
      int lno;			/* line number */
@@ -1333,6 +1348,59 @@
   add_node (np, &head);
 }
 
+/* Date: Wed, 22 Jan 1997 02:56:31 -0500
+ * From: Sam Kendall <kendall@cybercom.net>
+ * Subject: Proposal for firming up the TAGS format specification
+ * To: F.Potorti@cnuce.cnr.it
+ *
+ * pfnote should emit the optimized form [unnamed tag] only if:
+ *  1. name does not contain any of the characters " \t\r\n()";
+ *  2. linestart contains name as either a rightmost, or rightmost but
+ *     one character, substring;
+ *  3. the character, if any, immediately before name in linestart must
+ *     be one of the characters " \t()";
+ *  4. the character, if any, immediately after name in linestart must
+ *     also be one of the characters " \t()".
+ */
+#define traditional_tag_style TRUE
+void
+new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
+     char *name;		/* tag name, or NULL if unnamed */
+     int namelen;		/* tag length */
+     bool is_func;		/* tag is a function */
+     char *linestart;		/* start of the line where tag is */
+     int linelen;		/* length of the line where tag is */
+     int lno;			/* line number */
+     long cno;			/* character number */
+{
+  register char *cp;
+  bool named;
+
+  named = TRUE;
+  if (!CTAGS)
+    {
+      for (cp = name; !notinname (*cp); cp++)
+	continue;
+      if (*cp == '\0')				/* rule #1 */
+	{
+	  cp = linestart + linelen - namelen;
+	  if (notinname (linestart[linelen-1]))
+	    cp -= 1;				/* rule #4 */
+	  if (cp >= linestart			/* rule #2 */
+	      && (cp == linestart
+		  || notinname (cp[-1]))	/* rule #3 */
+	      && strneq (name, cp, namelen))	/* rule #2 */
+	    named = FALSE;	/* use unnamed tag */
+	}
+    }
+  
+  if (named)
+    name = savenstr (name, namelen);
+  else
+    name = NULL;
+  pfnote (name, is_func, linestart, linelen, lno, cno);
+}
+
 /*
  * free_tree ()
  *	recurse on left children, iterate on right children.
@@ -1537,9 +1605,12 @@
  */
 enum sym_type
 {
-  st_none, st_C_objprot, st_C_objimpl, st_C_objend, st_C_gnumacro,
-  st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec,
-  st_C_javastruct
+  st_none,
+  st_C_objprot, st_C_objimpl, st_C_objend,
+  st_C_gnumacro,
+  st_C_ignore,
+  st_C_javastruct,
+  st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
 };
 
 /* Feed stuff between (but not including) %[ and %] lines to:
@@ -1551,6 +1622,9 @@
 @protocol,	0,	st_C_objprot
 @implementation,0,	st_C_objimpl
 @end,		0,	st_C_objend
+import,		C_JAVA,	st_C_ignore
+package,	C_JAVA,	st_C_ignore
+friend,		C_PLPL,	st_C_ignore
 extends,  	C_JAVA,	st_C_javastruct
 implements,  	C_JAVA,	st_C_javastruct
 class,  	C_PLPL,	st_C_struct
@@ -1591,6 +1665,7 @@
 %]
 and replace lines between %< and %> with its output. */
 /*%<*/
+/* starting time is 10:31:16 */
 /* C code produced by gperf version 2.1 (K&R C version) */
 /* Command-line: gperf -c -k 1,3 -o -p -r -t  */
 
@@ -1599,33 +1674,33 @@
 
 #define MIN_WORD_LENGTH 3
 #define MAX_WORD_LENGTH 15
-#define MIN_HASH_VALUE 33
-#define MAX_HASH_VALUE 126
+#define MIN_HASH_VALUE 15
+#define MAX_HASH_VALUE 128
 /*
-   36 keywords
-   94 is the maximum key range
+   39 keywords
+  114 is the maximum key range
 */
 
-int
+static int
 hash (str, len)
      register char *str;
      register unsigned int  len;
 {
   static unsigned char hash_table[] =
     {
-     126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-     126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-     126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-     126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-     126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-     126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-     126, 126, 126, 126,  15, 126, 126, 126,  53,  24,
-      41, 126, 126, 126, 126, 126, 126, 126, 126, 126,
-      51, 126, 126,  26,  47, 126, 126, 126, 126, 126,
-     126, 126, 126, 126, 126, 126, 126,  11,  36,  26,
-      35,  13,  22,  39, 126,  34, 126, 126,  43,  21,
-      36,   6,  49, 126,  47,  61,  28,  57,  35, 126,
-     126, 126, 126, 126, 126, 126, 126, 126,
+     128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+     128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+     128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+     128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+     128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+     128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+     128, 128, 128, 128,  39, 128, 128, 128,  54,  48,
+      46, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+      28, 128, 128,  40,  32, 128, 128, 128, 128, 128,
+     128, 128, 128, 128, 128, 128, 128,  24,  30,  47,
+      62,   7,  60,  27, 128,  60, 128, 128,  59,  16,
+      31,  23,  45, 128,   4,  14,   2,  55,   5, 128,
+     128, 128, 128, 128, 128, 128, 128, 128,
   };
   return len + hash_table[str[2]] + hash_table[str[0]];
 }
@@ -1639,64 +1714,71 @@
   static struct C_stab_entry  wordlist[] =
     {
       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"float",    	0,	st_C_typespec},
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"char",     	0,	st_C_typespec},
-      {"class",   	C_PLPL,	st_C_struct},
-      {"auto",     	0,	st_C_typespec},
-      {"",}, {"",}, 
-      {"bool", 		C_PLPL,	st_C_typespec},
       {"extern",   	0,	st_C_typespec},
       {"extends",   	C_JAVA,	st_C_javastruct},
-      {"",}, {"",}, 
-      {"@implementation", 0,	st_C_objimpl},
-      {"",}, {"",}, {"",}, 
-      {"@end", 		0,	st_C_objend},
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"struct",  	0,	st_C_struct},
       {"mutable", 	C_PLPL,	st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
+      {"auto",     	0,	st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
       {"",}, {"",}, 
-      {"SYSCALL", 	0,	st_C_gnumacro},
-      {"",}, 
-      {"@interface", 	0,	st_C_objprot},
-      {"domain",  	C_STAR,	st_C_struct},
-      {"define",   	0,	st_C_define},
-      {"",}, 
-      {"int",      	0,	st_C_typespec},
-      {"namespace", 	C_PLPL,	st_C_struct},
-      {"const",    	0,	st_C_typespec},
-      {"",}, {"",}, 
-      {"explicit", 	C_PLPL,	st_C_typespec},
-      {"@protocol", 	0,	st_C_objprot},
       {"short",    	0,	st_C_typespec},
-      {"void",     	0,	st_C_typespec},
-      {"enum",     	0,	st_C_enum},
-      {"",}, 
-      {"ENTRY", 		0,	st_C_gnumacro},
       {"",}, 
       {"static",   	0,	st_C_typespec},
       {"",}, {"",}, 
-      {"PSEUDO", 		0,	st_C_gnumacro},
+      {"signed",   	0,	st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
+      {"@protocol", 	0,	st_C_objprot},
       {"",}, 
-      {"long",     	0,	st_C_typespec},
       {"typedef",  	0,	st_C_typedef},
       {"typename", 	C_PLPL,	st_C_typespec},
-      {"volatile", 	0,	st_C_typespec},
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"implements",   	C_JAVA,	st_C_javastruct},
+      {"namespace", 	C_PLPL,	st_C_struct},
+      {"bool", 		C_PLPL,	st_C_typespec},
+      {"",}, {"",}, 
+      {"explicit", 	C_PLPL,	st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
+      {"int",      	0,	st_C_typespec},
+      {"enum",     	0,	st_C_enum},
       {"",}, {"",}, 
-      {"union",   	0,	st_C_struct},
+      {"void",     	0,	st_C_typespec},
+      {"@implementation", 0,	st_C_objimpl},
+      {"",}, 
+      {"volatile", 	0,	st_C_typespec},
+      {"",}, 
+      {"@end", 		0,	st_C_objend},
+      {"char",     	0,	st_C_typespec},
+      {"class",   	C_PLPL,	st_C_struct},
+      {"unsigned", 	0,	st_C_typespec},
+      {"",}, {"",}, 
+      {"@interface", 	0,	st_C_objprot},
       {"",}, 
-      {"double",   	0,	st_C_typespec},
+      {"PSEUDO", 		0,	st_C_gnumacro},
+      {"const",    	0,	st_C_typespec},
+      {"domain",  	C_STAR,	st_C_struct},
+      {"ENTRY", 		0,	st_C_gnumacro},
+      {"",}, 
+      {"SYSCALL", 	0,	st_C_gnumacro},
+      {"float",    	0,	st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"long",     	0,	st_C_typespec},
+      {"",}, {"",}, {"",}, {"",}, 
+      {"package", 	C_JAVA,	st_C_ignore},
+      {"",}, {"",}, {"",}, {"",}, {"",}, 
       {"DEFUN", 		0,	st_C_gnumacro},
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"signed",   	0,	st_C_typespec},
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
-      {"struct",  	0,	st_C_struct},
-      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"",}, {"",}, {"",}, {"",}, {"",}, 
+      {"import", 		C_JAVA,	st_C_ignore},
+      {"",}, {"",}, {"",}, 
+      {"implements",   	C_JAVA,	st_C_javastruct},
+      {"",}, {"",}, {"",}, {"",}, 
+      {"union",   	0,	st_C_struct},
       {"",}, {"",}, 
-      {"unsigned", 	0,	st_C_typespec},
+      {"double",   	0,	st_C_typespec},
+      {"",}, {"",}, 
+      {"friend", 		C_PLPL,	st_C_ignore},
+      {"",}, 
+      {"define",   	0,	st_C_define},
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -1713,6 +1795,7 @@
     }
   return 0;
 }
+/* ending time is 10:31:16 */
 /*%>*/
 
 enum sym_type
@@ -1729,18 +1812,19 @@
 }
 
  /*
-  * C functions are recognized using a simple finite automaton.
-  * funcdef is its state variable.
+  * C functions and variables are recognized using a simple
+  * finite automaton.  fvdef is its state variable.
   */
 enum
 {
-  fnone,			/* nothing seen */
-  ftagseen,			/* function-like tag seen */
-  fstartlist,			/* just after open parenthesis */
-  finlist,			/* in parameter list */
-  flistseen,			/* after parameter list */
-  fignore			/* before open brace */
-} funcdef;
+  fvnone,			/* nothing seen */
+  fvnameseen,			/* function or variable name seen */
+  fstartlist,			/* func: just after open parenthesis */
+  finlist,			/* func: in parameter list */
+  flistseen,			/* func: after parameter list */
+  fignore,			/* func: before open brace */
+  vignore			/* var-like: ignore until ';' */
+} fvdef;
 
 
  /*
@@ -1815,16 +1899,34 @@
   oignore			/* wait for @end */
 } objdef;
 
+
+/*
+ * Use this structure to keep info about the token read, and how it
+ * should be tagged.  Used by the make_C_tag function to build a tag.
+ */
+typedef struct
+{
+  bool valid;
+  char *str;
+  bool named;
+  int linelen;
+  int lineno;
+  long linepos;
+  char *buffer;
+} TOKEN;
+TOKEN tok;			/* latest token read */
+
+
 /*
  * Set this to TRUE, and the next token considered is called a function.
  * Used only for GNU emacs's function-defining macros.
  */
-logical next_token_is_func;
+bool next_token_is_func;
 
 /*
  * TRUE in the rules part of a yacc file, FALSE outside (parse as C).
  */
-logical yacc_rules;
+bool yacc_rules;
 
 /*
  * methodlen is the length of the method name stored in token_name.
@@ -1834,8 +1936,8 @@
 /*
  * consider_token ()
  *	checks to see if the current token is at the start of a
- *	function, or corresponds to a typedef, or is a struct/union/enum
- *	tag, or #define, or an enum constant.
+ *	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
  *	with args.  C_EXT is which language we are looking at.
@@ -1846,7 +1948,7 @@
  *	whatever follows `operator'.
  *
  * Globals
- *	funcdef			IN OUT
+ *	fvdef			IN OUT
  *	structdef		IN OUT
  *	definedef		IN OUT
  *	typdef			IN OUT
@@ -1854,15 +1956,15 @@
  *	next_token_is_func	IN OUT
  */
 
-logical
-consider_token (str, len, c, c_ext, cblev, parlev, is_func)
+bool
+consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var)
      register char *str;	/* IN: token pointer */
      register int len;		/* IN: token length */
      register char c;		/* IN: first char after the token */
      int c_ext;			/* IN: C extensions mask */
      int cblev;			/* IN: curly brace level */
      int parlev;		/* IN: parenthesis level */
-     logical *is_func;		/* OUT: function found */
+     bool *is_func_or_var;	/* OUT: function or variable found */
 {
   enum sym_type toktype = C_symtype (str, len, c_ext);
 
@@ -1890,8 +1992,8 @@
        * and constantypedefs is FALSE.
        */
       definedef = dignorerest;
-      *is_func = (c == '(');
-      if (!*is_func && !constantypedefs)
+      *is_func_or_var = (c == '(');
+      if (!*is_func_or_var && !constantypedefs)
 	return FALSE;
       else
 	return TRUE;
@@ -1911,7 +2013,7 @@
 	{
 	  if (typedefs)
 	    typdef = ttypedseen;
-	  funcdef = fnone;
+	  fvdef = fvnone;
 	  return FALSE;
 	}
       break;
@@ -1969,8 +2071,8 @@
 
   if (structdef == skeyseen)
     {
-      /* Save the tag for struct/union/class, for functions that may be
-         defined inside. */
+      /* Save the tag for struct/union/class, for functions and variables
+	 that may be defined inside. */
       if (structtype == st_C_struct)
 	structtag = savenstr (str, len);
       else
@@ -1979,7 +2081,7 @@
       return TRUE;
     }
 
-  /* Avoid entering funcdef stuff if typdef is going on. */
+  /* Avoid entering fvdef stuff if typdef is going on. */
   if (typdef != tnone)
     {
       definedef = dnone;
@@ -2008,8 +2110,8 @@
   if (next_token_is_func)
     {
       next_token_is_func = FALSE;
-      funcdef = fignore;
-      *is_func = TRUE;
+      fvdef = fignore;
+      *is_func_or_var = TRUE;
       return TRUE;
     }
 
@@ -2028,7 +2130,7 @@
 	}
       break;
     case oimplementation:
-      /* Save the class tag for functions that may be defined inside. */
+      /* Save the class tag for functions or variables defined inside. */
       objtag = savenstr (str, len);
       objdef = oinbody;
       return FALSE;
@@ -2036,11 +2138,11 @@
       /* Save the class tag for categories. */
       objtag = savenstr (str, len);
       objdef = otagseen;
-      *is_func = TRUE;
+      *is_func_or_var = TRUE;
       return TRUE;
     case oparenseen:
       objdef = ocatseen;
-      *is_func = TRUE;
+      *is_func_or_var = TRUE;
       return TRUE;
     case oinbody:
       break;
@@ -2049,9 +2151,10 @@
 	{
 	  objdef = omethodtag;
 	  methodlen = len;
-	  grow_linebuffer (&token_name, methodlen+1);
+	  grow_linebuffer (&token_name, methodlen + 1);
 	  strncpy (token_name.buffer, str, len);
 	  token_name.buffer[methodlen] = '\0';
+	  token_name.len = methodlen;
 	  return TRUE;
 	}
       return FALSE;
@@ -2064,8 +2167,9 @@
 	{
 	  objdef = omethodtag;
 	  methodlen += len;
-	  grow_linebuffer (&token_name, methodlen+1);
+	  grow_linebuffer (&token_name, methodlen + 1);
 	  strncat (token_name.buffer, str, len);
+	  token_name.len = methodlen;
 	  return TRUE;
 	}
       return FALSE;
@@ -2083,20 +2187,23 @@
       return FALSE;
     }
 
-  /* A function or enum constant? */
+  /* A function, variable or enum constant? */
   switch (toktype)
     {
     case st_C_typespec:
-      if (funcdef != finlist && funcdef != fignore)
-        funcdef = fnone;		/* should be useless */
+      if (fvdef != finlist && fvdef != fignore  && fvdef != vignore)
+        fvdef = fvnone;		/* should be useless */
+      return FALSE;
+    case st_C_ignore:
+      fvdef = vignore;
       return FALSE;
     case st_none:
       if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
 	return TRUE;
-      if (funcdef == fnone)
+      if (fvdef == fvnone)
 	{
-	  funcdef = ftagseen;
-	  *is_func = TRUE;
+	  fvdef = fvnameseen;	/* function or variable */
+	  *is_func_or_var = TRUE;
 	  return TRUE;
 	}
     }
@@ -2106,21 +2213,10 @@
 
 /*
  * C_entries ()
- *	This routine finds functions, typedefs, #define's, enum
- * 	constants and struct/union/enum definitions in C syntax
- *	and adds them to the list.
+ *	This routine finds functions, variables, typedefs,
+ * 	#define's, enum constants and struct/union/enum definitions in
+ * 	#C syntax and adds them to the list.
  */
-typedef struct
-{
-  logical valid;
-  char *str;
-  logical named;
-  int linelen;
-  int lineno;
-  long linepos;
-  char *buffer;
-} TOKEN;
-
 #define current_lb_is_new (newndx == curndx)
 #define switch_line_buffers() (curndx = 1 - curndx)
 
@@ -2155,21 +2251,28 @@
 
 
 void
-make_C_tag (isfun, tokp)
-     logical isfun;
-     TOKEN *tokp;
+make_C_tag (isfun)
+     bool isfun;
 {
-  char *name = NULL;
-
   /* This function should never be called when tok.valid is FALSE, but
      we must protect against invalid input or internal errors. */
-  if (tokp->valid)
+  if (tok.valid)
     {
-      if (CTAGS || tokp->named)
-	name = savestr (token_name.buffer);
-      pfnote (name, isfun,
-	      tokp->buffer, tokp->linelen, tokp->lineno, tokp->linepos);
-      tokp->valid = FALSE;
+      if (traditional_tag_style)
+	{
+	  /* This was the original code.  Now we call new_pfnote instead,
+	     which uses the new method for naming tags (see new_pfnote). */
+	  char *name = NULL;
+
+	  if (CTAGS || tok.named)
+	    name = savestr (token_name.buffer);
+	  pfnote (name, isfun,
+		  tok.buffer, tok.linelen, tok.lineno, tok.linepos);
+	}
+      else
+	new_pfnote (token_name.buffer, token_name.len, isfun,
+		    tok.buffer, tok.linelen, tok.lineno, tok.linepos);
+      tok.valid = FALSE;
     }
   else if (DEBUG)
     abort ();
@@ -2184,13 +2287,14 @@
   register char c;		/* latest char read; '\0' for end of line */
   register char *lp;		/* pointer one beyond the character `c' */
   int curndx, newndx;		/* indices for current and new lb */
-  TOKEN tok;			/* latest token read */
   register int tokoff;		/* offset in line of start of current token */
   register int toklen;		/* length of current token */
+  char *qualifier;		/* string used to qualify names */
+  int qlen;			/* length of qualifier */
   int cblev;			/* current curly brace level */
   int parlev;			/* current parenthesis level */
-  logical incomm, inquote, inchar, quotednl, midtoken;
-  logical cplpl, cjava;
+  bool incomm, inquote, inchar, quotednl, midtoken;
+  bool cplpl, cjava;
   TOKEN savetok;		/* token saved during preprocessor handling */
 
 
@@ -2200,15 +2304,19 @@
   lp = curlb.buffer;
   *lp = 0;
 
-  funcdef = fnone; typdef = tnone; structdef = snone;
+  fvdef = fvnone; typdef = tnone; structdef = snone;
   definedef = dnone; objdef = onone;
   next_token_is_func = yacc_rules = FALSE;
   midtoken = inquote = inchar = incomm = quotednl = FALSE;
   tok.valid = savetok.valid = FALSE;
   cblev = 0;
   parlev = 0;
-  cplpl = c_ext & C_PLPL;
-  cjava = c_ext & C_JAVA;
+  cplpl = (c_ext & C_PLPL) == C_PLPL;
+  cjava = (c_ext & C_JAVA) == C_JAVA;
+  if (cjava)
+    { qualifier = "."; qlen = 1; }
+  else
+    { qualifier = "::"; qlen = 2; }
 
   while (!feof (inf))
     {
@@ -2280,13 +2388,13 @@
 	  {
 	  case '"':
 	    inquote = TRUE;
-	    if (funcdef != finlist && funcdef != fignore)
-	      funcdef = fnone;
+	    if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
+	      fvdef = fvnone;
 	    continue;
 	  case '\'':
 	    inchar = TRUE;
-	    if (funcdef != finlist && funcdef != fignore)
-	      funcdef = fnone;
+	    if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
+	      fvdef = fvnone;
 	    continue;
 	  case '/':
 	    if (*lp == '*')
@@ -2307,7 +2415,7 @@
 	      {
 		/* entering or exiting rules section in yacc file */
 		lp++;
-		definedef = dnone; funcdef = fnone;
+		definedef = dnone; fvdef = fvnone;
 		typdef = tnone; structdef = snone;
 		next_token_is_func = FALSE;
 		midtoken = inquote = inchar = incomm = quotednl = FALSE;
@@ -2321,7 +2429,7 @@
 	    if (definedef == dnone)
 	      {
 		char *cp;
-		logical cpptoken = TRUE;
+		bool cpptoken = TRUE;
 
 		/* Look back on this line.  If all blanks, or nonblanks
 		   followed by an end of comment, this is a preprocessor
@@ -2352,7 +2460,7 @@
 	   || (structdef == sinbody && structtype == st_C_enum))
 	  && typdef != tignore
 	  && definedef != dignorerest
-	  && funcdef != finlist)
+	  && fvdef != finlist)
 	{
 	  if (midtoken)
 	    {
@@ -2369,35 +2477,38 @@
 		    }
 		  else
 		    {
-		      logical is_func = FALSE;
+		      bool funorvar = FALSE;
 
 		      if (yacc_rules
 			  || consider_token (newlb.buffer + tokoff, toklen, c,
-					     c_ext, cblev, parlev, &is_func))
+					     c_ext, cblev, parlev, &funorvar))
 			{
+			  tok.named = FALSE;
 			  if (structdef == sinbody
 			      && definedef == dnone
-			      && is_func)
-			    /* function defined in C++ class body */
+			      && funorvar)
+			    /* function or var defined in C++ class body */
 			    {
-			      grow_linebuffer (&token_name,
-					       strlen(structtag)+2+toklen+1);
+			      int len = strlen (structtag) + qlen + toklen;
+			      grow_linebuffer (&token_name, len + 1);
 			      strcpy (token_name.buffer, structtag);
-			      strcat (token_name.buffer, "::");
+			      strcat (token_name.buffer, qualifier);
 			      strncat (token_name.buffer,
-				       newlb.buffer+tokoff, toklen);
+				       newlb.buffer + tokoff, toklen);
+			      token_name.len = len;
 			      tok.named = TRUE;
 			    }
 			  else if (objdef == ocatseen)
 			    /* Objective C category */
 			    {
-			      grow_linebuffer (&token_name,
-					       strlen(objtag)+2+toklen+1);
+			      int len = strlen (objtag) + 2 + toklen;
+			      grow_linebuffer (&token_name, len + 1);
 			      strcpy (token_name.buffer, objtag);
 			      strcat (token_name.buffer, "(");
 			      strncat (token_name.buffer,
-				       newlb.buffer+tokoff, toklen);
+				       newlb.buffer + tokoff, toklen);
 			      strcat (token_name.buffer, ")");
+			      token_name.len = len;
 			      tok.named = TRUE;
 			    }
 			  else if (objdef == omethodtag
@@ -2408,17 +2519,16 @@
 			    }
 			  else
 			    {
-			      grow_linebuffer (&token_name, toklen+1);
+			      grow_linebuffer (&token_name, toklen + 1);
 			      strncpy (token_name.buffer,
-				       newlb.buffer+tokoff, toklen);
+				       newlb.buffer + tokoff, toklen);
 			      token_name.buffer[toklen] = '\0';
-			      if (structdef == stagseen
-				  || typdef == tend
-				  || (is_func
-				      && definedef == dignorerest)) /* macro */
-				tok.named = TRUE;
-			      else
-				tok.named = FALSE;
+			      token_name.len = toklen;
+			      /* Name macros. */
+			      tok.named = (structdef == stagseen
+					   || typdef == tend
+					   || (funorvar
+					       && definedef == dignorerest));
 			    }
 			  tok.lineno = lineno;
 			  tok.linelen = tokoff + toklen + 1;
@@ -2427,7 +2537,7 @@
 			  tok.valid = TRUE;
 
 			  if (definedef == dnone
-			      && (funcdef == ftagseen
+			      && (fvdef == fvnameseen
 				  || structdef == stagseen
 				  || typdef == tend
 				  || objdef != onone))
@@ -2436,7 +2546,7 @@
 				switch_line_buffers ();
 			    }
 			  else
-			    make_C_tag (is_func, &tok);
+			    make_C_tag (funorvar);
 			}
 		      midtoken = FALSE;
 		    }
@@ -2452,17 +2562,17 @@
 	      switch (definedef)
 		{
 		case dnone:
-		  switch (funcdef)
+		  switch (fvdef)
 		    {
 		    case fstartlist:
-		      funcdef = finlist;
+		      fvdef = finlist;
 		      continue;
 		    case flistseen:
-		      make_C_tag (TRUE, &tok);
-		      funcdef = fignore;
+		      make_C_tag (TRUE); /* a function */
+		      fvdef = fignore;
 		      break;
-		    case ftagseen:
-		      funcdef = fnone;
+		    case fvnameseen:
+		      fvdef = fvnone;
 		      break;
 		    }
 		  if (structdef == stagseen && !cjava)
@@ -2493,30 +2603,31 @@
 	    {
 	    case  otagseen:
 	      objdef = oignore;
-	      make_C_tag (TRUE, &tok);
+	      make_C_tag (TRUE); /* an Objective C class */
 	      break;
 	    case omethodtag:
 	    case omethodparm:
 	      objdef = omethodcolon;
 	      methodlen += 1;
-	      grow_linebuffer (&token_name, methodlen+1);
+	      grow_linebuffer (&token_name, methodlen + 1);
 	      strcat (token_name.buffer, ":");
+	      token_name.len = methodlen;
 	      break;
 	    }
 	  if (structdef == stagseen)
 	    structdef = scolonseen;
 	  else
-	    switch (funcdef)
+	    switch (fvdef)
 	      {
-	      case ftagseen:
+	      case fvnameseen:
 		if (yacc_rules)
 		  {
-		    make_C_tag (FALSE, &tok);
-		    funcdef = fignore;
+		    make_C_tag (FALSE); /* a yacc function */
+		    fvdef = fignore;
 		  }
 		break;
 	      case fstartlist:
-		funcdef = fnone;
+		fvdef = fvnone;
 		break;
 	      }
 	  break;
@@ -2527,14 +2638,21 @@
 	    switch (typdef)
 	      {
 	      case tend:
-		make_C_tag (FALSE, &tok);
+		make_C_tag (FALSE); /* a typedef */
 		/* FALLTHRU */
 	      default:
 		typdef = tnone;
 	      }
-	  if (funcdef != fignore)
+	  switch (fvdef)
 	    {
-	      funcdef = fnone;
+	    case fignore:
+	      break;
+	    case fvnameseen:
+	      if ((globals && cblev == 0) || (members && cblev == 1))
+		make_C_tag (FALSE); /* a variable */
+	      /* FALLTHRU */
+	    default:
+	      fvdef = fvnone;
 	      /* The following instruction invalidates the token.
 		 Probably the token should be invalidated in all
 		 other cases  where some state machine is reset. */
@@ -2550,12 +2668,23 @@
 	    {
 	    case omethodtag:
 	    case omethodparm:
-	      make_C_tag (TRUE, &tok);
+	      make_C_tag (TRUE); /* an Objective C method */
 	      objdef = oinbody;
 	      break;
 	    }
-	  if (funcdef != finlist && funcdef != fignore)
-	    funcdef = fnone;
+	  switch (fvdef)
+	    {
+	    case finlist:
+	    case fignore:
+	    case vignore:
+	      break;
+	    case fvnameseen:
+	      if ((globals && cblev == 0) || (members && cblev == 1))
+		make_C_tag (FALSE); /* a variable */
+	      break;
+	    default:
+	      fvdef = fvnone;
+	    }
 	  if (structdef == stagseen)
 	    structdef = snone;
 	  break;
@@ -2565,11 +2694,22 @@
 	  if (cblev == 0 && typdef == tend)
 	    {
 	      typdef = tignore;
-	      make_C_tag (FALSE, &tok);
+	      make_C_tag (FALSE);	/* a typedef */
 	      break;
 	    }
-	  if (funcdef != finlist && funcdef != fignore)
-	    funcdef = fnone;
+	  switch (fvdef)
+	    {
+	    case finlist:
+	    case fignore:
+	    case vignore:
+	      break;
+	    case fvnameseen:
+	      if ((globals && cblev == 0) || (members && cblev == 1))
+		make_C_tag (FALSE); /* a variable */
+	      /* FALLTHRU */
+	    default:
+	      fvdef = fvnone;
+	    }
 	  if (structdef == stagseen)
 	    structdef = snone;
 	  break;
@@ -2578,29 +2718,28 @@
 	    break;
 	  if (objdef == otagseen && parlev == 0)
 	    objdef = oparenseen;
-	  switch (funcdef)
+	  switch (fvdef)
 	    {
-	    case fnone:
+	    case fvnone:
 	      switch (typdef)
 		{
 		case ttypedseen:
 		case tend:
-		  /* Make sure that the next char is not a '*'.
-		     This handles constructs like:
-		     typedef void OperatorFun (int fun); */
 		  if (tok.valid && *lp != '*')
 		    {
+		      /* This handles constructs like:
+			 typedef void OperatorFun (int fun); */
+		      make_C_tag (FALSE);
 		      typdef = tignore;
-		      make_C_tag (FALSE, &tok);
 		    }
 		  break;
 		} /* switch (typdef) */
 	      break;
-	    case ftagseen:
-	      funcdef = fstartlist;
+	    case fvnameseen:
+	      fvdef = fstartlist;
 	      break;
 	    case flistseen:
-	      funcdef = finlist;
+	      fvdef = finlist;
 	      break;
 	    }
 	  parlev++;
@@ -2610,22 +2749,22 @@
 	    break;
 	  if (objdef == ocatseen && parlev == 1)
 	    {
-	      make_C_tag (TRUE, &tok);
+	      make_C_tag (TRUE); /* an Objective C category */
 	      objdef = oignore;
 	    }
 	  if (--parlev == 0)
 	    {
-	      switch (funcdef)
+	      switch (fvdef)
 		{
 		case fstartlist:
 		case finlist:
-		  funcdef = flistseen;
+		  fvdef = flistseen;
 		  break;
 		}
 	      if (cblev == 0 && typdef == tend)
 		{
 		  typdef = tignore;
-		  make_C_tag (FALSE, &tok);
+		  make_C_tag (FALSE); /* a typedef */
 		}
 	    }
 	  else if (parlev < 0)	/* can happen due to ill-conceived #if's. */
@@ -2645,27 +2784,27 @@
 	    case stagseen:
 	    case scolonseen:	/* named struct */
 	      structdef = sinbody;
-	      make_C_tag (FALSE, &tok);
+	      make_C_tag (FALSE);	/* a struct */
 	      break;
 	    }
-	  switch (funcdef)
+	  switch (fvdef)
 	    {
 	    case flistseen:
-	      make_C_tag (TRUE, &tok);
+	      make_C_tag (TRUE); /* a function */
 	      /* FALLTHRU */
 	    case fignore:
-	      funcdef = fnone;
+	      fvdef = fvnone;
 	      break;
-	    case fnone:
+	    case fvnone:
 	      switch (objdef)
 		{
 		case otagseen:
-		  make_C_tag (TRUE, &tok);
+		  make_C_tag (TRUE); /* an Objective C class */
 		  objdef = oignore;
 		  break;
 		case omethodtag:
 		case omethodparm:
-		  make_C_tag (TRUE, &tok);
+		  make_C_tag (TRUE); /* an Objective C method */
 		  objdef = oinbody;
 		  break;
 		default:
@@ -2679,8 +2818,8 @@
 	case '*':
 	  if (definedef != dnone)
 	    break;
-	  if (funcdef == fstartlist)
-	    funcdef = fnone;	/* avoid tagging `foo' in `foo (*bar()) ()' */
+	  if (fvdef == fstartlist)
+	    fvdef = fvnone;	/* avoid tagging `foo' in `foo (*bar()) ()' */
 	  break;
 	case '}':
 	  if (definedef != dnone)
@@ -2708,6 +2847,23 @@
 	      structtag = "<error>";
 	    }
 	  break;
+	case '=':
+	  if (definedef != dnone)
+	    break;
+	  switch (fvdef)
+	    {
+	    case finlist:
+	    case fignore:
+	    case vignore:
+	      break;
+	    case fvnameseen:
+	      if ((globals && cblev == 0) || (members && cblev == 1))
+		make_C_tag (FALSE); /* a variable */
+	      /* FALLTHRU */
+	    default:
+	      fvdef = vignore;
+	    }
+	  break;
 	case '+':
 	case '-':
 	  if (objdef == oinbody && cblev == 0)
@@ -2716,18 +2872,18 @@
 	      break;
 	    }
 	  /* FALLTHRU */
-	case '=': case '#': case '~': case '&': case '%': case '/':
-	case '|': case '^': case '!': case '<': case '>': case '.': case '?':
+	case '#': case '~': case '&': case '%': case '/': case '|':
+	case '^': case '!': case '<': case '>': case '.': case '?': case ']':
 	  if (definedef != dnone)
 	    break;
 	  /* These surely cannot follow a function tag. */
-	  if (funcdef != finlist && funcdef != fignore)
-	    funcdef = fnone;
+	  if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
+	    fvdef = fvnone;
 	  break;
 	case '\0':
 	  if (objdef == otagseen)
 	    {
-	      make_C_tag (TRUE, &tok);
+	      make_C_tag (TRUE); /* an Objective C class */
 	      objdef = oignore;
 	    }
 	  /* If a macro spans multiple lines don't reset its state. */
@@ -2770,7 +2926,8 @@
 
 /* Always do Java. */
 void
-Cjava_entries (FILE *inf)
+Cjava_entries (inf)
+     FILE *inf;
 {
   C_entries (C_JAVA, inf);
 }
@@ -2795,7 +2952,7 @@
 
 char *dbp;
 
-logical
+bool
 tail (cp)
      char *cp;
 {
@@ -3009,11 +3166,11 @@
       charno += readline (&lb, inf);
       cp = lb.buffer;
 
-      if (*cp++ == 's' && *cp++ == 'u' && *cp++ == 'b' && isspace(*cp++))
+      if (*cp++ == 's' && *cp++ == 'u' && *cp++ == 'b' && isspace (*cp++))
 	{
-	  while (*cp && isspace(*cp))
+	  while (*cp && isspace (*cp))
 	    cp++;
-	  while (*cp && ! isspace(*cp) && *cp != '{')
+	  while (*cp && ! isspace (*cp) && *cp != '{')
 	    cp++;
 	  pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : NULL, TRUE,
 		  lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
@@ -3021,6 +3178,42 @@
     }
 }
 
+/* Idea by Corny de Souza
+ * Cobol tag functions
+ * We could look for anything that could be a paragraph name.
+ * i.e. anything that starts in column 8 is one word and ends in a full stop.
+ */
+void
+Cobol_paragraphs (inf)
+     FILE *inf;
+{
+  register char *cp;
+
+  lineno = 0;
+  charno = 0;
+
+  while (!feof (inf))
+    {
+      lineno++;
+      linecharno = charno;
+      charno += readline (&lb, inf);
+
+      if (lb.len < 9)
+	continue;
+      dbp = lb.buffer + 8;
+
+      /* If eoln, compiler option or comment ignore whole line. */
+      if (dbp[-1] != ' ' || !isalnum (dbp[0]))
+        continue;
+
+      for (cp = dbp; isalnum (*cp) || *cp == '-'; cp++)
+	continue;
+      if (*cp++ == '.')
+	pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
+		lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
+    }
+}
+
 /* Added by Mosur Mohan, 4/22/88 */
 /* Pascal parsing                */
 
@@ -3039,7 +3232,7 @@
   int save_lineno, save_len;
   char c, *cp, *namebuf;
 
-  logical			/* each of these flags is TRUE iff: */
+  bool				/* each of these flags is TRUE iff: */
     incomment,			/* point is inside a comment */
     inquote,			/* point is inside '..' string */
     get_tagname,		/* point is after PROCEDURE/FUNCTION
@@ -3171,7 +3364,7 @@
 	  save_lcno = linecharno;
 
 	  /* grab block name */
-	  for (cp = dbp + 1; *cp && (!endtoken (*cp)); cp++)
+	  for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
 	    continue;
 	  namebuf = (CTAGS) ? savenstr (dbp, cp-dbp) : NULL;
 	  dbp = cp;		/* set dbp to e-o-token */
@@ -3224,7 +3417,7 @@
 	  && (*(++strp) == 'o' || *strp == 'O')
 	  && (*(++strp) == 't' || *strp == 'T')
 	  && (*(++strp) == 'e' || *strp == 'E')
-	  && isspace(*(++strp)));
+	  && isspace (*(++strp)));
 }
 
 void
@@ -3237,11 +3430,11 @@
   else if (*dbp == '(' && L_isquote (dbp)) /* Skip "(quote " */
   {
     dbp += 7;
-    while (isspace(*dbp))
+    while (isspace (*dbp))
       dbp++;
   }
   for (cp = dbp /*+1*/;
-       *cp && *cp != '(' && *cp != ' ' && *cp != ')';
+       *cp != '\0' && *cp != '(' && *cp != ' ' && *cp != ')';
        cp++)
     continue;
   if (cp == dbp)
@@ -3312,6 +3505,7 @@
 {
   lineno = 0;
   charno = 0;
+
   while (!feof (inf))
     {
       lineno++;
@@ -3423,7 +3617,6 @@
 void TEX_mode ();
 struct TEX_tabent *TEX_decode_env ();
 int TEX_Token ();
-static void TEX_getit ();
 
 char TEX_esc = '\\';
 char TEX_opgrp = '{';
@@ -3437,6 +3630,7 @@
      FILE *inf;
 {
   char *lasthit;
+  register int i;
 
   lineno = 0;
   charno = 0;
@@ -3457,20 +3651,22 @@
       lasthit = dbp;
       while (dbp = etags_strchr (dbp, TEX_esc))	/* Look at each esc in line */
 	{
-	  register int i;
-
 	  if (!*(++dbp))
 	    break;
 	  linecharno += dbp - lasthit;
 	  lasthit = dbp;
 	  i = TEX_Token (lasthit);
-	  if (0 <= i)
+	  if (i >= 0)
 	    {
-	      pfnote ((char *)NULL, TRUE,
+	      /* We seem to include the TeX command in the tag name.
+	      register char *p;
+	      for (p = lasthit + TEX_toktab[i].len;
+		   *p != '\0' && *p != TEX_clgrp;
+		   p++)
+		continue; */
+	      pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
 		      lb.buffer, lb.len, lineno, linecharno);
-	      if (TeX_named_tokens)
-		TEX_getit (lasthit, TEX_toktab[i].len);
-	      break;		/* We only save a line once */
+	      break;		/* We only tag a line once */
 	    }
 	}
     }
@@ -3568,26 +3764,6 @@
   return tab;
 }
 
-/* Record a tag defined by a TeX command of length LEN and starting at NAME.
-   The name being defined actually starts at (NAME + LEN + 1).
-   But we seem to include the TeX command in the tag name.  */
-static void
-TEX_getit (name, len)
-     char *name;
-     int len;
-{
-  char *p = name + len;
-
-  if (*name == '\0')
-    return;
-
-  /* Let tag name extend to next group close (or end of line) */
-  while (*p && *p != TEX_clgrp)
-    p++;
-  pfnote (savenstr (name, p-name), TRUE,
-	  lb.buffer, lb.len, lineno, linecharno);
-}
-
 /* If the text at CP matches one of the tag-defining TeX command names,
    return the pointer to the first occurrence of that command in TEX_toktab.
    Otherwise return -1.
@@ -3611,13 +3787,15 @@
  * Assumes that the predicate starts at column 0.
  * Only the first clause of a predicate is added. 
  */
+int prolog_pred ();
+void prolog_skip_comment ();
+int prolog_atom ();
+int eat_white ();
+
 void
 Prolog_functions (inf)
      FILE *inf;
 {
-  int prolog_pred ();
-  void prolog_skip_comment ();
-
   char * last;
   int len;
   int allocated;
@@ -3691,18 +3869,15 @@
      char *s;
      char *last;		/* Name of last clause. */
 {
-  int prolog_atom();
-  int prolog_white();
-
   int pos;
   int len;
 
-  pos = prolog_atom(s, 0);
+  pos = prolog_atom (s, 0);
   if (pos < 1)
     return 0;
 
   len = pos;
-  pos += prolog_white(s, pos);
+  pos += eat_white (s, pos);
 
   if ((s[pos] == '(') || (s[pos] == '.'))
     {
@@ -3710,9 +3885,9 @@
 	pos++;
 
       /* Save only the first clause. */
-      if ((last == NULL) ||
-	  (len != strlen(last)) ||
-	  (strncmp(s, last, len) != 0))
+      if (last == NULL
+	  || len != strlen (last)
+	  || !strneq (s, last, len))
 	{
 	  pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
 		  s, pos, lineno, linecharno);
@@ -3783,15 +3958,15 @@
 
 /* Consume whitespace.  Return the number of bytes eaten. */
 int
-prolog_white (s, pos)
+eat_white (s, pos)
      char *s;
      int pos;
 {
-  int origpos;
+  int origpos = pos;
 
   origpos = pos;
 
-  while (isspace(s[pos]))
+  while (isspace (s[pos]))
     pos++;
 
   return pos - origpos;
@@ -3804,13 +3979,14 @@
  *
  * Assumes that Erlang functions start at column 0.
  */
+int erlang_func ();
+void erlang_attribute ();
+int erlang_atom ();
+
 void
 Erlang_functions (inf)
      FILE *inf;
 {
-  int erlang_func ();
-  void erlang_attribute ();
-
   char * last;
   int len;
   int allocated;
@@ -3839,7 +4015,7 @@
 	continue;
       else if (dbp[0] == '-') 	/* attribute, e.g. "-define" */
 	{
-	  erlang_attribute(dbp);
+	  erlang_attribute (dbp);
 	  last = NULL;
 	}
       else if (len = erlang_func (dbp, last)) 
@@ -3849,9 +4025,9 @@
 	   * generates a tag for the first clause.
 	   */
 	  if (last == NULL)
-	    last = xnew(len + 1, char);
+	    last = xnew (len + 1, char);
 	  else if (len + 1 > allocated)
-	    last = (char *) xrealloc(last, len + 1);
+	    last = (char *) xrealloc (last, len + 1);
 	  allocated = len + 1;
 	  strncpy (last, dbp, len);
 	  last[len] = '\0';
@@ -3875,31 +4051,27 @@
      char *s;
      char *last;		/* Name of last clause. */
 {
-  int erlang_atom ();
-  int erlang_white ();
-
   int pos;
   int len;
 
-  pos = erlang_atom(s, 0);
+  pos = erlang_atom (s, 0);
   if (pos < 1)
     return 0;
 
   len = pos;
-  pos += erlang_white(s, pos);
-
-  if (s[pos++] == '(')
-    {
-      /* Save only the first clause. */
-      if ((last == NULL) ||
-	  (len != strlen(last)) ||
-	  (strncmp(s, last, len) != 0))
+  pos += eat_white (s, pos);
+
+  /* Save only the first clause. */
+  if (s[pos++] == '('
+      && (last == NULL
+	  || len != strlen (last)
+	  || !strneq (s, last, len)))
 	{
 	  pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
 		  s, pos, lineno, linecharno);
 	  return len;
 	}
-    }
+
   return 0;
 }
 
@@ -3917,27 +4089,18 @@
 erlang_attribute (s)
      char *s;
 {
-  int erlang_atom ();
-  int erlang_white ();
-
   int pos;
   int len;
 
-  if ((strncmp(s, "-define", 7) == 0) ||
-      (strncmp(s, "-record", 7) == 0))
+  if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
     {
-      pos = 7;
-      pos += erlang_white(s, pos);
-
+      pos = 7 + eat_white (s, pos);
       if (s[pos++] == '(') 
 	{
-	  pos += erlang_white(s, pos);
-	
-	  if (len = erlang_atom(s, pos))
-	    {
+	  pos += eat_white (s, pos);
+	  if (len = erlang_atom (s, pos))
 	      pfnote ((CTAGS) ? savenstr (& s[pos], len) : NULL, TRUE,
 		      s, pos + len, lineno, linecharno);
-	    }
 	}
     }
   return;
@@ -3993,22 +4156,6 @@
   else
     return -1;
 }
-
-/* Consume whitespace.  Return the number of bytes eaten */
-int
-erlang_white (s, pos)
-     char *s;
-     int pos;
-{
-  int origpos;
-
-  origpos = pos;
-
-  while (isspace (s[pos]))
-    pos++;
-
-  return pos - origpos;
-}
 
 #ifdef ETAGS_REGEXPS
 /* Take a string like "/blah/" and turn it into "blah", making sure
@@ -4023,7 +4170,7 @@
 {
   char sep = name[0];
   char *copyto = name;
-  logical quoted = FALSE;
+  bool quoted = FALSE;
 
   for (++name; *name != '\0'; ++name)
     {