From ec88c1beac003bd6660037da3cef3aebeee7af20 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Wed, 2 Jun 2010 00:59:21 +0400 Subject: [PATCH] BR3005117: Expland local single macro before pasting tokens When we have switched to unified token pasting code we loose backward compatibility. Restore it. Note that new code MUST not expluatate this facility but rather use paste macro %+ explicitly. N.B. this patch is probably the candidate for revert, though to give it a chance I commit it. Reported-by: Alexey Dokuchaev Signed-off-by: Cyrill Gorcunov --- preproc.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/preproc.c b/preproc.c index ac6c1f91..86366ed4 100644 --- a/preproc.c +++ b/preproc.c @@ -3742,6 +3742,32 @@ static Token *expand_mmac_params(Token * tline) } delete_Token(t); changed = true; + } else if (tline->type == TOK_PREPROC_ID && + tline->text[0] == '%' && tline->text[1] == '$' && + (tok_type_(tline->next, TOK_ID) || + tok_type_(tline->next, TOK_PREPROC_ID) || + tok_type_(tline->next, TOK_NUMBER) || + tok_type_(tline->next, TOK_FLOAT))) { + /* + * In a sake of backward compatibility we allow + * to expand local single macro that early before + * pasting token code have place + * + * NOTE: that new code MUST use %+ macro to obtain + * same result + */ + t = tline; + tline = tline->next; + tt = tokenize(t->text); + tt = expand_smacro(tt); + *tail = tt; + while (tt) { + tt->a.mac = NULL; + tail = &tt->next; + tt = tt->next; + } + delete_Token(t); + changed = true; } else { t = *tail = tline; tline = tline->next;