diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-09-15 08:59:51 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-09-15 08:59:51 -0700 |
commit | c1ade75944f36c103ffe0e07eab0727fe1b303ca (patch) | |
tree | f9835176937324614c70a8d34894418269fc0b81 | |
parent | 84b4cbab54f6cb1712dc02f902af1620a598bca6 (diff) | |
parent | 2c11f97ca88f4f9b5494f6a8a24b5eb925275817 (diff) | |
download | nasm-c1ade75944f36c103ffe0e07eab0727fe1b303ca.tar.gz |
Merge branch 'nasm-2.09.xx'
-rw-r--r-- | doc/changes.src | 5 | ||||
-rw-r--r-- | preproc.c | 25 |
2 files changed, 29 insertions, 1 deletions
diff --git a/doc/changes.src b/doc/changes.src index cc9349ee..e1b0d955 100644 --- a/doc/changes.src +++ b/doc/changes.src @@ -19,6 +19,11 @@ since 2007. To force a specific form, use the \c{STRICT} keyword, see \k{strict}. +\S{cl-2.09.02} Version 2.09.02 + +\b Fix reversed tokens when \c{%deftok} produces more than one output token. + + \S{cl-2.09.01} Version 2.09.01 \b Fix NULL dereference on missed %deftok second parameter. @@ -488,6 +488,24 @@ static size_t nasm_unquote_cstr(char *qstr, enum preproc_token directive) } /* + * In-place reverse a list of tokens. + */ +static Token *reverse_tokens(Token *t) +{ + Token *prev = NULL; + Token *next; + + while (t) { + next = t->next; + t->next = prev; + prev = t; + t = next; + } + + return prev; +} + +/* * Handle TASM specific directives, which do not contain a % in * front of them. We do it here because I could not find any other * place to do it for the moment, and it is a hack (ideally it would @@ -3185,8 +3203,13 @@ issue_error: return DIRECTIVE_FOUND; } + /* + * Convert the string to a token stream. Note that smacros + * are stored with the token stream reversed, so we have to + * reverse the output of tokenize(). + */ nasm_unquote_cstr(t->text, i); - macro_start = tokenize(t->text); + macro_start = reverse_tokens(tokenize(t->text)); /* * We now have a macro name, an implicit parameter count of |