diff mbox series

[3/9] pre-process: suppress trailing space when dumping macros

Message ID 85a62d44-a351-4250-e88c-7efe0104b0f0@ramsayjones.plus.com (mailing list archive)
State Mainlined, archived
Headers show
Series misc sparse patches | expand

Commit Message

Ramsay Jones Nov. 19, 2018, 8:48 p.m. UTC
The dump_macro() function outputs a trailing space character for every
macro. This makes comparing the '-dD' output from sparse to the similar
output from gcc somewhat annoying. The space character arises from the
presence of an <untaint> token directly before the <eof> token in the
macro definition token list. The <untaint> token seems to always have
the 'whitespace' flag set, which results in the output of a space in
order to separate it from the current token.

In order to suppress the unwanted space character, check if the next
token is an <untaint> token and, if so, don't print the space.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 pre-process.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/pre-process.c b/pre-process.c
index bf4b8e7..8abd5e6 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -2201,6 +2201,8 @@  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(' ');
 		}