two -D options for one identifier didn't work

This commit is contained in:
eck 1990-04-18 13:03:05 +00:00
parent e625c3bdb8
commit b44938412e

View file

@ -40,6 +40,7 @@ do_option(text)
case 'D' : /* -Dname : predefine name */ case 'D' : /* -Dname : predefine name */
{ {
register char *cp = text, *name, *mactext; register char *cp = text, *name, *mactext;
unsigned maclen;
if (class(*cp) != STIDF && class(*cp) != STELL) { if (class(*cp) != STIDF && class(*cp) != STELL) {
error("identifier missing in -D%s", text); error("identifier missing in -D%s", text);
@ -48,18 +49,20 @@ do_option(text)
name = cp; name = cp;
while (*cp && in_idf(*cp)) while (*cp && in_idf(*cp))
++cp; ++cp;
if (!*cp) /* -Dname */ if (!*cp) { /* -Dname */
mactext = "1"; maclen = 1;
else mactext = Salloc("1", 2);
} else
if (*cp == '=') { /* -Dname=text */ if (*cp == '=') { /* -Dname=text */
*cp++ = '\0'; /* end of name */ *cp++ = '\0'; /* end of name */
mactext = cp; maclen = strlen(cp);
mactext = Salloc(cp, maclen + 1);
} }
else { /* -Dname?? */ else { /* -Dname?? */
error("malformed option -D%s", text); error("malformed option -D%s", text);
break; break;
} }
macro_def(str2idf(name, 0), mactext, -1, strlen(mactext), NOFLAG); macro_def(str2idf(name, 0), mactext, -1, maclen, NOFLAG);
break; break;
} }
case 'I' : /* -Ipath : insert "path" into include list */ case 'I' : /* -Ipath : insert "path" into include list */