summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2012-02-27 11:11:33 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2012-02-27 11:12:06 +0400
commit99a055add917fe954038885d9013f8968f76790c (patch)
treec9e8f4fd0c7fcc8d6842cd91aff7c55eca0d3284
parentbd8cef73d1ccf2cc75aa38116e78adb37ed66274 (diff)
downloadnasm-99a055add917fe954038885d9013f8968f76790c.tar.gz
BR3392200: preproc - Fix dangling paste term
In case if there a production {tok},{%+},{whitespace}* the preprocessor does not delete ending paste+spaces tokens. Fix it. http://bugzilla.nasm.us/show_bug.cgi?id=3392200 Reported-by: KO Myung-Hun <komh@chollian.net> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--preproc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/preproc.c b/preproc.c
index b21335e9..49277729 100644
--- a/preproc.c
+++ b/preproc.c
@@ -4026,6 +4026,9 @@ static bool paste_tokens(Token **head, const struct tokseq_match *m,
char *tmp;
int i;
+ nasm_dump_stream(*head);
+ nasm_dump_token(*head);
+
/* Now handle token pasting... */
paste_head = NULL;
tail = head;
@@ -4046,8 +4049,13 @@ static bool paste_tokens(Token **head, const struct tokseq_match *m,
while (t && (t->type == TOK_WHITESPACE ||
t->type == TOK_PASTE))
t = *tail = delete_Token(t);
- if (!paste_head || !t)
- break; /* Nothing to paste with */
+ if (!t) { /* Dangling %+ term */
+ if (paste_head)
+ (*paste_head)->next = NULL;
+ else
+ *head = NULL;
+ return did_paste;
+ }
tail = paste_head;
t = *tail;
tt = t->next;