diff options
author | H. Peter Anvin <hpa@zytor.com> | 2019-08-10 06:42:55 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2019-08-10 06:42:55 -0700 |
commit | 06335873ae360054ae08c67762cbe3d8ee9ca489 (patch) | |
tree | 3ce68a8d8f88190bf060c0d582d6661211319245 | |
parent | f5d7d90148a9a162d956fd3d7d63fdbff3625f7f (diff) | |
download | nasm-06335873ae360054ae08c67762cbe3d8ee9ca489.tar.gz nasm-06335873ae360054ae08c67762cbe3d8ee9ca489.tar.xz nasm-06335873ae360054ae08c67762cbe3d8ee9ca489.zip |
preproc: avoid dropping the facility name in %pragma
tline got advanced a token too far, with the obvious results that the
facility name got truncated. Skip whitespace *after* expand_smacro(),
not before.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | asm/preproc.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/asm/preproc.c b/asm/preproc.c index 5d95f74a..51b6b33d 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -2519,25 +2519,33 @@ static int do_directive(Token *tline, Token **output) * Invalid %pragmas are ignored and may have different * meaning in future versions of NASM. */ - tline = tline->next; - skip_white_(tline); t = tline; tline = tline->next; t->next = NULL; tline = expand_smacro(tline); + while (tok_type_(tline, TOK_WHITESPACE)) { + t = tline; + tline = tline->next; + delete_Token(t); + } if (tok_type_(tline, TOK_ID)) { if (!nasm_stricmp(tline->text, "preproc")) { /* Preprocessor pragma */ do_pragma_preproc(tline); + free_tlist(tline); } else { /* Build the assembler directive */ - t = new_Token(NULL, TOK_OTHER, "[", 1); - t->next = new_Token(NULL, TOK_ID, "pragma", 6); - t->next->next = new_Token(tline, TOK_WHITESPACE, NULL, 0); - tline = t; + + /* Append bracket to the end of the output */ for (t = tline; t->next; t = t->next) ; t->next = new_Token(NULL, TOK_OTHER, "]", 1); + + /* Prepend "[pragma " */ + t = new_Token(tline, TOK_WHITESPACE, NULL, 0); + t = new_Token(t, TOK_ID, "pragma", 6); + t = new_Token(t, TOK_OTHER, "[", 1); + tline = t; *output = tline; } } |