two -D options for one identifier didn't work

This commit is contained in:
eck 1990-04-18 13:09:36 +00:00
parent b44938412e
commit 52f08181a6

View file

@ -104,6 +104,7 @@ deleted, is now a debug-flag
case 'D' : { /* -Dname : predefine name */ case 'D' : { /* -Dname : predefine name */
#ifndef NOPP #ifndef NOPP
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);
@ -117,20 +118,21 @@ deleted, is now a debug-flag
} }
if (!*cp) { /* -Dname */ if (!*cp) { /* -Dname */
mactext = "1"; maclen = 1;
mactext = Salloc("1", 2);
} }
else else
if (*cp == '=') { /* -Dname=text */ if (*cp == '=') { /* -Dname=text */
*cp++ = '\0'; /* end of name */ *cp++ = '\0'; /* end of name */
mactext = cp; maclen = (unsigned) 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), mactext, -1, strlen(mactext), macro_def(str2idf(name), mactext, -1, maclen, NOFLAG);
NOFLAG);
#else NOPP #else NOPP
warning("-D option ignored"); warning("-D option ignored");
#endif NOPP #endif NOPP