Print this page
cpp: only consider macro calls unterminated if they ever began
We should only error about an unterminated macro parameter list if a
parameter list was begun. If we never even seen the _first_
parenthesis, there is nothing to terminate.
Previously, we would set the parenthesis level to -1 when expecting
parameters (such that when we saw the opening paren it became the 0th
level), but when checking for unterminated expansion we would strictly
compare to 0, and thus flag a macro which needed parameters but lacked
them as having an unterminated parameter list.
@@ -396,11 +396,11 @@
pend=pbuf+ninbuf; *pend='\0';
return(p);
}
/* end of #include file */
if (ifno==0) {/* end of input */
- if (plvl!=0) {
+ if (plvl > 0) {
int n=plvl,tlin=lineno[ifno];
char *tfil=fnames[ifno];
lineno[ifno]=maclin;
fnames[ifno]=macfil;
pperror("%s: unterminated macro call",
@@ -1162,11 +1162,10 @@
* macro definition and any parameters such that the expanded macro is what is
* next read by the preprocessor as if it were input
*/
static char *
subst(p,sp) register char *p; struct symtab *sp; {
- static char match[]="%s: argument mismatch";
register char *ca,*vp; int params;
char *actual[MAXFRM]; /* actual[n] is text of nth actual */
char acttxt[BUFFERSIZ]; /* space for actuals */
/* State while pasting, TRAIL is trailing space, INTRA is in the body */
enum { TRAIL, INTRA } state = TRAIL;
@@ -1249,17 +1248,18 @@
if (ca> &acttxt[BUFFERSIZ])
pperror("%s: actuals too long",
sp->name);
}
if (pa>= &actual[MAXFRM])
- ppwarn(match,sp->name);
+ ppwarn("%s: argument mismatch" ,
+ sp->name);
else
*pa++=ca;
}
}
if (params!=0)
- ppwarn(match,sp->name);
+ ppwarn("%s: argument mismatch", sp->name);
while (--params>=0)
*pa++=""+1; /* null string for missing actuals */
--flslvl; fasscan();
}