Merge branch 'nasm-2.09.xx'

This commit is contained in:
H. Peter Anvin 2010-09-15 08:59:51 -07:00
commit c1ade75944
2 changed files with 29 additions and 1 deletions

View File

@ -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.

View File

@ -487,6 +487,24 @@ static size_t nasm_unquote_cstr(char *qstr, enum preproc_token directive)
return clen;
}
/*
* 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
@ -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