changeset 9193:86fd33a4f327

* etags.c (C_entries): Recognise typedef of ANSI style functions. (C_entries): Recognise #define inside a struct. (C_entries): ANSI tells that preprocessor commands do not have to start on the first column. (print_help): Documentation corrected for -d and -D. (white, endtk): ANSI tells the vertical tab is a separator.
author Francesco Potortì <pot@gnu.org>
date Fri, 30 Sep 1994 17:18:24 +0000
parents 082392c8f9be
children 3db4151c3d00
files lib-src/etags.c
diffstat 1 files changed, 57 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/etags.c	Fri Sep 30 09:16:06 1994 +0000
+++ b/lib-src/etags.c	Fri Sep 30 17:18:24 1994 +0000
@@ -231,8 +231,8 @@
 
 char *curfile,			/* current input file name		*/
  *tagfile,			/* output file				*/
- *white = " \f\t\n",		/* white chars				*/
- *endtk = " \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?",	/* token ending chars	*/
+ *white = " \f\t\n\013",	/* white chars				*/
+ *endtk = " \t\n\013\"'#()[]{}=-+%*/&|^~!<>;,.:?", /* token ending chars */
 				/* token starting chars			*/
  *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~",
 				/* valid in-token chars			*/
@@ -333,11 +333,11 @@
 
   if (CTAGS)
     puts ("-d, --defines\n\
-        Create tag entries for C #defines, too.");
+        Create tag entries for constant C #defines, too.");
   else
     puts ("-D, --no-defines\n\
-        Don't create tag entries for C #defines.  This makes the tags\n\
-	file smaller.");
+        Don't create tag entries for constant C #defines.  This makes\n\
+	the tags file smaller.");
 
   if (!CTAGS)
     puts ("-i FILE, --include=FILE\n\
@@ -1413,7 +1413,8 @@
       return (FALSE);
     case ddefineseen:
       /*
-       * Make a tag for any macro.
+       * Make a tag for any macro, unless it is a constant
+       * and constantypedefs is FALSE.
        */
       definedef = dignorerest;
       *is_func = (c == '(');
@@ -1745,19 +1746,40 @@
 	    else
 	      break;
 	  case '#':
-	    if (lp == newlb.buffer + 1 && definedef == dnone)
-	      definedef = dsharpseen;
+	    if (definedef == dnone)
+	      {
+		char *cp;
+		logical cpptoken = TRUE;
+
+		/* Look back on this line.  If all blanks, or nonblanks
+		   followed by an end of comment, this is a preprocessor
+		   token. */
+		for (cp = newlb.buffer; cp < lp-1; cp++)
+		  if (!iswhite (*cp))
+		    {
+		      if (*cp == '*' && *(cp+1) == '/')
+			{
+			  cp++;
+			  cpptoken = TRUE;
+			}
+		      else
+			cpptoken = FALSE;
+		    }
+		if (cpptoken)
+		  definedef = dsharpseen;
+	      } /* if (definedef == dnone) */
+
 	    continue;
 	  } /* switch (c) */
 
 
       /* Consider token only if some complicated conditions are satisfied. */
-      if (((cblev == 0 && structdef != scolonseen)
+      if ((definedef != dnone
+	   || (cblev == 0 && structdef != scolonseen)
 	   || (cblev == 1 && cplpl && structdef == sinbody))
 	  && typdef != tignore
 	  && definedef != dignorerest
-	  && (funcdef != finlist
-	      || definedef != dnone))
+	  && funcdef != finlist)
 	{
 	  if (midtoken)
 	    {
@@ -1766,8 +1788,8 @@
 		  if (cplpl && c == ':' && *lp == ':' && begtoken(*(lp + 1)))
 		    {
 		      /*
-		       * This handles :: in the middle, but not at beginning
-		       * of an identifier.
+		       * This handles :: in the middle, but not at the
+		       * beginning of an identifier.
 		       */
 		      lp += 2;
 		      toklen += 3;
@@ -1788,11 +1810,11 @@
 			      && is_func)
 			    /* function defined in C++ class body */
 			    {
-			      tok.named = TRUE;
 			      sprintf (nameb, "%s::%.*s",
 				       ((structtag[0] == '\0')
 					? "_anonymous_" : structtag),
 				       tok.len, tok.p);
+			      tok.named = TRUE;
 			    }
 			  else
 			    {
@@ -1800,7 +1822,10 @@
 			    }
 
 			  if (structdef == stagseen
-			      || typdef == tend)
+			      || typdef == tend
+			      /* Better not to name the #define's in
+				 order to reduce the TAGS file size.
+			      || definedef == dignorerest */ )
 			    tok.named = TRUE;
 
 			  if (definedef == dnone
@@ -1845,7 +1870,7 @@
 		    structdef = snone;
 		  break;
 		case dsharpseen:
-		  /* Take a quick peek ahead for define directive,
+		  /* Take a quick peek ahead for a define directive,
 		     so we can avoid saving the token when not absolutely
 		     necessary. [This is a speed hack.] */
 		  if (c == 'd' && strneq(lp, "efine", 5)
@@ -1938,6 +1963,22 @@
 	    break;
 	  switch (funcdef)
 	    {
+	    case fnone:
+	      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 (*lp != '*')
+		    {
+		      typdef = tignore;
+		      MAKE_TAG_FROM_OTH_LB (FALSE);
+		    }
+		  break;
+		} /* switch (typdef) */
+	      break;
 	    case ftagseen:
 	      funcdef = fstartlist;
 	      break;