diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index fa66843fe1..4890e37f8f 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -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; diff --git a/libretro-common/include/string/stdstring.h b/libretro-common/include/string/stdstring.h index 23bf0620b7..17e7209529 100644 --- a/libretro-common/include/string/stdstring.h +++ b/libretro-common/include/string/stdstring.h @@ -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;