Using alternatives with multiple characters in a lookahead pattern
appears to cause Flex to write past the end of an internal state array.

We don't actually need to do that - we can just make our empty pragma
rule eat the NEWLINE and return it, rather than ensuring one exists but
leaving it as the next thing to be processed.

Fixes Piglit's 16385-consecutive-chars and
17000-consecutive-chars-identifier tests.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82472
Signed-off-by: Kenneth Graunke <kenn...@whitecape.org>
Cc: Carl Worth <cwo...@cworth.org>
---
 src/glsl/glcpp/glcpp-lex.l | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 98d500e..eac41c8 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -290,8 +290,9 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
 
        /* Swallow empty #pragma directives, (to avoid confusing the
         * downstream compiler). */
-<HASH>pragma{HSPACE}*/{NEWLINE} {
+<HASH>pragma{HSPACE}*{NEWLINE} {
        BEGIN INITIAL;
+       RETURN_TOKEN_NEVER_SKIP (NEWLINE);
 }
 
        /* glcpp doesn't handle #extension, #version, or #pragma directives.
-- 
2.0.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to