dri/common: Tokenize driParseDebugString() argument before matching debug flags.
authorFrancisco Jerez <currojerez@riseup.net>
Thu, 3 Sep 2015 12:20:04 +0000 (15:20 +0300)
committerIago Toral Quiroga <itoral@igalia.com>
Fri, 4 Sep 2015 10:49:36 +0000 (12:49 +0200)
Fixes debug string parsing when one of the supported flags is a
substring of another.

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
src/mesa/drivers/dri/common/utils.c

index 1e3b15b..1246bec 100644 (file)
@@ -50,10 +50,19 @@ driParseDebugString(const char *debug,
 
    if (debug != NULL) {
       for (; control->string != NULL; control++) {
-        if (!strcmp(debug, "all") ||
-            strstr(debug, control->string) != NULL) {
-           flag |= control->flag;
-        }
+         if (!strcmp(debug, "all")) {
+            flag |= control->flag;
+
+         } else {
+            const char *s = debug;
+            unsigned n;
+
+            for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
+               if (strlen(control->string) == n &&
+                   !strncmp(control->string, s, n))
+                  flag |= control->flag;
+            }
+         }
       }
    }