=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d: Handle lists in debug env vars consistently.
Alexandre Julliard
julliard at winehq.org
Fri May 17 15:56:03 CDT 2019
Module: vkd3d
Branch: master
Commit: 51b930192a58b0856546d15191fc2be13cfafeb2
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=51b930192a58b0856546d15191fc2be13cfafeb2
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Fri May 17 10:39:14 2019 +0200
vkd3d: Handle lists in debug env vars consistently.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
include/private/vkd3d_debug.h | 2 ++
libs/vkd3d-common/debug.c | 42 ++++++++++++++++++++++++------------------
libs/vkd3d/device.c | 7 +------
3 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/include/private/vkd3d_debug.h b/include/private/vkd3d_debug.h
index 80c5781..2ef8a00 100644
--- a/include/private/vkd3d_debug.h
+++ b/include/private/vkd3d_debug.h
@@ -22,6 +22,7 @@
#include "vkd3d_common.h"
#include <stdarg.h>
+#include <stdbool.h>
#include <stdint.h>
#ifdef VKD3D_NO_TRACE_MESSAGES
@@ -100,6 +101,7 @@ struct vkd3d_debug_option
uint64_t flag;
};
+bool vkd3d_debug_list_has_member(const char *string, const char *member) DECLSPEC_HIDDEN;
uint64_t vkd3d_parse_debug_options(const char *string,
const struct vkd3d_debug_option *options, unsigned int option_count) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-common/debug.c b/libs/vkd3d-common/debug.c
index 9a27c22..33deed6 100644
--- a/libs/vkd3d-common/debug.c
+++ b/libs/vkd3d-common/debug.c
@@ -323,34 +323,40 @@ static bool is_option_separator(char c)
return c == ',' || c == ';' || c == '\0';
}
+bool vkd3d_debug_list_has_member(const char *string, const char *member)
+{
+ char prev_char, next_char;
+ const char *p;
+
+ p = string;
+ while (p)
+ {
+ if ((p = strstr(p, member)))
+ {
+ prev_char = p > string ? p[-1] : 0;
+ p += strlen(member);
+ next_char = *p;
+
+ if (is_option_separator(prev_char) && is_option_separator(next_char))
+ return true;
+ }
+ }
+
+ return false;
+}
+
uint64_t vkd3d_parse_debug_options(const char *string,
const struct vkd3d_debug_option *options, unsigned int option_count)
{
- char prev_char, next_char;
uint64_t flags = 0;
unsigned int i;
- const char *p;
for (i = 0; i < option_count; ++i)
{
const struct vkd3d_debug_option *opt = &options[i];
- p = string;
- while (p)
- {
- if ((p = strstr(p, opt->name)))
- {
- prev_char = p > string ? p[-1] : 0;
- p += strlen(opt->name);
- next_char = *p;
-
- if (is_option_separator(prev_char) && is_option_separator(next_char))
- {
- flags |= opt->flag;
- break;
- }
- }
- }
+ if (vkd3d_debug_list_has_member(string, opt->name))
+ flags |= opt->flag;
}
return flags;
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 5c15808..5239911 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -180,16 +180,11 @@ static unsigned int get_spec_version(const VkExtensionProperties *extensions,
static bool is_extension_disabled(const char *extension_name)
{
const char *disabled_extensions;
- const char *s;
- size_t len;
if (!(disabled_extensions = getenv("VKD3D_DISABLE_EXTENSIONS")))
return false;
- if (!(s = strstr(disabled_extensions, extension_name)))
- return false;
- len = strlen(extension_name);
- return s[len] == ';' || s[len] == '\0';
+ return vkd3d_debug_list_has_member(disabled_extensions, extension_name);
}
static bool has_extension(const VkExtensionProperties *extensions,
More information about the wine-cvs
mailing list