This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the EGCS project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

cpplib minor updates



This patch contains three minor updates for cpplib: two bug fixes and
an optimization.  They are not related at all, and if you want to
see them separately I'll resend.

Also, note my email address has changed.  The old one
(zack@rabi.columbia.edu) still works but I would appreciate it if
people would send gcc-related mail to the new address.

zw

1999-07-23 21:33 -0700  Zack Weinberg  <zack@bitmover.com>

	* cpphash.c (macroexpand): Delete leading whitespace when arg
	is concatenated before.
	(unsafe_chars): Correct test for whether + and - can extend a
	token.

	* cppinit.c (cpp_start_read): Do dependencies for
	-include/-imacros files also.

	* cpplib.c (cpp_scan_buffer): In no-output mode, don't bother
	tokenizing non-directive lines.
	(cpp_expand_to_buffer): Temporarily disable no-output mode.
	* cppmain.c: In no-output mode, just call cpp_scan_buffer for
	the input file.

Index: cpphash.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cpphash.c,v
retrieving revision 1.22
diff -u -r1.22 cpphash.c
--- cpphash.c	1999/06/07 10:35:24	1.22
+++ cpphash.c	1999/07/23 18:12:49
@@ -1337,10 +1337,17 @@
 	      U_CHAR *l1 = p1 + arg->raw_length;
 	      if (ap->raw_before)
 		{
-		  while (p1 != l1 && is_space[*p1])
-		    p1++;
-		  while (p1 != l1 && is_idchar[*p1])
-		    xbuf[totlen++] = *p1++;
+		  /* Arg is concatenated before: delete leading whitespace,
+		     whitespace markers, and no-reexpansion markers.  */
+		  while (p1 != l1)
+		    {
+		      if (is_space[p1[0]])
+			p1++;
+		      else if (p1[0] == '\r')
+			p1 += 2;
+		      else
+			break;
+		    }
 		}
 	      if (ap->raw_after)
 		{
@@ -1460,15 +1467,12 @@
 {
   switch (c1)
     {
-    case '+':
-    case '-':
+    case '+':  case '-':
       if (c2 == c1 || c2 == '=')
 	return 1;
       goto letter;
 
-    case '.':    case '0':    case '1':    case '2':    case '3':
-    case '4':    case '5':    case '6':    case '7':    case '8':
-    case '9':    case 'e':    case 'E':    case 'p':    case 'P':
+    case 'e':  case 'E':  case 'p':  case 'P':
       if (c2 == '-' || c2 == '+')
 	return 1;		/* could extend a pre-processing number */
       goto letter;
@@ -1478,6 +1482,8 @@
 	return 1;		/* Could turn into L"xxx" or L'xxx'.  */
       goto letter;
 
+    case '.':  case '0':  case '1':  case '2':  case '3':
+    case '4':  case '5':  case '6':  case '7':  case '8':  case '9':
     case '_':  case 'a':  case 'b':  case 'c':  case 'd':  case 'f':
     case 'g':  case 'h':  case 'i':  case 'j':  case 'k':  case 'l':
     case 'm':  case 'n':  case 'o':  case 'q':  case 'r':  case 's':
Index: cppinit.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cppinit.c,v
retrieving revision 1.15
diff -u -r1.15 cppinit.c
--- cppinit.c	1999/07/20 19:13:00	1.15
+++ cppinit.c	1999/07/23 18:12:51
@@ -1029,8 +1029,15 @@
       ih_fake->control_macro = 0;
       ih_fake->buf = (char *)-1;
       ih_fake->limit = 0;
-      if (!finclude (pfile, fd, ih_fake))
-	cpp_scan_buffer (pfile);
+      if (finclude (pfile, fd, ih_fake))
+	{
+	  if (CPP_PRINT_DEPS (pfile))
+	    deps_output (pfile, ih_fake->name, ' ');
+
+	  cpp_scan_buffer (pfile);
+	}
+      else
+	cpp_pop_buffer (pfile);
       free (ih_fake);
 
       q = p->next;
@@ -1062,8 +1069,14 @@
       ih_fake->buf = (char *)-1;
       ih_fake->limit = 0;
       if (finclude (pfile, fd, ih_fake))
-	output_line_command (pfile, enter_file);
-
+	{
+	  if (CPP_PRINT_DEPS (pfile))
+	    deps_output (pfile, ih_fake->name, ' ');
+	  
+	  output_line_command (pfile, enter_file);
+	}
+      else
+	cpp_pop_buffer (pfile);
       q = p->next;
       free (p);
       p = q;
Index: cpplib.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cpplib.c,v
retrieving revision 1.83
diff -u -r1.83 cpplib.c
--- cpplib.c	1999/07/20 19:13:00	1.83
+++ cpplib.c	1999/07/23 18:12:51
@@ -731,17 +731,44 @@
      cpp_reader *pfile;
 {
   cpp_buffer *buffer = CPP_BUFFER (pfile);
-  for (;;)
+  enum cpp_token token;
+  if (CPP_OPTIONS (pfile)->no_output)
     {
-      enum cpp_token token = cpp_get_token (pfile);
-      if (token == CPP_EOF) /* Should not happen ...  */
-	break;
-      if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
+      long old_written = CPP_WRITTEN (pfile);
+      /* In no-output mode, we can ignore everything but directives.  */
+      for (;;)
 	{
-	  cpp_pop_buffer (pfile);
-	  break;
+	  if (! pfile->only_seen_white)
+	    skip_rest_of_line (pfile);
+	  token = cpp_get_token (pfile);
+	  if (token == CPP_EOF) /* Should not happen ...  */
+	    break;
+	  if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
+	    {
+	      if (CPP_PREV_BUFFER (CPP_BUFFER (pfile))
+		  != CPP_NULL_BUFFER (pfile))
+		cpp_pop_buffer (pfile);
+	      break;
+	    }
 	}
+      CPP_SET_WRITTEN (pfile, old_written);
     }
+  else
+    {
+      for (;;)
+	{
+	  token = cpp_get_token (pfile);
+	  if (token == CPP_EOF) /* Should not happen ...  */
+	    break;
+	  if (token == CPP_POP && CPP_BUFFER (pfile) == buffer)
+	    {
+	      if (CPP_PREV_BUFFER (CPP_BUFFER (pfile))
+		  != CPP_NULL_BUFFER (pfile))
+		cpp_pop_buffer (pfile);
+	      break;
+	    }
+	}
+    }
 }
 
 /*
@@ -760,13 +787,8 @@
      int length;
 {
   register cpp_buffer *ip;
-#if 0
-  cpp_buffer obuf;
-#endif
   U_CHAR *buf1;
-#if 0
-  int odepth = indepth;
-#endif
+  int save_no_output;
 
   if (length < 0)
     {
@@ -784,12 +806,12 @@
   if (ip == NULL)
     return;
   ip->has_escapes = 1;
-#if 0
-  ip->lineno = obuf.lineno = 1;
-#endif
 
   /* Scan the input, create the output.  */
+  save_no_output = CPP_OPTIONS (pfile)->no_output;
+  CPP_OPTIONS (pfile)->no_output = 0;
   cpp_scan_buffer (pfile);
+  CPP_OPTIONS (pfile)->no_output = save_no_output;
 
   CPP_NUL_TERMINATE (pfile);
 }
Index: cppmain.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cppmain.c,v
retrieving revision 1.16
diff -u -r1.16 cppmain.c
--- cppmain.c	1999/05/10 15:24:36	1.16
+++ cppmain.c	1999/07/23 18:12:51
@@ -81,12 +81,12 @@
   else if (! freopen (opts->out_fname, "w", stdout))
     cpp_pfatal_with_name (&parse_in, opts->out_fname);
 
-  do
+  if (! opts->no_output)
     {
-      kind = cpp_get_token (&parse_in);
-      if (CPP_WRITTEN (&parse_in) >= BUFSIZ || kind == CPP_EOF)
+      do
 	{
-	  if (! opts->no_output)
+	  kind = cpp_get_token (&parse_in);
+	  if (CPP_WRITTEN (&parse_in) >= BUFSIZ || kind == CPP_EOF)
 	    {
 	      size_t rem, count = CPP_WRITTEN (&parse_in);
 
@@ -94,12 +94,22 @@
 	      if (rem < count)
 		/* Write error. */
 		cpp_pfatal_with_name (&parse_in, opts->out_fname);
-	    }
 
-	  CPP_SET_WRITTEN (&parse_in, 0);
+	      CPP_SET_WRITTEN (&parse_in, 0);
+	    }
+	}
+      while (kind != CPP_EOF);
+    }
+  else
+    {
+      do
+	{
+	  cpp_scan_buffer (&parse_in);
+	  kind = cpp_get_token (&parse_in);
 	}
+      while (kind != CPP_EOF);
+      CPP_SET_WRITTEN (&parse_in, 0);
     }
-  while (kind != CPP_EOF);
 
   cpp_finish (&parse_in);
   if (fwrite (parse_in.token_buffer, 1, CPP_WRITTEN (&parse_in), stdout)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]