changeset 36361:e9d69d45eae4

When in autodetect mode, switch to C++ when the template keyword is met
author Francesco Potortì <pot@gnu.org>
date Fri, 23 Feb 2001 18:19:25 +0000
parents 0774daebf700
children 193e0fa6c140
files lib-src/ChangeLog lib-src/etags.c
diffstat 2 files changed, 106 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Fri Feb 23 18:06:10 2001 +0000
+++ b/lib-src/ChangeLog	Fri Feb 23 18:19:25 2001 +0000
@@ -1,3 +1,9 @@
+2001-02-23  Francesco Potorti`  <pot@gnu.org>
+
+	* etags.c (enum sym_type): New label st_C_template.
+	(gperf input): Use it for switching to C++ from C.
+	(consider_token): Do it.
+
 2001-02-22  Andrew Innes  <andrewi@gnu.org>
 
 	* makefile.nt ($(BLD)\movemail.obj): Remove reference to
--- a/lib-src/etags.c	Fri Feb 23 18:06:10 2001 +0000
+++ b/lib-src/etags.c	Fri Feb 23 18:19:25 2001 +0000
@@ -32,7 +32,7 @@
  *	Francesco Potort́ <pot@gnu.org> has maintained it since 1993.
  */
 
-char pot_etags_version[] = "@(#) pot revision number is 14.15";
+char pot_etags_version[] = "@(#) pot revision number is 14.18";
 
 #define	TRUE	1
 #define	FALSE	0
@@ -58,7 +58,11 @@
 # undef static
 # define ETAGS_REGEXPS		/* use the regexp features */
 # define LONG_OPTIONS		/* accept long options */
-#endif /* HAVE_CONFIG_H */
+#else
+# ifndef __STDC__
+#   define static		/* remove static for old compilers' sake */
+# endif
+#endif /* !HAVE_CONFIG_H */
 
 #ifndef _GNU_SOURCE
 # define _GNU_SOURCE 1		/* enables some compiler checks on GNU */
@@ -1943,7 +1947,7 @@
   st_C_ignore,
   st_C_javastruct,
   st_C_operator,
-  st_C_class,
+  st_C_class, st_C_template,
   st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
 };
 
@@ -1953,7 +1957,6 @@
 
 /* Feed stuff between (but not including) %[ and %] lines to:
       gperf -c -k 1,3 -o -p -r -t
-   then put a `static' keyword in front of the in_word_set function.
 %[
 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
 %%
@@ -1982,6 +1985,7 @@
 typedef, 	0,	st_C_typedef
 define,  	0,	st_C_define
 operator,	C_PLPL, st_C_operator
+template,	0,	st_C_template
 bool,		C_PLPL,	st_C_typespec
 long,    	0,	st_C_typespec
 short,   	0,	st_C_typespec
@@ -2016,12 +2020,12 @@
 /* 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 TOTAL_KEYWORDS 46
+#define TOTAL_KEYWORDS 47
 #define MIN_WORD_LENGTH 2
 #define MAX_WORD_LENGTH 15
-#define MIN_HASH_VALUE 13
-#define MAX_HASH_VALUE 121
-/* maximum key range = 109, duplicates = 0 */
+#define MIN_HASH_VALUE 18
+#define MAX_HASH_VALUE 138
+/* maximum key range = 121, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -2033,32 +2037,32 @@
 {
   static unsigned char asso_values[] =
     {
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122,  57, 122, 122, 122,  55,   6,
-       60, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-       51, 122, 122,  10,   2, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122,   2,  52,  59,
-       49,  38,  56,  41, 122,  22, 122, 122,   9,  32,
-       33,  60,  26, 122,   1,  28,  46,  59,  44,  51,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
-      122, 122, 122, 122, 122, 122
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139,  63, 139, 139, 139,  33,  44,
+       62, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+       42, 139, 139,  12,  32, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139,  34,  59,  37,
+       24,  58,  33,   3, 139,  16, 139, 139,  42,  60,
+       18,  11,  39, 139,  23,  57,   4,  63,   6,  20,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
+      139, 139, 139, 139, 139, 139
     };
   register int hval = len;
 
@@ -2086,77 +2090,79 @@
   static struct C_stab_entry wordlist[] =
     {
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"ENTRY",		0,	st_C_gnumacro},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""},
       {"if",		0,	st_C_ignore},
-      {""}, {""},
-      {"SYSCALL",	0,	st_C_gnumacro},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"struct", 	0,	st_C_struct},
-      {"static",  	0,	st_C_typespec},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"long",    	0,	st_C_typespec},
-      {""}, {""}, {""}, {""}, {""},
-      {"auto",    	0,	st_C_typespec},
-      {"return",		0,	st_C_ignore},
-      {"import",		C_JAVA,	st_C_ignore},
-      {""},
-      {"switch",		0,	st_C_ignore},
-      {""},
-      {"implements",  	C_JAVA,	st_C_javastruct},
-      {""},
-      {"for",		0,	st_C_ignore},
-      {"volatile",	0,	st_C_typespec},
-      {""},
-      {"PSEUDO",		0,	st_C_gnumacro},
-      {""},
-      {"char",    	0,	st_C_typespec},
-      {"class",  	0,	st_C_class},
-      {"@protocol",	0,	st_C_objprot},
+      {""}, {""}, {""}, {""},
+      {"int",     	0,	st_C_typespec},
       {""}, {""},
       {"void",    	0,	st_C_typespec},
-      {"int",     	0,	st_C_typespec},
-      {"explicit",	C_PLPL,	st_C_typespec},
+      {""}, {""},
+      {"interface",	C_JAVA, st_C_struct},
+      {""},
+      {"SYSCALL",	0,	st_C_gnumacro},
       {""},
-      {"namespace",	C_PLPL,	st_C_struct},
-      {"signed",  	0,	st_C_typespec},
-      {""},
-      {"interface",	C_JAVA, st_C_struct},
+      {"return",		0,	st_C_ignore},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {"while",		0,	st_C_ignore},
+      {"auto",    	0,	st_C_typespec},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"float",   	0,	st_C_typespec},
       {"typedef", 	0,	st_C_typedef},
       {"typename",	C_PLPL,	st_C_typespec},
       {""}, {""}, {""},
       {"friend",		C_PLPL,	st_C_ignore},
-      {"mutable",	C_PLPL,	st_C_typespec},
-      {"union",  	0,	st_C_struct},
-      {"domain", 	C_STAR,	st_C_struct},
+      {"volatile",	0,	st_C_typespec},
       {""}, {""},
+      {"for",		0,	st_C_ignore},
+      {"const",   	0,	st_C_typespec},
+      {"import",		C_JAVA,	st_C_ignore},
+      {""},
+      {"define",  	0,	st_C_define},
+      {"long",    	0,	st_C_typespec},
+      {"implements",  	C_JAVA,	st_C_javastruct},
+      {"signed",  	0,	st_C_typespec},
+      {""},
       {"extern",  	0,	st_C_extern},
       {"extends",  	C_JAVA,	st_C_javastruct},
+      {""},
+      {"mutable",	C_PLPL,	st_C_typespec},
+      {"template",	0,	st_C_template},
+      {"short",   	0,	st_C_typespec},
+      {"bool",		C_PLPL,	st_C_typespec},
+      {"char",    	0,	st_C_typespec},
+      {"class",  	0,	st_C_class},
+      {"operator",	C_PLPL, st_C_operator},
+      {""},
+      {"switch",		0,	st_C_ignore},
+      {""},
+      {"ENTRY",		0,	st_C_gnumacro},
+      {""},
       {"package",	C_JAVA,	st_C_ignore},
-      {"short",   	0,	st_C_typespec},
+      {"union",  	0,	st_C_struct},
       {"@end",		0,	st_C_objend},
-      {"unsigned",	0,	st_C_typespec},
+      {"struct", 	0,	st_C_struct},
+      {"namespace",	C_PLPL,	st_C_struct},
+      {""}, {""},
+      {"domain", 	C_STAR,	st_C_struct},
+      {"@interface",	0,	st_C_objprot},
+      {"PSEUDO",		0,	st_C_gnumacro},
+      {"double",  	0,	st_C_typespec},
       {""},
-      {"const",   	0,	st_C_typespec},
+      {"@protocol",	0,	st_C_objprot},
+      {""},
+      {"static",  	0,	st_C_typespec},
       {""}, {""},
-      {"@interface",	0,	st_C_objprot},
+      {"DEFUN",		0,	st_C_gnumacro},
+      {""}, {""}, {""}, {""},
+      {"explicit",	C_PLPL,	st_C_typespec},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
       {"enum",    	0,	st_C_enum},
       {""}, {""},
-      {"@implementation",0,	st_C_objimpl},
-      {""},
-      {"operator",	C_PLPL, st_C_operator},
-      {""}, {""}, {""}, {""},
-      {"define",  	0,	st_C_define},
-      {""}, {""},
-      {"double",  	0,	st_C_typespec},
-      {""},
-      {"bool",		C_PLPL,	st_C_typespec},
-      {""}, {""}, {""},
-      {"DEFUN",		0,	st_C_gnumacro},
-      {"float",   	0,	st_C_typespec}
+      {"unsigned",	0,	st_C_typespec},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"@implementation",0,	st_C_objimpl}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -2523,12 +2529,15 @@
       if (structdef == stagseen)
         structdef = scolonseen;
       return FALSE;
+    case st_C_template:
     case st_C_class:
       if (cblev == 0
 	  && (*c_extp & C_AUTO)	/* automatic detection of C++ language */
 	  && definedef == dnone && structdef == snone
 	  && typdef == tnone && fvdef == fvnone)
 	*c_extp = (*c_extp | C_PLPL) & ~C_AUTO;
+      if (toktype == st_C_template)
+	break;
       /* FALLTHRU */
     case st_C_struct:
     case st_C_enum:
@@ -2792,7 +2801,7 @@
       cstack.cblev = xnew (cstack.size, int);
     }
 
-  tokoff = toklen = 0;		/* keep compiler quiet */
+  tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */
   curndx = newndx = 0;
   lineno = 0;
   charno = 0;
@@ -3370,8 +3379,10 @@
 	    break;
 	  if (typdef == ttypeseen)
 	    {
+	      /* Whenever typdef is set to tinbody (currently only
+		 here), typdefcblev should be set to cblev. */
+	      typdef = tinbody;
 	      typdefcblev = cblev;
-	      typdef = tinbody;
 	    }
 	  switch (fvdef)
 	    {
@@ -3433,6 +3444,7 @@
 	    cblev--;
 	  popclass_above (cblev);
 	  structdef = snone;
+	  /* Only if typdef == tinbody is typdefcblev significant. */
 	  if (typdef == tinbody && cblev <= typdefcblev)
 	    {
 	      assert (cblev == typdefcblev);