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


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

Re: cpplib bug fix (macro expansion)


On Wed, 30 Sep 1998 14:48:23 -0400, Dave Brolley wrote:
>You don't need to preserve the spaces in the macro buffers, just in the source
>file buffer. That's why the mark is set after the macro buffers are all popped
>off the stack. I think a combination of the existing mark/return scheme and
>something to note spaces in the macro buffers is in order.

Is it safe to assume macro buffers cannot contain newlines and
comments?  If so, this patch should work.

zw

1998-10-02 19:55 -0400  Zack Weinberg  <zack@rabi.phys.columbia.edu>

	* cpplib.c (cpp_get_token): When checking for a function-like
	macro call, remember whitespace provided by macro buffers.

Index: cpplib.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cpplib.c,v
retrieving revision 1.34
diff -u -r1.34 cpplib.c
--- cpplib.c	1998/09/30 19:27:28	1.34
+++ cpplib.c	1998/10/02 23:53:43
@@ -5099,17 +5099,20 @@
 	    if (hp->type == T_MACRO && hp->value.defn->nargs >= 0)
 	    {
 	      struct parse_marker macro_mark;
-	      int is_macro_call;
+	      int is_macro_call, macbuf_whitespace = 0;
 	      while (CPP_IS_MACRO_BUFFER (CPP_BUFFER (pfile)))
 	        {
-		  cpp_buffer *next_buf;
-		  cpp_skip_hspace (pfile);
-		  if (PEEKC () != EOF)
+		  while (is_hor_space[c = PEEKC ()])
+		    {
+		      macbuf_whitespace = 1;
+		      FORWARD (1);
+		    }
+		  if (c != EOF)
 		    break;
-		  next_buf = CPP_PREV_BUFFER (CPP_BUFFER (pfile));
-		  (*CPP_BUFFER (pfile)->cleanup) (CPP_BUFFER (pfile), pfile);
-		  CPP_BUFFER (pfile) = next_buf;
+
+		  cpp_pop_buffer (pfile);
 	        }
+	      if(macbuf_whitespace) CPP_PUTC(pfile, ' ');
 	      parse_set_mark (&macro_mark, pfile);
 	      for (;;)
 		{


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