summaryrefslogtreecommitdiff
path: root/glcpp-parse.y
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-20 14:38:06 -0700
committerCarl Worth <cworth@cworth.org>2010-05-20 14:38:06 -0700
commit876e510bdab96574c4ca5ee94c580fe6ad7f0106 (patch)
tree0610132017e3746eeb4be1857581127b1281466f /glcpp-parse.y
parent5a6b9a27fdb2ac66aaadd90b15b1889fea8f08d0 (diff)
Finish cleaning up whitespace differences.
The last remaining thing here was that when a line ended with a macro, and the parser looked ahead to the newline token, the lexer was printing that newline before the parser printed the expansion of the macro. The fix is simple, just make the lexer tell the parser that a newline is needed, and the parser can wait until reducing a production to print that newline. With this, we now pass the entire test suite with simply "diff -u", so we no longer have any diff options hiding whitespace bugs from us. Hurrah!
Diffstat (limited to 'glcpp-parse.y')
-rw-r--r--glcpp-parse.y9
1 files changed, 9 insertions, 0 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y
index 93713a3..ddc2a25 100644
--- a/glcpp-parse.y
+++ b/glcpp-parse.y
@@ -171,6 +171,12 @@ input:
if ($2)
talloc_free ($2);
+
+ if (parser->need_newline) {
+ printf ("\n");
+ parser->just_printed_separator = 1;
+ parser->need_newline = 0;
+ }
}
;
@@ -564,6 +570,7 @@ glcpp_parser_create (void)
parser->expansions = NULL;
parser->just_printed_separator = 1;
+ parser->need_newline = 0;
return parser;
}
@@ -577,6 +584,8 @@ glcpp_parser_parse (glcpp_parser_t *parser)
void
glcpp_parser_destroy (glcpp_parser_t *parser)
{
+ if (parser->need_newline)
+ printf ("\n");
glcpp_lex_destroy (parser->scanner);
hash_table_dtor (parser->defines);
talloc_free (parser);