Module: Mesa
Branch: master
Commit: a6e9cd14cad555520ad98213adf541a7687a7498
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6e9cd14cad555520ad98213adf541a7687a7498

Author: Anuj Phogat <[email protected]>
Date:   Fri Jun  6 16:56:59 2014 -0700

glsl/glcpp: Fix preprocessor error condition for macro redefinition

This patch specifically fixes redefinition condition for white space
changes. #define and #undef functionality in GLSL follows the standard
for C++ preprocessors for macro definitions.

>From https://gcc.gnu.org/onlinedocs/cpp/Undefining-and-Redefining-Macros.html:

These definitions are effectively the same:

     #define FOUR (2 + 2)
     #define FOUR         (2    +    2)
     #define FOUR (2 /* two */ + 2)

but these are not:

     #define FOUR (2 + 2)
     #define FOUR ( 2+2 )
     #define FOUR (2 * 2)
     #define FOUR(score,and,seven,years,ago) (2 + 2)

Fixes Khronos GLES3 CTS tests;
invalid_object_whitespace_vertex
invalid_object_whitespace_fragment

Signed-off-by: Anuj Phogat <[email protected]>
Reviewed-by: Carl Worth <[email protected]>

---

 src/glsl/glcpp/glcpp-parse.y |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 9d8b5bb..3fc8c86 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -939,14 +939,16 @@ _token_list_equal_ignoring_space (token_list_t *a, 
token_list_t *b)
 
                if (node_a == NULL || node_b == NULL)
                        return 0;
-
-               if (node_a->token->type == SPACE) {
-                       node_a = node_a->next;
-                       continue;
-               }
-
-               if (node_b->token->type == SPACE) {
-                       node_b = node_b->next;
+               /* Make sure whitespace appears in the same places in both.
+                * It need not be exactly the same amount of whitespace,
+                * though.
+                */
+               if (node_a->token->type == SPACE
+                   && node_b->token->type == SPACE) {
+                       while (node_a->token->type == SPACE)
+                               node_a = node_a->next;
+                       while (node_b->token->type == SPACE)
+                               node_b = node_b->next;
                        continue;
                }
 

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to