glsl/glcpp: Fix to emit spaces following directives
authorCarl Worth <cworth@cworth.org>
Mon, 28 Jul 2014 15:59:25 +0000 (08:59 -0700)
committerCarl Worth <cworth@cworth.org>
Tue, 29 Jul 2014 22:11:48 +0000 (15:11 -0700)
The glcpp lexer and parser use the space_tokens state bit to avoid emitting
tokens for spaces while parsing a directive. Previously, this bit was only
being set again by the first non-space token following a directive.

This led to a bug where a space, (or a comment that should emit a space),
immediately following a directive, (optionally searated by newlines), would be
omitted from the output.

Here we fix the bug by also setting the space_tokens bit whenever we lex a
newline in the standard start conditions.

src/glsl/glcpp/glcpp-lex.l
src/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected

index a1a8e76..cfb9f2a 100644 (file)
@@ -355,6 +355,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
        if (parser->commented_newlines) {
                BEGIN NEWLINE_CATCHUP;
        }
+       yyextra->space_tokens = 1;
        yyextra->lexing_directive = 0;
        yylineno++;
        yycolumn = 0;