mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Create string_is_equal_noncase - try not to use strcasecmp so much
This commit is contained in:
parent
de513211dc
commit
63e2d13b8f
@ -14,12 +14,15 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <file/config_file_userdata.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "audio_resampler_driver.h"
|
||||
#ifdef RARCH_INTERNAL
|
||||
#include "../performance.h"
|
||||
#endif
|
||||
#include <file/config_file_userdata.h>
|
||||
#include <string.h>
|
||||
#ifndef DONT_HAVE_STRING_LIST
|
||||
#include "../string_list_special.h"
|
||||
#endif
|
||||
@ -54,7 +57,7 @@ static int find_resampler_driver_index(const char *ident)
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; resampler_drivers[i]; i++)
|
||||
if (strcasecmp(ident, resampler_drivers[i]->ident) == 0)
|
||||
if (string_is_equal_noncase(ident, resampler_drivers[i]->ident))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ static bool init_content_file_extract(
|
||||
if (!ext)
|
||||
continue;
|
||||
|
||||
if (!strcasecmp(ext, "zip"))
|
||||
if (string_is_equal_noncase(ext, "zip"))
|
||||
{
|
||||
char temp_content[PATH_MAX_LENGTH];
|
||||
|
||||
|
@ -516,7 +516,7 @@ void core_info_list_get_supported_cores(core_info_list_t *core_info_list,
|
||||
core_info_tmp_path = path;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
if (!strcasecmp(path_get_extension(path), "zip"))
|
||||
if (string_is_equal_noncase(path_get_extension(path), "zip"))
|
||||
list = zlib_get_file_list(path, NULL);
|
||||
core_info_tmp_list = list;
|
||||
#endif
|
||||
|
2
driver.c
2
driver.c
@ -142,7 +142,7 @@ int find_driver_index(const char * label, const char *drv)
|
||||
return -1;
|
||||
if (string_is_empty(str))
|
||||
break;
|
||||
if (!strcasecmp(drv, str))
|
||||
if (string_is_equal_noncase(drv, str))
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ int read_compressed_file(const char * path, void **buf,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_7ZIP
|
||||
if (strcasecmp(file_ext,"7z") == 0)
|
||||
if (string_is_equal_noncase(file_ext, "7z"))
|
||||
{
|
||||
*length = read_7zip_file(archive_path,archive_found,buf,optional_filename);
|
||||
if (*length != -1)
|
||||
@ -545,7 +545,7 @@ int read_compressed_file(const char * path, void **buf,
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB
|
||||
if (strcasecmp(file_ext,"zip") == 0)
|
||||
if (string_is_equal_noncase(file_ext, "zip"))
|
||||
{
|
||||
*length = read_zip_file(archive_path,archive_found,buf,optional_filename);
|
||||
if (*length != -1)
|
||||
@ -588,11 +588,11 @@ struct string_list *compressed_file_list_new(const char *path,
|
||||
const char* file_ext = path_get_extension(path);
|
||||
#endif
|
||||
#ifdef HAVE_7ZIP
|
||||
if (strcasecmp(file_ext,"7z") == 0)
|
||||
if (string_is_equal_noncase(file_ext, "7z"))
|
||||
return compressed_7zip_file_list_new(path,ext);
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB
|
||||
if (strcasecmp(file_ext,"zip") == 0)
|
||||
if (string_is_equal_noncase(file_ext, "zip"))
|
||||
return zlib_get_file_list(path, ext);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include <xtl.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "../font_driver.h"
|
||||
#include "../d3d/d3d.h"
|
||||
#include "../../general.h"
|
||||
@ -166,7 +168,7 @@ void *PackedResource::GetData(const char *strName) const
|
||||
for (DWORD i = 0; i < m_dwNumResourceTags; i++)
|
||||
#endif
|
||||
{
|
||||
if (!strcasecmp(strName, m_pResourceTags[i].strName))
|
||||
if (string_is_equal_noncase(strName, m_pResourceTags[i].strName))
|
||||
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "video_context_driver.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -291,7 +293,7 @@ static int find_gfx_ctx_driver_index(const char *ident)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; gfx_ctx_drivers[i]; i++)
|
||||
if (strcasecmp(ident, gfx_ctx_drivers[i]->ident) == 0)
|
||||
if (string_is_equal_noncase(ident, gfx_ctx_drivers[i]->ident))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ static enum retro_key find_rk_bind(const char *str)
|
||||
|
||||
for (i = 0; input_config_key_map[i].str; i++)
|
||||
{
|
||||
if (strcasecmp(input_config_key_map[i].str, str) == 0)
|
||||
if (string_is_equal_noncase(input_config_key_map[i].str, str))
|
||||
return input_config_key_map[i].key;
|
||||
}
|
||||
|
||||
@ -266,13 +266,13 @@ static void parse_hat(struct retro_keybind *bind, const char *str)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(dir, "up") == 0)
|
||||
if (string_is_equal_noncase(dir, "up"))
|
||||
hat_dir = HAT_UP_MASK;
|
||||
else if (strcasecmp(dir, "down") == 0)
|
||||
else if (string_is_equal_noncase(dir, "down"))
|
||||
hat_dir = HAT_DOWN_MASK;
|
||||
else if (strcasecmp(dir, "left") == 0)
|
||||
else if (string_is_equal_noncase(dir, "left"))
|
||||
hat_dir = HAT_LEFT_MASK;
|
||||
else if (strcasecmp(dir, "right") == 0)
|
||||
else if (string_is_equal_noncase(dir, "right"))
|
||||
hat_dir = HAT_RIGHT_MASK;
|
||||
|
||||
if (hat_dir)
|
||||
|
@ -36,6 +36,8 @@ bool string_is_empty(const char *data);
|
||||
|
||||
bool string_is_equal(const char *a, const char *b);
|
||||
|
||||
bool string_is_equal_noncase(const char *a, const char *b);
|
||||
|
||||
char *string_to_upper(char *s);
|
||||
|
||||
char *string_to_lower(char *s);
|
||||
|
@ -44,6 +44,19 @@ bool string_is_equal(const char *a, const char *b)
|
||||
return (strcmp(a, b) == 0);
|
||||
}
|
||||
|
||||
bool string_is_equal_noncase(const char *a, const char *b)
|
||||
{
|
||||
int ca, cb;
|
||||
do
|
||||
{
|
||||
ca = (unsigned char)*a++;
|
||||
cb = (unsigned char)*b++;
|
||||
ca = tolower(toupper(ca));
|
||||
cb = tolower(toupper(cb));
|
||||
} while (ca == cb && ca != '\0');
|
||||
return (ca - cb) == 0;
|
||||
}
|
||||
|
||||
char *string_to_upper(char *s)
|
||||
{
|
||||
unsigned char *ucs = (unsigned char *)s;
|
||||
|
@ -457,7 +457,7 @@ void cb_generic_download(void *task_data, void *user_data, const char *err)
|
||||
if (!settings->network.buildbot_auto_extract_archive)
|
||||
goto finish;
|
||||
|
||||
if (!strcasecmp(file_ext, "zip"))
|
||||
if (string_is_equal_noncase(file_ext, "zip"))
|
||||
{
|
||||
rarch_task_push_decompress(output_path, dir_path, NULL, NULL,
|
||||
cb_decompressed, (void*)(uintptr_t)transf->type_hash);
|
||||
|
@ -2252,7 +2252,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool ho
|
||||
case MENU_LABEL_CORE_LIST:
|
||||
#ifdef HAVE_LIBRETRO_MANAGEMENT
|
||||
#ifdef RARCH_CONSOLE
|
||||
if (is_dir || strcasecmp(path, SALAMANDER_FILE) == 0)
|
||||
if (is_dir || string_is_equal_noncase(path, SALAMANDER_FILE))
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
|
@ -372,21 +372,23 @@ int find_first_data_track(const char *cue_path,
|
||||
fill_pathname_join(track_path, cue_dir, tmp_token, max_len);
|
||||
|
||||
}
|
||||
else if (strcasecmp(tmp_token, "TRACK") == 0)
|
||||
else if (string_is_equal_noncase(tmp_token, "TRACK"))
|
||||
{
|
||||
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
||||
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
||||
if (strcasecmp(tmp_token, "AUDIO") == 0)
|
||||
if (string_is_equal_noncase(tmp_token, "AUDIO"))
|
||||
continue;
|
||||
|
||||
find_token(fd, "INDEX");
|
||||
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
||||
get_token(fd, tmp_token, MAX_TOKEN_LEN);
|
||||
|
||||
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
||||
{
|
||||
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
*offset = ((m * 60) * (s * 75) * f) * 25;
|
||||
|
||||
RARCH_LOG("Found 1st data track on file '%s+%d'\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user