glcpp: Reject #version and #line not followed by whitespace
authorMatt Turner <mattst88@gmail.com>
Wed, 21 Nov 2012 01:23:42 +0000 (17:23 -0800)
committerMatt Turner <mattst88@gmail.com>
Wed, 28 Nov 2012 18:26:53 +0000 (10:26 -0800)
Fixes part of es3conform's preprocess16_frag test.
Reviewed-by: Carl Worth <cworth@cworth.org>
src/glsl/glcpp/glcpp-lex.l
src/glsl/glcpp/tests/108-no-space-after-hash-version.c [new file with mode: 0644]
src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected [new file with mode: 0644]
src/glsl/glcpp/tests/109-no-space-after-hash-line.c [new file with mode: 0644]
src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected [new file with mode: 0644]

index 783c545495e3848ed13175600a968c2bde89bc91..4f0dd34d30da59d9f60b5b6bcbbadea62546092e 100644 (file)
@@ -120,7 +120,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
                return SPACE;
 }
 
-{HASH}version {
+{HASH}version{HSPACE}+ {
        yylval->str = ralloc_strdup (yyextra, yytext);
        yyextra->space_tokens = 0;
        return HASH_VERSION;
@@ -135,7 +135,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
        return OTHER;
 }
 
-{HASH}line {
+{HASH}line{HSPACE}+ {
        return HASH_LINE;
 }
 
diff --git a/src/glsl/glcpp/tests/108-no-space-after-hash-version.c b/src/glsl/glcpp/tests/108-no-space-after-hash-version.c
new file mode 100644 (file)
index 0000000..0ce36f2
--- /dev/null
@@ -0,0 +1 @@
+#version110
diff --git a/src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected b/src/glsl/glcpp/tests/108-no-space-after-hash-version.c.expected
new file mode 100644 (file)
index 0000000..da4544a
--- /dev/null
@@ -0,0 +1,2 @@
+0:1(3): preprocessor error: Invalid tokens after #
+
diff --git a/src/glsl/glcpp/tests/109-no-space-after-hash-line.c b/src/glsl/glcpp/tests/109-no-space-after-hash-line.c
new file mode 100644 (file)
index 0000000..f52966a
--- /dev/null
@@ -0,0 +1 @@
+#line2
diff --git a/src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected b/src/glsl/glcpp/tests/109-no-space-after-hash-line.c.expected
new file mode 100644 (file)
index 0000000..da4544a
--- /dev/null
@@ -0,0 +1,2 @@
+0:1(3): preprocessor error: Invalid tokens after #
+