diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-07-20 17:14:23 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-07-20 17:14:23 +0000 |
commit | 92ac01460c75ee187f1fe74a74f88dbaaa2bd31a (patch) | |
tree | fa10ffb8fdef99014249c2280b3199b32872d31c /gcc/tradcpp.c | |
parent | 8386ea8800f321a1db8cdea2291717ff0197c572 (diff) | |
download | gcc-92ac01460c75ee187f1fe74a74f88dbaaa2bd31a.tar.gz |
2000-07-20 Zack Weinberg <zack@wolery.cumb.org>
* 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
Diffstat (limited to 'gcc/tradcpp.c')
-rw-r--r-- | gcc/tradcpp.c | 64 |
1 files changed, 18 insertions, 46 deletions
diff --git a/gcc/tradcpp.c b/gcc/tradcpp.c index d48510ce7ac..1881d75b97f 100644 --- a/gcc/tradcpp.c +++ b/gcc/tradcpp.c @@ -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; |