From: nasm-bot f. C. G. <gor...@gm...> - 2013-11-09 08:06:23
|
Commit-ID: c0ce79133c78a013adcdc9bd76c03c1822ed683e Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=c0ce79133c78a013adcdc9bd76c03c1822ed683e Author: Cyrill Gorcunov <gor...@gm...> AuthorDate: Sat, 9 Nov 2013 12:02:15 +0400 Committer: Cyrill Gorcunov <gor...@gm...> CommitDate: Sat, 9 Nov 2013 12:03:11 +0400 BR3392270: preproc: Handle all token chains in mmacro params range A typical example is --- preproc.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/preproc.c b/preproc.c index b878e4b..f781f95 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; + } } } |