=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d-shader: Use locale-insensitive string comparison.

Alexandre Julliard julliard at winehq.org
Wed May 1 15:58:16 CDT 2019


Module: vkd3d
Branch: master
Commit: df7274672975688f6034a8d9a17a9018289a5ea5
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=df7274672975688f6034a8d9a17a9018289a5ea5

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Tue Apr 30 14:33:48 2019 +0200

vkd3d-shader: Use locale-insensitive string comparison.

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_common.h        | 23 +++++++++++++++++++++++
 libs/vkd3d-shader/spirv.c             |  2 +-
 libs/vkd3d-shader/vkd3d_shader_main.c |  2 +-
 tests/vkd3d_shader_api.c              |  6 +++++-
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h
index 1129f1e..2442092 100644
--- a/include/private/vkd3d_common.h
+++ b/include/private/vkd3d_common.h
@@ -88,6 +88,29 @@ static inline unsigned int vkd3d_log2i(unsigned int x)
 #endif
 }
 
+static inline int ascii_isupper(int c)
+{
+    return 'A' <= c && c <= 'Z';
+}
+
+static inline int ascii_tolower(int c)
+{
+    return ascii_isupper(c) ? c - 'A' + 'a' : c;
+}
+
+static inline int ascii_strcasecmp(const char *a, const char *b)
+{
+    int c_a, c_b;
+
+    do
+    {
+        c_a = ascii_tolower(*a++);
+        c_b = ascii_tolower(*b++);
+    } while (c_a == c_b && c_a != '\0');
+
+    return c_a - c_b;
+}
+
 #ifndef _WIN32
 # if HAVE_SYNC_ADD_AND_FETCH
 static inline LONG InterlockedIncrement(LONG volatile *x)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index ad927b2..dc51644 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -3709,7 +3709,7 @@ static void vkd3d_dxbc_compiler_decorate_xfb_output(struct vkd3d_dxbc_compiler *
         const struct vkd3d_shader_transform_feedback_element *e = &xfb_info->elements[i];
 
         if (e->stream_index == signature_element->stream_index
-                && !strcasecmp(e->semantic_name, signature_element->semantic_name)
+                && !ascii_strcasecmp(e->semantic_name, signature_element->semantic_name)
                 && e->semantic_index == signature_element->semantic_index)
         {
             xfb_element = e;
diff --git a/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d-shader/vkd3d_shader_main.c
index 9848202..aa486cc 100644
--- a/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -401,7 +401,7 @@ struct vkd3d_shader_signature_element *vkd3d_shader_find_signature_element(
     e = signature->elements;
     for (i = 0; i < signature->element_count; ++i)
     {
-        if (!strcasecmp(e[i].semantic_name, semantic_name)
+        if (!ascii_strcasecmp(e[i].semantic_name, semantic_name)
                 && e[i].semantic_index == semantic_index
                 && e[i].stream_index == stream_index)
             return &e[i];
diff --git a/tests/vkd3d_shader_api.c b/tests/vkd3d_shader_api.c
index 41067c0..f9bec7e 100644
--- a/tests/vkd3d_shader_api.c
+++ b/tests/vkd3d_shader_api.c
@@ -19,6 +19,8 @@
 #include "vkd3d_test.h"
 #include <vkd3d_shader.h>
 
+#include <locale.h>
+
 static void test_invalid_shaders(void)
 {
     struct vkd3d_shader_code spirv;
@@ -112,7 +114,7 @@ static void test_vkd3d_shader_pfns(void)
 
     rc = pfn_vkd3d_shader_parse_input_signature(&vs, &signature);
     ok(rc == VKD3D_OK, "Got unexpected error code %d.\n", rc);
-    element = pfn_vkd3d_shader_find_signature_element(&signature, "POSITION", 0, 0);
+    element = pfn_vkd3d_shader_find_signature_element(&signature, "position", 0, 0);
     ok(element, "Could not find shader signature element.\n");
     pfn_vkd3d_shader_free_shader_signature(&signature);
 
@@ -128,6 +130,8 @@ static void test_vkd3d_shader_pfns(void)
 
 START_TEST(vkd3d_shader_api)
 {
+    setlocale(LC_ALL, "");
+
     run_test(test_invalid_shaders);
     run_test(test_vkd3d_shader_pfns);
 }




More information about the wine-cvs mailing list