From da7f226a2711450bf92dcc9e2e1e1052111683ff Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 28 Jul 2014 08:59:25 -0700 Subject: [PATCH] glsl/glcpp: Fix to emit spaces following directives 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 | 1 + .../glcpp/tests/125-es-short-circuit-undefined.c.expected | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index a1a8e76af0a..cfb9f2a18be 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -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; diff --git a/src/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected b/src/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected index 93bcffb47c8..ce5c102ed33 100644 --- a/src/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected +++ b/src/glsl/glcpp/tests/125-es-short-circuit-undefined.c.expected @@ -8,6 +8,7 @@ #version 300 es + @@ -15,8 +16,7 @@ - - + Success -- 2.30.2