diff mbox series

[2/2] dump-macro: simplify processing of whitespace

Message ID 20181124233937.27702-3-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series simplify processing of whitespaces in dump_macro() | expand

Commit Message

Luc Van Oostenryck Nov. 24, 2018, 11:39 p.m. UTC
When dumping the macros, two special cases are needed
regarding whitespace:
* just before the macro body
* just after the macro body.
This is caused in parts because some misunderstanding
about the role of TOKEN_UNTAINT.

Happily, things can be simplified, which is what is
done in this patch.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 pre-process.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/pre-process.c b/pre-process.c
index 1b3fdc2f9..f5b25d54d 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -2197,14 +2197,15 @@  static void dump_macro(struct symbol *sym)
 		}
 		putchar(')');
 	}
-	putchar(' ');
 
 	token = sym->expansion;
 	while (token_type(token) != TOKEN_UNTAINT) {
 		struct token *next = token->next;
+		if (token->pos.whitespace)
+			putchar(' ');
 		switch (token_type(token)) {
 		case TOKEN_CONCAT:
-			printf("## ");
+			printf("##");
 			break;
 		case TOKEN_STR_ARGUMENT:
 			printf("#");
@@ -2215,10 +2216,6 @@  static void dump_macro(struct symbol *sym)
 			/* fall-through */
 		default:
 			printf("%s", show_token(token));
-			if (token_type(next) == TOKEN_UNTAINT)
-				break;
-			if (next->pos.whitespace)
-				putchar(' ');
 		}
 		token = next;
 	}