diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-10-19 22:22:05 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-10-19 22:22:05 -0700 |
commit | 49b33f398ecc1068f7e0b5591b36d663238b1e8b (patch) | |
tree | 9d7ef5061de17b8bbe07faf4513b176dd46b762d | |
parent | e126581f4d391cc25cf3db55acff717aee39c85c (diff) | |
download | nasm-49b33f398ecc1068f7e0b5591b36d663238b1e8b.tar.gz |
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>
-rw-r--r-- | preproc.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -3915,6 +3915,8 @@ static Token *expand_id(Token * tline) /* * Expand indirect tokens, %[...]. Just like expand_smacro(), * 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) { @@ -3962,7 +3964,33 @@ static Token *expand_indirect(Token * tline, int level) 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); } } |