mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Do a better check for recursive macro invocations
Simply checking if the macro's next pointer was set wasn't enough for when the macro was at the end of the chain (or the only macro in the chain).
This commit is contained in:
parent
a57ea628ca
commit
15ddd8fea9
1 changed files with 13 additions and 1 deletions
|
@ -1383,6 +1383,18 @@ check_macro (rua_macro_t *macro)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool __attribute__((pure))
|
||||
recursive_invocation (rua_macro_t *macro, rua_extra_t *extra)
|
||||
{
|
||||
while (macro && extra->macro) {
|
||||
if (macro == extra->macro) {
|
||||
return true;
|
||||
}
|
||||
macro = macro->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
next_token (rua_tok_t *tok, yyscan_t scanner, rua_ctx_t *ctx)
|
||||
{
|
||||
|
@ -1561,7 +1573,7 @@ rescan:
|
|||
if ((extra->expand || !(extra->preprocessor || extra->suppressed))
|
||||
&& token == -rua_id
|
||||
&& (sym = symtab_lookup (extra->macro_tab, e.text))
|
||||
&& !sym->macro->next) {
|
||||
&& !recursive_invocation (sym->macro, extra)) {
|
||||
auto macro = sym->macro;
|
||||
if (macro->update) {
|
||||
macro->update (macro, ctx);
|
||||
|
|
Loading…
Reference in a new issue