[cogl] cogl-blend-string: Fix TEXTURE_N sources



commit 92704124957af137d0afbeeebc3884399b2405f9
Author: Neil Roberts <neil linux intel com>
Date:   Thu Aug 4 19:04:11 2011 +0100

    cogl-blend-string: Fix TEXTURE_N sources
    
    The parser couldn't cope with TEXTURE_N source arguments because the
    sources are checked in turn to find one that matches the beginning of
    the argument. The TEXTURE_N source was checked last so it would end up
    matching the regular 'TEXTURE' source and then the parser would choke
    when it tries to parse the trailing parts.
    
    This patch just moves the check for TEXTURE_ to the top. It also also
    changes it so that the argument only needs to be at least 8 characters
    long instead of 9. This is necessary because the parser doesn't
    consider the digits to be part of the name of the argument so while we
    are parsing 'TEXTURE_0' the length is only 8.
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/cogl-blend-string.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl-blend-string.c b/cogl/cogl-blend-string.c
index 1eb2a80..92c4cb1 100644
--- a/cogl/cogl-blend-string.c
+++ b/cogl/cogl-blend-string.c
@@ -439,6 +439,13 @@ get_color_src_info (const char *mark,
       array_len = G_N_ELEMENTS (tex_combine_color_sources);
     }
 
+  if (len >= 8 &&
+      strncmp (mark, "TEXTURE_", 8) == 0 &&
+      g_ascii_isdigit (mark[8]))
+    {
+      return &tex_combine_texture_n_color_source;
+    }
+
   for (i = 0; i < array_len; i++)
     {
       if (len >= sources[i].name_len
@@ -446,13 +453,6 @@ get_color_src_info (const char *mark,
         return &sources[i];
     }
 
-  if (len >= 9 &&
-      strncmp (mark, "TEXTURE_", 8) == 0 &&
-      g_ascii_isdigit (mark[8]))
-    {
-      return &tex_combine_texture_n_color_source;
-    }
-
   return NULL;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]