Mesa (master): meson/xmlconfig: win32 regex fallback

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 25 14:23:54 UTC 2021


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

Author: Michel Zou <xantares09 at hotmail.com>
Date:   Wed Feb 24 20:28:38 2021 +0100

meson/xmlconfig: win32 regex fallback

xmlconfig now uses regex fonctions even without xml support

Fixes: c83400e6
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9261>

---

 meson.build          |  9 +++++++++
 src/util/meson.build |  1 +
 src/util/xmlconfig.c | 12 +++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 142f3839e91..d6ea2c18c37 100644
--- a/meson.build
+++ b/meson.build
@@ -1424,6 +1424,15 @@ endif
 # it's not linux and wont
 dep_m = cc.find_library('m', required : false)
 
+if host_machine.system() == 'windows'
+  dep_regex = meson.get_compiler('c').find_library('regex', required : false)
+  if not dep_regex.found()
+    dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
+  endif
+else
+  dep_regex = null_dep
+endif
+
 if with_platform_haiku
   dep_network = cc.find_library('network')
 endif
diff --git a/src/util/meson.build b/src/util/meson.build
index 00782d62433..7e7c25c5711 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -221,6 +221,7 @@ xmlconfig_deps = []
 if not (with_platform_android or with_platform_windows)
   xmlconfig_deps += dep_expat
 endif
+xmlconfig_deps += dep_regex
 
 _libxmlconfig = static_library(
   'xmlconfig',
diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index c322d6dfb2e..a3c6429205d 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -43,7 +43,17 @@
 #include <dirent.h>
 #include <sys/stat.h>
 #endif
+#ifdef NO_REGEX
+typedef int regex_t;
+#define REG_EXTENDED 0
+#define REG_NOSUB 0
+#define REG_NOMATCH 1
+inline int regcomp(regex_t *r, const char *s, int f) { return 0; }
+inline int regexec(regex_t *r, const char *s, int n, void *p, int f) { return REG_NOMATCH; }
+inline void regfree(regex_t* r) {}
+#else
 #include <regex.h>
+#endif
 #include <fcntl.h>
 #include <math.h>
 #include "strndup.h"
@@ -1153,7 +1163,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
    userData.applicationVersion = applicationVersion;
    userData.engineName = engineName ? engineName : "";
    userData.engineVersion = engineVersion;
-   userData.execName = execname ?: util_get_process_name();
+   userData.execName = execname ? execname : util_get_process_name();
 
 #if WITH_XMLCONFIG
    char *home;



More information about the mesa-commit mailing list