Also recognize 'defined' without parentheses

This commit is contained in:
ceriel 1989-10-25 14:23:08 +00:00
parent 35586d769a
commit 44ff24f085
4 changed files with 43 additions and 15 deletions

View file

@ -34,7 +34,7 @@ PRIVATE char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
int nestlevel = -1;
PRIVATE struct idf *
struct idf *
GetIdentifier()
{
/* returns a pointer to the descriptor of the identifier that is

View file

@ -69,19 +69,32 @@ replace(idef)
return 0;
}
LoadChar(c);
c = skipspaces(c,1);
c = skipspaces(c,! (mac->mc_flag & FUNC));
if (c != '(') { /* no replacement if no () */
lexerror("(warning) macro %s needs arguments",
idef->id_text);
PushBack();
return 0;
if (! (mac->mc_flag & FUNC)) {
lexerror("(warning) macro %s needs arguments",
idef->id_text);
return 0;
}
}
actpars = getactuals(idef); /* get act.param. list */
if (mac->mc_flag & FUNC) {
struct idf *param = str2idf(*actpars);
struct idf *param;
extern struct idf *GetIdentifier();
UnknownIdIsZero = 0;
param = GetIdentifier();
UnknownIdIsZero = 1;
if (c == '(') {
LoadChar(c);
c = skipspaces(c,0);
if (c != ')') error(") missing");
}
if (! param) {
error("identifier missing");
}
repl = new_mlist();
if (param->id_macro)
if (param && param->id_macro)
reptext = "1";
else
reptext = "0";
@ -93,6 +106,7 @@ replace(idef)
repl->m_mac = mac;
return 1;
}
actpars = getactuals(idef); /* get act.param. list */
}
repl = new_mlist();
repl->m_mac = mac;

View file

@ -34,7 +34,7 @@ int nestlevel = -1;
int svnestlevel[30] = {-1};
int nestcount;
PRIVATE char *
char *
GetIdentifier()
{
/* returns a pointer to the descriptor of the identifier that is

View file

@ -65,17 +65,30 @@ replace(idef)
return 0;
}
LoadChar(c);
c = skipspaces(c,1);
c = skipspaces(c,! (mac->mc_flag & FUNC));
if (c != '(') { /* no replacement if no () */
warning("macro %s needs arguments",
idef->id_text);
PushBack();
return 0;
if (! (mac->mc_flag & FUNC)) {
warning("macro %s needs arguments",
idef->id_text);
return 0;
}
}
actpars = getactuals(idef); /* get act.param. list */
if (mac->mc_flag & FUNC) {
struct idf *param = findidf(*actpars);
struct idf *param;
extern struct idf *GetIdentifier();
UnknownIdIsZero = 0;
param = GetIdentifier();
UnknownIdIsZero = 1;
if (c == '(') {
LoadChar(c);
c = skipspaces(c, 0);
if (c != ')') error(") missing");
}
if (! param) {
error("identifier missing");
}
repl = new_mlist();
if (param && param->id_macro)
reptext = "1";
@ -90,6 +103,7 @@ replace(idef)
repl->m_mac = mac;
return 1;
}
actpars = getactuals(idef); /* get act.param. list */
}
repl = new_mlist();