[multiple changes]

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.

From-SVN: r35145
This commit is contained in:
Zack Weinberg 2000-07-20 17:14:23 +00:00
parent 5685bed383
commit 1e18a243c2
2 changed files with 18 additions and 46 deletions

View 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)

View 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;
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;