mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-01-06 16:04:43 +08:00
preproc: fix terminal token pasting in indirect sequences
Fix the case where the terminal token pastes with the first token of the unmodified sequence. This is a really ugly version; we need to merge the two instances plus the one in expand_mmac_params(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
e126581f4d
commit
49b33f398e
30
preproc.c
30
preproc.c
@ -3915,6 +3915,8 @@ static Token *expand_id(Token * tline)
|
|||||||
/*
|
/*
|
||||||
* Expand indirect tokens, %[...]. Just like expand_smacro(),
|
* Expand indirect tokens, %[...]. Just like expand_smacro(),
|
||||||
* the input is considered destroyed.
|
* the input is considered destroyed.
|
||||||
|
*
|
||||||
|
* XXX: fix duplicated code in this function and in expand_mmac_params()
|
||||||
*/
|
*/
|
||||||
static Token *expand_indirect(Token * tline, int level)
|
static Token *expand_indirect(Token * tline, int level)
|
||||||
{
|
{
|
||||||
@ -3962,7 +3964,33 @@ static Token *expand_indirect(Token * tline, int level)
|
|||||||
it = it->next;
|
it = it->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*tp = thead = t->next;
|
|
||||||
|
skip = false;
|
||||||
|
it = t->next;
|
||||||
|
if (it) {
|
||||||
|
switch (thead ? thead->type : TOK_NONE) {
|
||||||
|
case TOK_WHITESPACE:
|
||||||
|
skip = (it->type == TOK_WHITESPACE);
|
||||||
|
break;
|
||||||
|
case TOK_ID:
|
||||||
|
case TOK_NUMBER:
|
||||||
|
if (it->type == thead->type || it->type == TOK_NUMBER) {
|
||||||
|
char *tmp = nasm_strcat(thead->text, it->text);
|
||||||
|
nasm_free(thead->text);
|
||||||
|
thead->text = tmp;
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skip) {
|
||||||
|
*tp = thead = it->next;
|
||||||
|
t = delete_Token(t);
|
||||||
|
} else {
|
||||||
|
*tp = thead = it;
|
||||||
|
}
|
||||||
t = delete_Token(t);
|
t = delete_Token(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user