Treat newlines as space when invoking a function-like macro invocation.
This adds three new pieces of state to the parser, (is_control_line,
newline_as_space, and paren_count), and a large amount of messy
code. I'd definitely like to see a cleaner solution for this.
With this fix, the "define-func-extra-newlines" now passes so we put
it back to test #26 where it was originally (lately it has been known
as test #55).
Also, we tweak test 25 slightly. Previously this test was ending a
file function-like macro name that was not actually a macro (not
followed by a left parenthesis). As is, this fix was making that test
fail because the text_line production expects to see a terminating
NEWLINE, but that NEWLINE is now getting turned into a SPACE here.
This seems unlikely to be a problem in the wild, (function macros
being used in a non-macro sense seems rare enough---but more than
likely they won't happen at the end of a file). Still, we document
this shortcoming in the README.
diff --git a/glcpp.h b/glcpp.h
index e5be1a6..5c8c304 100644
--- a/glcpp.h
+++ b/glcpp.h
@@ -128,6 +128,9 @@
struct hash_table *defines;
string_list_t *active;
int space_tokens;
+ int newline_as_space;
+ int in_control_line;
+ int paren_count;
skip_node_t *skip_stack;
token_list_t *lex_from_list;
token_node_t *lex_from_node;