20000717 snapshot broken specs setup in gcc/config/i386/cygwi n.h

Zack Weinberg zack@wolery.cumb.org
Wed Jul 19 17:26:00 GMT 2000


On Thu, Jul 20, 2000 at 12:01:06AM -0000, Billinghurst, David (CRTS) wrote:
> Here is a little more detail on the -D__declspec(x)=__attribute(x) issue
> with g77
...
> /usr/local/obj/egcs-20000717/gcc/tradcpp.exe: malformed option `-D
> __declspec(x) __attribute__((x))'

This is due to excessive cleverness in the -D handler.  Please try the
appended patch.

> PS.  There is an outstanding tradcpp makefile patch
> http://gcc.gnu.org/ml/gcc-patches/2000-07/msg00693.html

I thought I had applied that already.  Sorry.  I'll need to test it
but it should go in sometime this evening.

zw

	* tradcpp.c (main): Do not munge -D options.
	(make_definition): Handle -Dfoo(x)=... correctly.

===================================================================
Index: tradcpp.c
--- tradcpp.c	2000/07/19 20:37:25	1.6
+++ tradcpp.c	2000/07/20 00:23:39
@@ -610,7 +610,7 @@ main (argc, argv)
 
       case 'D':
 	{
-	  char *p, *p1;
+	  char *p;
 
 	  if (argv[i][2] != 0)
 	    p = argv[i] + 2;
@@ -619,8 +619,6 @@ main (argc, argv)
 	  else
 	    p = argv[++i];
 
-	  if ((p1 = (char *) strchr (p, '=')) != NULL)
-	    *p1 = ' ';
 	  pend_defs[i] = p;
 	}
 	break;
@@ -4667,52 +4665,26 @@ make_definition (str)
   FILE_BUF *ip;
   struct directive *kt;
   U_CHAR *buf, *p;
+  size_t len = strlen ((char *)str);
 
-  buf = str;
-  p = str;
-  while (is_idchar[*p]) p++;
-  if (p == str) {
-    error ("malformed option `-D %s'", str);
-    return;
-  }
-  if (*p == 0) {
-    buf = (U_CHAR *) alloca (p - buf + 4);
-    strcpy ((char *)buf, (char *)str);
-    strcat ((char *)buf, " 1");
-  } else if (*p != ' ') {
-    error ("malformed option `-D %s'", str);
-    return;
+  p = (U_CHAR *) strchr ((char *)str, '=');
+  if (p == NULL) {
+    /* Change -DFOO into #define FOO 1 */
+    buf = (U_CHAR *) alloca (len + 3);
+    memcpy (buf, str, len);
+    memcpy (buf + len, " 1", 3);
+    len += 2;
   } else {
-    U_CHAR *q;
-    /* Copy the entire option so we can modify it.  */
-    buf = (U_CHAR *) alloca (2 * strlen ((char *)str) + 1);
-    strncpy ((char *)buf, (char *)str, p - str);
-    /* Change the = to a space.  */
+    buf = (U_CHAR *) alloca (len + 1);
+    memcpy (buf, str, len + 1);
     buf[p - str] = ' ';
-    /* Scan for any backslash-newline and remove it.  */
-    p++;
-    q = &buf[p - str];
-    while (*p) {
-      if (*p == '\\' && p[1] == '\n')
-	p += 2;
-      /* Change newline chars into newline-markers.  */
-      else if (*p == '\n')
-	{
-	  *q++ = '\n';
-	  *q++ = '\n';
-	  p++;
-	}
-      else
-	*q++ = *p++;
-    }
-    *q = 0;
   }
   
   ip = &instack[++indepth];
   ip->fname = "*Initialization*";
 
   ip->buf = ip->bufp = buf;
-  ip->length = strlen ((char *)buf);
+  ip->length = len;
   ip->lineno = 1;
   ip->macro = 0;
   ip->free_ptr = 0;


More information about the Gcc-bugs mailing list