Create string_is_equal_case_insensitive

This commit is contained in:
twinaphex 2018-03-01 23:16:34 +01:00
parent 2f457af8bf
commit df7f47d00a
2 changed files with 25 additions and 11 deletions

View File

@ -1147,8 +1147,7 @@ enum rarch_shader_type video_shader_get_type_from_ext(
}
}
if (
string_is_equal(ext, "cgp") ||
string_is_equal(ext, "CGP")
string_is_equal_case_insensitive(ext, "cgp")
)
{
*is_preset = true;
@ -1180,8 +1179,7 @@ enum rarch_shader_type video_shader_get_type_from_ext(
}
}
if (
string_is_equal(ext, "glsl") ||
string_is_equal(ext, "GLSL")
string_is_equal_case_insensitive(ext, "glsl")
)
{
switch (api)
@ -1194,8 +1192,7 @@ enum rarch_shader_type video_shader_get_type_from_ext(
}
}
if (
string_is_equal(ext, "glslp") ||
string_is_equal(ext, "GLSLP")
string_is_equal_case_insensitive(ext, "glslp")
)
{
*is_preset = true;
@ -1209,8 +1206,7 @@ enum rarch_shader_type video_shader_get_type_from_ext(
}
}
if (
string_is_equal(ext, "slang") ||
string_is_equal(ext, "SLANG")
string_is_equal_case_insensitive(ext, "slang")
)
{
switch (api)
@ -1225,8 +1221,7 @@ enum rarch_shader_type video_shader_get_type_from_ext(
}
}
if (
string_is_equal(ext, "slangp") ||
string_is_equal(ext, "SLANGP")
string_is_equal_case_insensitive(ext, "slangp")
)
{
*is_preset = true;

View File

@ -75,9 +75,28 @@ static INLINE void string_add_between_pairs(char *s, const char *str,
#define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0)
#define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0)
static INLINE bool string_is_equal_case_insensitive(const char *a,
const char *b)
{
int result = 0;
const unsigned char *p1 = (const unsigned char*)a;
const unsigned char *p2 = (const unsigned char*)b;
if (!a || !b)
return false;
if (p1 == p2)
return true;
while ((result = tolower (*p1) - tolower (*p2++)) == 0)
if (*p1++ == '\0')
break;
return (result == 0);
}
static INLINE bool string_is_equal_noncase(const char *a, const char *b)
{
int result;
int result = 0;
const unsigned char *p1 = (const unsigned char*)a;
const unsigned char *p2 = (const unsigned char*)b;