OSDN Git Service

2000-07-20 Zack Weinberg <zack@wolery.cumb.org>
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Jul 2000 17:14:23 +0000 (17:14 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Jul 2000 17:14:23 +0000 (17:14 +0000)
* tradcpp.c (main): Don't munge -D options.
(make_definition): Bring -D handling in line with cpplib.
(do_define): Strip all leading whitespace from macro definitions.

2000-07-20  David Billinghurst <David.Billinghurst@riotinto.com.au>

* Makefile.in (tradcpp): Depend on intl.o and version.o.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35145 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/Makefile.in
gcc/tradcpp.c

index fd2485a..62f49cb 100644 (file)
@@ -1822,7 +1822,7 @@ mkdeps.o: mkdeps.c $(CONFIG_H) system.h mkdeps.h
 
 # The traditional mode preprocessor, a separate program for ease of
 # maintenance.  Some code is shared with the ISO-C cpp.
-tradcpp$(exeext): tradcpp.o tradcif.o cppdefault.o $(LIBDEPS)
+tradcpp$(exeext): tradcpp.o tradcif.o cppdefault.o version.o intl.o $(LIBDEPS)
        $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o tradcpp$(exeext) \
        tradcpp.o tradcif.o cppdefault.o version.o intl.o $(LIBS)
 
index d48510c..1881d75 100644 (file)
@@ -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;
@@ -2543,8 +2541,8 @@ do_define (buf, limit, op, keyword)
     }
 
     ++bp;                      /* skip paren */
-    /* Skip exactly one space or tab if any.  */
-    if (bp < limit && (*bp == ' ' || *bp == '\t')) ++bp;
+    while (is_hor_space[*bp])  /* and leading whitespace */
+      ++bp;
     /* now everything from bp before limit is the definition. */
     defn = collect_expansion (bp, limit, argno, arg_ptrs);
 
@@ -2566,9 +2564,9 @@ do_define (buf, limit, op, keyword)
       defn->argnames[i] = 0;
     }
   } else {
-    /* simple expansion or empty definition; gobble it */
-    if (is_hor_space[*bp])
-      ++bp;            /* skip exactly one blank/tab char */
+    /* simple expansion or empty definition; skip leading whitespace */
+    while (is_hor_space[*bp])
+      ++bp;
     /* now everything from bp before limit is the definition. */
     defn = collect_expansion (bp, limit, -1, 0);
     defn->argnames = (U_CHAR *) "";
@@ -4667,52 +4665,26 @@ make_definition (str)
   FILE_BUF *ip;
   struct directive *kt;
   U_CHAR *buf, *p;
-
-  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;
+  size_t len = strlen ((char *)str);
+
+  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;