util: Split the pack/unpack functions out of the format desc.
[mesa.git] / src / util / debug.c
index 2773b55cc4d4a801441742a4107c4434fb94a72b..89ae61310746455ecb037a6a0dda837eb320c223 100644 (file)
@@ -23,8 +23,8 @@
 
 #include <errno.h>
 #include <string.h>
-#include "main/macros.h"
 #include "debug.h"
+#include "u_string.h"
 
 uint64_t
 parse_debug_string(const char *debug,
@@ -53,6 +53,20 @@ parse_debug_string(const char *debug,
    return flag;
 }
 
+bool
+comma_separated_list_contains(const char *list, const char *s)
+{
+   assert(list);
+   const size_t len = strlen(s);
+
+   for (unsigned n; n = strcspn(list, ","), *list; list += MAX2(1, n)) {
+      if (n == len && !strncmp(list, s, n))
+         return true;
+   }
+
+   return false;
+}
+
 /**
  * Reads an environment variable and interprets its value as a boolean.
  *
@@ -67,10 +81,12 @@ env_var_as_boolean(const char *var_name, bool default_value)
 
    if (strcmp(str, "1") == 0 ||
        strcasecmp(str, "true") == 0 ||
+       strcasecmp(str, "y") == 0 ||
        strcasecmp(str, "yes") == 0) {
       return true;
    } else if (strcmp(str, "0") == 0 ||
               strcasecmp(str, "false") == 0 ||
+              strcasecmp(str, "n") == 0 ||
               strcasecmp(str, "no") == 0) {
       return false;
    } else {