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]

cpp -dD broken (patch)



Hi All,

  cpp -dD is currently broken in the CVS tree.  A simple test case to show
this is:

---- test.h ----
#define macro(x,y)	(x) + (y)
----------------

  Which when processed with "cpp -dD -P test.h" results in:

---- test.i ----
#define macro(, x) () + (x)
----------------

  I would have to guess that this is just a simple logic error wrt. to the
recent cpp reorganisation ... so here is a quick patch to make it work
again (assuming that "cpp -dD" is the only thing broken).

Index: cpphash.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cpphash.c,v
retrieving revision 1.45
diff -u -r1.45 cpphash.c
--- cpphash.c	2000/03/04 01:42:56	1.45
+++ cpphash.c	2000/03/06 19:15:45
@@ -1609,19 +1609,18 @@
 
       /* First extract the argument list. */
       x = argnames;
-      i = defn->nargs;
-      while (i--)
-	{
-	  argv[i] = x;
-	  while (*x != ',' && *x != '\0') x++;
-	  argl[i] = x - argv[i];
-	  if (*x == ',')
-	    {
-	      *x = '\0';
-	      x += 2;  /* skip the space after the comma */
-	    }
-	}
-      
+      for (i = 0; i < defn->nargs; i++)
+        {
+          argv[i] = x;
+          while (*x != ',' && *x != '\0') x++;
+          argl[i] = x - argv[i];
+          if (*x == ',')
+            {
+              *x++ = '\0';
+              while ((*x == ',' || *x == ' ') && *x != '\0') x++;
+            }
+        }
+   
       /* Now print out the argument list. */
       CPP_PUTC_Q (pfile, '(');
       for (i = 0; i < defn->nargs; i++)

	Thanks,

		CraigN
--
      Craig Newell                email: CraigN@savaJe.com
 Founder and Kernel Engineer      icbm:  anywhere in NJ, USA
  savaJe technologies, inc.       voice: +1 732 558 0018


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