util/format: remove left-over util_format_description_table declaration
[mesa.git] / src / util / xmlconfig.c
index 4b77ea7624f6b96345f8eec9785f60faf76fa885..b036145269e8fc9d67ad565b7f327037abb9dd71 100644 (file)
@@ -43,6 +43,7 @@
 #include <dirent.h>
 #include <fnmatch.h>
 #include <regex.h>
+#include "strndup.h"
 #include "xmlconfig.h"
 #include "u_process.h"
 
 #define PATH_MAX 4096
 #endif
 
+static bool
+be_verbose(void)
+{
+   const char *s = getenv("MESA_DEBUG");
+   if (!s)
+      return true;
+
+   return strstr(s, "silent") == NULL;
+}
+
 /** \brief Find an option in an option cache with the name as key */
 static uint32_t
 findOption(const driOptionCache *cache, const char *name)
@@ -547,9 +558,11 @@ parseOptInfoAttr(struct OptInfoData *data, const XML_Char **attr)
     defaultVal = getenv (cache->info[opt].name);
     if (defaultVal != NULL) {
       /* don't use XML_WARNING, we want the user to see this! */
-        fprintf (stderr,
-                 "ATTENTION: default value of option %s overridden by environment.\n",
-                 cache->info[opt].name);
+        if (be_verbose()) {
+            fprintf(stderr,
+                    "ATTENTION: default value of option %s overridden by environment.\n",
+                    cache->info[opt].name);
+        }
     } else
         defaultVal = attrVal[OA_DEFAULT];
     if (!parseValue (&cache->values[opt], cache->info[opt].type, defaultVal))
@@ -794,7 +807,7 @@ parseEngineAttr(struct OptConfData *data, const XML_Char **attr)
     if (engine_name_match) {
        regex_t re;
 
-       if (regcomp (&re, engine_name_match, REG_EXTENDED|REG_NOSUB) != 0) {
+       if (regcomp (&re, engine_name_match, REG_EXTENDED|REG_NOSUB) == 0) {
           if (regexec (&re, data->engineName, 0, NULL, 0) == REG_NOMATCH)
              data->ignoringApp = data->inApp;
           regfree (&re);
@@ -830,11 +843,14 @@ parseOptConfAttr(struct OptConfData *data, const XML_Char **attr)
             /* don't use XML_WARNING, drirc defines options for all drivers,
              * but not all drivers support them */
             return;
-        else if (getenv (cache->info[opt].name))
+        else if (getenv (cache->info[opt].name)) {
           /* don't use XML_WARNING, we want the user to see this! */
-            fprintf (stderr, "ATTENTION: option value of option %s ignored.\n",
-                     cache->info[opt].name);
-        else if (!parseValue (&cache->values[opt], cache->info[opt].type, value))
+            if (be_verbose()) {
+                fprintf(stderr,
+                        "ATTENTION: option value of option %s ignored.\n",
+                        cache->info[opt].name);
+            }
+        } else if (!parseValue (&cache->values[opt], cache->info[opt].type, value))
             XML_WARNING ("illegal option value: %s.", value);
     }
 }