mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-13 17:57:12 +08:00
BR3392270: preproc: Handle all token chains in mmacro params range
A typical example is | | %macro m0 0-* | %rep %0 | m0 arg is %1 | %rotate 1 | %endrep | %endmacro | | %macro m1 0-* | m0 %{1:-1} | %endmacro | | m1 a=b, c=d If passed with nasm -E the output must be like m0 arg is a=b m0 arg is c=d http://bugzilla.nasm.us/show_bug.cgi?id=3392270 Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
c6c750cb3d
commit
e75331cc09
25
preproc.c
25
preproc.c
@ -3799,19 +3799,28 @@ static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last)
|
||||
fst--, lst--;
|
||||
|
||||
/*
|
||||
* it will be at least one token
|
||||
* It will be at least one token. Note we
|
||||
* need to scan params until separator, otherwise
|
||||
* only first token will be passed.
|
||||
*/
|
||||
tm = mac->params[(fst + mac->rotate) % mac->nparam];
|
||||
t = new_Token(NULL, tm->type, tm->text, 0);
|
||||
head = t, tt = &t->next;
|
||||
head = new_Token(NULL, tm->type, tm->text, 0);
|
||||
tt = &head->next, tm = tm->next;
|
||||
while (tok_isnt_(tm, ",")) {
|
||||
t = new_Token(NULL, tm->type, tm->text, 0);
|
||||
*tt = t, tt = &t->next, tm = tm->next;
|
||||
}
|
||||
|
||||
if (fst < lst) {
|
||||
for (i = fst + 1; i <= lst; i++) {
|
||||
t = new_Token(NULL, TOK_OTHER, ",", 0);
|
||||
*tt = t, tt = &t->next;
|
||||
j = (i + mac->rotate) % mac->nparam;
|
||||
tm = mac->params[j];
|
||||
t = new_Token(NULL, tm->type, tm->text, 0);
|
||||
*tt = t, tt = &t->next;
|
||||
while (tok_isnt_(tm, ",")) {
|
||||
t = new_Token(NULL, tm->type, tm->text, 0);
|
||||
*tt = t, tt = &t->next, tm = tm->next;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = fst - 1; i >= lst; i--) {
|
||||
@ -3819,8 +3828,10 @@ static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last)
|
||||
*tt = t, tt = &t->next;
|
||||
j = (i + mac->rotate) % mac->nparam;
|
||||
tm = mac->params[j];
|
||||
t = new_Token(NULL, tm->type, tm->text, 0);
|
||||
*tt = t, tt = &t->next;
|
||||
while (tok_isnt_(tm, ",")) {
|
||||
t = new_Token(NULL, tm->type, tm->text, 0);
|
||||
*tt = t, tt = &t->next, tm = tm->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user