mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
preproc: reverse the order of the tokens in %deftok
Smacros are apparently stored with the token stream reversed, so make sure %deftok matches that sense of relatity. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
e6e6a9ae2c
commit
b40992c929
25
preproc.c
25
preproc.c
@ -487,6 +487,24 @@ static size_t nasm_unquote_cstr(char *qstr, enum preproc_token directive)
|
|||||||
return clen;
|
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
|
* Handle TASM specific directives, which do not contain a % in
|
||||||
* front of them. We do it here because I could not find any other
|
* front of them. We do it here because I could not find any other
|
||||||
@ -3186,8 +3204,13 @@ issue_error:
|
|||||||
return DIRECTIVE_FOUND;
|
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);
|
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
|
* We now have a macro name, an implicit parameter count of
|
||||||
|
Loading…
Reference in New Issue
Block a user