changeset 2004:6469a137fea6

(C_entries): New local variable quotednl. Used for parsing of #define's spanning multiple lines. (C_entries): Save the definedef status even when a newline is met inside a string.
author Richard M. Stallman <rms@gnu.org>
date Wed, 03 Mar 1993 06:20:12 +0000
parents bff31af6c721
children 9b80d7737d2b
files lib-src/etags.c
diffstat 1 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/etags.c	Wed Mar 03 05:12:05 1993 +0000
+++ b/lib-src/etags.c	Wed Mar 03 06:20:12 1993 +0000
@@ -906,7 +906,7 @@
 
 /*
  * This routine sets up the boolean psuedo-functions which work
- * by seting boolean flags dependent upon the corresponding character
+ * by setting boolean flags dependent upon the corresponding character
  * Every char which is NOT in that string is not a white char.  Therefore,
  * all of the array "_wht" is set to FALSE, and then the elements
  * subscripted by the chars in "white" are set to TRUE.  Thus "_wht"
@@ -1413,6 +1413,7 @@
 
 #define CNL_SAVE_DEFINEDEF						\
 {									\
+  quotednl = FALSE;							\
   prev_linepos = linepos;						\
   SET_FILEPOS (linepos, inf, charno);					\
   lineno++;								\
@@ -1431,10 +1432,10 @@
      int c_ext;			/* extension of C? */
 {
   register int c;		/* latest char read; '\0' for end of line */
-  register int tokoff;		/* offset in line of beginning of latest token */
+  register int tokoff;		/* offset in line of start of latest token*/
   register int toklen;		/* length of latest token */
   register char *lp;		/* pointer one beyond the character `c' */
-  logical incomm, inquote, inchar, midtoken;
+  logical incomm, inquote, inchar, quotednl, midtoken;
   int level;			/* current curly brace level */
   char tokb[BUFSIZ];
 
@@ -1444,7 +1445,7 @@
   *lp = 0;
 
   definedef = dnone;
-  gotone = midtoken = inquote = inchar = incomm = FALSE;
+  gotone = midtoken = inquote = inchar = incomm = quotednl = FALSE;
   level = 0;
   tydef = none;
   next_token_is_func = 0;
@@ -1460,7 +1461,10 @@
 	     '\0'; don't skip it, because it's the thing that tells us
 	     to read the next line.  */
 	  if (*lp == 0)
-	    continue;
+	    {
+	      quotednl =TRUE;
+	      continue;
+	    }
 	  lp++;
 	  c = ' ';
 	}
@@ -1520,7 +1524,8 @@
 	    if (structdef == stagseen)
 	      structdef = scolonseen;
 	    break;
-	    /* Not a struct definition when semicolon seen in non-sinbody context. */
+	    /* Not a struct definition when semicolon seen
+	       in non-sinbody context. */
 	  case ';':
 	    if (structdef != snone && structdef != sinbody)
 	      {
@@ -1627,7 +1632,7 @@
 		      lp = lp_tmp;
 		      if (bingo)
 			{
-			  if (GET_CHARNO (tok.linestart) != GET_CHARNO (linepos)
+			  if (GET_CHARNO (tok.linestart) != GET_CHARNO(linepos)
 			      && !tok_at_end_of_line)
 			    {
 			      /*
@@ -1639,7 +1644,8 @@
 				tok.p = lb1.buffer + (tok.p - tok_linebuf);
 			      tok_linebuf = lb1.buffer;
 			    }
-			  if (structdef == sinbody && definedef == dnone && is_func)
+			  if (structdef == sinbody
+			      && definedef == dnone && is_func)
 			    {	/* function defined in C++ class body */
 			      sprintf (tokb, "%s::%.*s",
 				       structtag[0] == '\0' ? "_anonymous_"
@@ -1669,10 +1675,10 @@
 	      midtoken = TRUE;
 	    }
 	}
-      /* Detect end of line, after having handled the last token on the line.  */
+      /* Detect end of line, having handled the last token on the line.  */
       if (c == 0)
 	{
-	  if (incomm)
+	  if (incomm || inquote || quotednl)
 	    {
 	      CNL_SAVE_DEFINEDEF;
 	    }
@@ -1710,7 +1716,8 @@
 logical
 consider_token (c, lpp, tokp, is_func, c_ext, level)
      reg char c;		/* IN: first char after the token */
-     char **lpp;		/* IN OUT: *lpp points to 2nd char after the token */
+     char **lpp;		/* IN OUT: *lpp points
+				   to 2nd char after the token */
      reg TOKEN *tokp;		/* IN */
      logical *is_func;		/* OUT */
      int c_ext;			/* IN */
@@ -1844,7 +1851,8 @@
     {
     case st_C_struct:
     case st_C_enum:
-      if (tydef == begin || (typedefs_and_cplusplus && level == 0 && structdef == snone))
+      if (tydef == begin
+	  || (typedefs_and_cplusplus && level == 0 && structdef == snone))
 	{
 	  structdef = skeyseen;
 	  structkey = tokse;
@@ -1887,8 +1895,8 @@
 	  structdef = snone;
 	  (void) strcpy (structtag, "<error 3>");
 	}
-      /* Now what?  And how does/should this stuff interact with tydef?? */
-      /* Also maybe reset lp to *lpp for benefit of the function finding code. */
+      /* Now what?  And how does/should this stuff interact with tydef??  */
+      /* Also maybe reset lp to *lpp for sake of function-finding code.  */
     }
   if (tydef == begin)
     {