summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2013-11-09 12:02:15 +0400
committerCyrill Gorcunov <gorcunov@gmail.com>2013-11-09 12:08:41 +0400
commite75331cc097fd45e6d8408204a0eee8db661754d (patch)
tree03acc7260323c627de43e0e6060d4578100a841a
parentc6c750cb3ddd094fa8195cdcd6d5c8c1d1d02d60 (diff)
downloadnasm-e75331cc097fd45e6d8408204a0eee8db661754d.tar.gz
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>
-rw-r--r--preproc.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/preproc.c b/preproc.c
index b878e4b1..f781f956 100644
--- a/preproc.c
+++ b/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;
+ }
}
}