diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-07-10 17:22:47 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-07-10 17:22:47 -0700 |
commit | fcd3cb88615a200fbee85e5906e37e265a8d297d (patch) | |
tree | bbde27d993ca40ff330530114f5cc458f347cf07 | |
parent | a79a700208d771fb3b8e6e7f03fcc195c2d1831c (diff) | |
download | nasm-fcd3cb88615a200fbee85e5906e37e265a8d297d.tar.gz |
preproc: preserve %[...] in listings
When generating list output, preserve %[...] in the output if we list
a TOK_INDIRECT. The tokenization process removes these deliminators,
so we have to explicitly put them back.
This doesn't affect assembly output, which will only ever be generated
after all TOK_INDIRECT tokens have been removed, but it does affect
some of the listing modes.
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r-- | asm/preproc.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/asm/preproc.c b/asm/preproc.c index ccb00f3b..693cbcbb 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -2000,6 +2000,16 @@ static char *detoken(Token * tlist, bool expand_locals) } break; + case TOK_INDIRECT: + /* + * This won't happen in when emitting to the assembler, + * but can happen when emitting output for some of the + * list options. The token string doesn't actually include + * the brackets in this case. + */ + len += 3; /* %[] */ + break; + default: break; /* No modifications */ } @@ -2019,8 +2029,19 @@ static char *detoken(Token * tlist, bool expand_locals) p = line = nasm_malloc(len + 1); - list_for_each(t, tlist) - p = mempcpy(p, tok_text(t), t->len); + list_for_each(t, tlist) { + switch (t->type) { + case TOK_INDIRECT: + *p++ = '%'; + *p++ = '['; + p = mempcpy(p, tok_text(t), t->len); + *p++ = ']'; + break; + + default: + p = mempcpy(p, tok_text(t), t->len); + } + } *p = '\0'; return line; |