fixed error with # && ##-operators in non function-like macro's
pass printable garbage characters on to parser
This commit is contained in:
parent
49fd9f9377
commit
5ed44e3432
2 changed files with 11 additions and 7 deletions
|
@ -178,10 +178,11 @@ firstline:
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
garbage:
|
garbage:
|
||||||
#endif
|
#endif
|
||||||
if (040 < ch && ch < 0177)
|
if (040 < ch && ch < 0177) {
|
||||||
lexerror("garbage char %c", ch);
|
return ptok->tk_symb = ch;
|
||||||
else
|
} else {
|
||||||
lexerror("garbage char \\%03o", ch);
|
lexerror("garbage char \\%03o", ch);
|
||||||
|
}
|
||||||
goto again;
|
goto again;
|
||||||
case STSIMP: /* a simple character, no part of compound token*/
|
case STSIMP: /* a simple character, no part of compound token*/
|
||||||
return ptok->tk_symb = ch;
|
return ptok->tk_symb = ch;
|
||||||
|
|
|
@ -548,6 +548,7 @@ macro2buffer(repl, idf, args)
|
||||||
*/
|
*/
|
||||||
register char *ptr = idf->id_macro->mc_text;
|
register char *ptr = idf->id_macro->mc_text;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
int func = idf->id_macro->mc_nps != -1;
|
||||||
char *stringify();
|
char *stringify();
|
||||||
|
|
||||||
ASSERT(ptr[idf->id_macro->mc_length] == '\0');
|
ASSERT(ptr[idf->id_macro->mc_length] == '\0');
|
||||||
|
@ -566,7 +567,7 @@ macro2buffer(repl, idf, args)
|
||||||
ptr++;
|
ptr++;
|
||||||
} while (*ptr != delim || *ptr == '\0');
|
} while (*ptr != delim || *ptr == '\0');
|
||||||
add2repl(repl, *ptr++);
|
add2repl(repl, *ptr++);
|
||||||
} else if (*ptr == '#') {
|
} else if (func && *ptr == '#') {
|
||||||
if (*++ptr == '#') {
|
if (*++ptr == '#') {
|
||||||
register int tmpindex;
|
register int tmpindex;
|
||||||
/* ## - paste operator */
|
/* ## - paste operator */
|
||||||
|
@ -631,8 +632,9 @@ macro2buffer(repl, idf, args)
|
||||||
repl->r_text[tmpindex] = TOKSEP;
|
repl->r_text[tmpindex] = TOKSEP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else /* # operator */
|
} else { /* # operator */
|
||||||
ptr = stringify(repl, ptr, args);
|
ptr = stringify(repl, ptr, args);
|
||||||
|
}
|
||||||
} else if (*ptr & FORMALP) {
|
} else if (*ptr & FORMALP) {
|
||||||
/* insert actual parameter */
|
/* insert actual parameter */
|
||||||
register int n = *ptr++ & 0177;
|
register int n = *ptr++ & 0177;
|
||||||
|
@ -658,8 +660,9 @@ macro2buffer(repl, idf, args)
|
||||||
|
|
||||||
if (*(repl->r_ptr - 1) != TOKSEP)
|
if (*(repl->r_ptr - 1) != TOKSEP)
|
||||||
add2repl(repl, TOKSEP);
|
add2repl(repl, TOKSEP);
|
||||||
} else
|
} else {
|
||||||
add2repl(repl, *ptr++);
|
add2repl(repl, *ptr++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (err)
|
if (err)
|
||||||
lexerror("illegal use of the ## operator");
|
lexerror("illegal use of the ## operator");
|
||||||
|
|
Loading…
Reference in a new issue