vkd3d-shader: Use locale-insensitive string comparison.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2019-04-30 14:33:48 +02:00 committed by Alexandre Julliard
parent de3423e98e
commit df72746729
4 changed files with 30 additions and 3 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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];

View File

@ -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);
}