Also recognize 'defined' without parentheses
This commit is contained in:
parent
35586d769a
commit
44ff24f085
4 changed files with 43 additions and 15 deletions
|
@ -34,7 +34,7 @@ PRIVATE char ifstack[IFDEPTH]; /* if-stack: the content of an entry is */
|
||||||
|
|
||||||
int nestlevel = -1;
|
int nestlevel = -1;
|
||||||
|
|
||||||
PRIVATE struct idf *
|
struct idf *
|
||||||
GetIdentifier()
|
GetIdentifier()
|
||||||
{
|
{
|
||||||
/* returns a pointer to the descriptor of the identifier that is
|
/* returns a pointer to the descriptor of the identifier that is
|
||||||
|
|
|
@ -69,19 +69,32 @@ replace(idef)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
LoadChar(c);
|
LoadChar(c);
|
||||||
c = skipspaces(c,1);
|
c = skipspaces(c,! (mac->mc_flag & FUNC));
|
||||||
if (c != '(') { /* no replacement if no () */
|
if (c != '(') { /* no replacement if no () */
|
||||||
lexerror("(warning) macro %s needs arguments",
|
|
||||||
idef->id_text);
|
|
||||||
PushBack();
|
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) {
|
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();
|
repl = new_mlist();
|
||||||
if (param->id_macro)
|
if (param && param->id_macro)
|
||||||
reptext = "1";
|
reptext = "1";
|
||||||
else
|
else
|
||||||
reptext = "0";
|
reptext = "0";
|
||||||
|
@ -93,6 +106,7 @@ replace(idef)
|
||||||
repl->m_mac = mac;
|
repl->m_mac = mac;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
actpars = getactuals(idef); /* get act.param. list */
|
||||||
}
|
}
|
||||||
repl = new_mlist();
|
repl = new_mlist();
|
||||||
repl->m_mac = mac;
|
repl->m_mac = mac;
|
||||||
|
|
|
@ -34,7 +34,7 @@ int nestlevel = -1;
|
||||||
int svnestlevel[30] = {-1};
|
int svnestlevel[30] = {-1};
|
||||||
int nestcount;
|
int nestcount;
|
||||||
|
|
||||||
PRIVATE char *
|
char *
|
||||||
GetIdentifier()
|
GetIdentifier()
|
||||||
{
|
{
|
||||||
/* returns a pointer to the descriptor of the identifier that is
|
/* returns a pointer to the descriptor of the identifier that is
|
||||||
|
|
|
@ -65,17 +65,30 @@ replace(idef)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
LoadChar(c);
|
LoadChar(c);
|
||||||
c = skipspaces(c,1);
|
c = skipspaces(c,! (mac->mc_flag & FUNC));
|
||||||
if (c != '(') { /* no replacement if no () */
|
if (c != '(') { /* no replacement if no () */
|
||||||
warning("macro %s needs arguments",
|
|
||||||
idef->id_text);
|
|
||||||
PushBack();
|
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) {
|
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();
|
repl = new_mlist();
|
||||||
if (param && param->id_macro)
|
if (param && param->id_macro)
|
||||||
reptext = "1";
|
reptext = "1";
|
||||||
|
@ -90,6 +103,7 @@ replace(idef)
|
||||||
repl->m_mac = mac;
|
repl->m_mac = mac;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
actpars = getactuals(idef); /* get act.param. list */
|
||||||
}
|
}
|
||||||
|
|
||||||
repl = new_mlist();
|
repl = new_mlist();
|
||||||
|
|
Loading…
Reference in a new issue