From c2d021e2f3554ea48728f6a3e0422167df4609c7 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 24 Mar 2003 00:48:59 -0700 Subject: [PATCH] =?utf8?q?Don't=20expand=20arguments=20that=20are=20preced?= =?utf8?q?ed=20by=20'#'=20or=20preceded=20or=20followed=20by=20'##'=20(ANS?= =?utf8?q?I=20C=20-=20Appending=20A=20=A712.3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- pre-process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pre-process.c b/pre-process.c index 3b7cfb47..5130c4a6 100644 --- a/pre-process.c +++ b/pre-process.c @@ -161,7 +161,7 @@ static void insert(struct token *token, struct token *prev) prev->next = token; } -static void replace(struct token *token, struct token *prev, struct token *list) +static struct token * replace(struct token *token, struct token *prev, struct token *list) { int newline = token->newline; @@ -173,6 +173,7 @@ static void replace(struct token *token, struct token *prev, struct token *list) prev = newtok; list = list->next; } + return prev; } static struct token *get_argument(int nr, struct token *args) @@ -224,6 +225,7 @@ static struct token *expand_one_arg(struct token *head, struct token *token, struct token *arglist, struct token *arguments) { int nr = arg_number(arglist, token->ident); + struct token *orig_head = head; if (nr >= 0) { struct token *arg = get_argument(nr, arguments); @@ -239,8 +241,9 @@ static struct token *expand_one_arg(struct token *head, struct token *token, empty_arg_token.next = &eof_token_entry; } - replace(token, head, arg); - head = expand_list(head); + head = replace(token, head, arg); + if (!match_op(orig_head, SPECIAL_HASHHASH) && !match_op(last, SPECIAL_HASHHASH) && !match_op(orig_head, '#')) + head = expand_list(orig_head); head->next = last; return head; } -- 2.11.4.GIT