fixed error with # && ##-operators in non function-like macro's
This commit is contained in:
parent
5ed44e3432
commit
707d811586
1 changed files with 7 additions and 4 deletions
|
@ -536,6 +536,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');
|
||||||
|
@ -554,7 +555,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 */
|
||||||
|
@ -619,8 +620,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;
|
||||||
|
@ -646,8 +648,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)
|
||||||
error("illegal use of ## operator");
|
error("illegal use of ## operator");
|
||||||
|
|
Loading…
Add table
Reference in a new issue