From 9f4b3b0fc6ca4a1ce639def86ae6c6d91cf5ecec Mon Sep 17 00:00:00 2001 From: twinaphex <libretro@gmail.com> Date: Fri, 22 May 2020 20:07:21 +0200 Subject: [PATCH] Start using string_ends_with --- menu/drivers/ozone/ozone_sidebar.c | 4 ++-- menu/drivers/stripes.c | 7 ++----- menu/drivers/xmb.c | 4 ++-- menu/menu_shader.c | 6 +++--- tasks/task_audio_mixer.c | 28 ++++++++++++++-------------- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 367643f8e2..f2c1c37d8f 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -851,7 +851,7 @@ void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) if (!path) continue; - if (!strstr(path, ".lpl")) + if (!string_ends_with(path, ".lpl")) continue; { @@ -968,7 +968,7 @@ void ozone_context_destroy_horizontal_list(ozone_handle_t *ozone) file_list_get_at_offset(ozone->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path || !strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; video_driver_texture_unload(&node->icon); diff --git a/menu/drivers/stripes.c b/menu/drivers/stripes.c index 7b2ecac23d..307ce6ffdc 100644 --- a/menu/drivers/stripes.c +++ b/menu/drivers/stripes.c @@ -1839,7 +1839,7 @@ static void stripes_context_destroy_horizontal_list(stripes_handle_t *stripes) file_list_get_at_offset(stripes->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path || !strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; video_driver_texture_unload(&node->icon); @@ -1937,10 +1937,7 @@ static void stripes_context_reset_horizontal_list( file_list_get_at_offset(stripes->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path) - continue; - - if (!strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; { diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 04d6b9a1f2..d26ead6292 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2016,7 +2016,7 @@ static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb) file_list_get_at_offset(xmb->horizontal_list, i, &path, NULL, NULL, NULL); - if (!path || !strstr(path, ".lpl")) + if (!path || !string_ends_with(path, ".lpl")) continue; video_driver_texture_unload(&node->icon); @@ -2115,7 +2115,7 @@ static void xmb_context_reset_horizontal_list( if (!path) continue; - if (!strstr(path, ".lpl")) + if (!string_ends_with(path, ".lpl")) continue; { diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 1aafd41b93..b584dfb512 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -249,9 +249,9 @@ static bool menu_shader_manager_save_preset_internal( strlcpy(fullname, basename, sizeof(fullname)); /* Append extension automatically as appropriate. */ - if ( !strstr(basename, ".cgp") - && !strstr(basename, ".glslp") - && !strstr(basename, ".slangp")) + if ( !string_ends_with(basename, ".cgp") + && !string_ends_with(basename, ".glslp") + && !string_ends_with(basename, ".slangp")) { const char *preset_ext = video_shader_get_preset_extension(type); strlcat(fullname, preset_ext, sizeof(fullname)); diff --git a/tasks/task_audio_mixer.c b/tasks/task_audio_mixer.c index 4f5a8c4c79..69c3ce409f 100644 --- a/tasks/task_audio_mixer.c +++ b/tasks/task_audio_mixer.c @@ -479,34 +479,34 @@ bool task_push_audio_mixer_load_and_play( nbio->type = NBIO_TYPE_NONE; mixer->type = AUDIO_MIXER_TYPE_NONE; - if (strstr(fullpath, ".wav")) + if (string_ends_with(fullpath, ".wav")) { mixer->type = AUDIO_MIXER_TYPE_WAV; nbio->type = NBIO_TYPE_WAV; t->callback = task_audio_mixer_handle_upload_wav_and_play; } - else if (strstr(fullpath, ".ogg")) + else if (string_ends_with(fullpath, ".ogg")) { mixer->type = AUDIO_MIXER_TYPE_OGG; nbio->type = NBIO_TYPE_OGG; t->callback = task_audio_mixer_handle_upload_ogg_and_play; } - else if (strstr(fullpath, ".mp3")) + else if (string_ends_with(fullpath, ".mp3")) { mixer->type = AUDIO_MIXER_TYPE_MP3; nbio->type = NBIO_TYPE_MP3; t->callback = task_audio_mixer_handle_upload_mp3_and_play; } - else if (strstr(fullpath, ".flac")) + else if (string_ends_with(fullpath, ".flac")) { mixer->type = AUDIO_MIXER_TYPE_FLAC; nbio->type = NBIO_TYPE_FLAC; t->callback = task_audio_mixer_handle_upload_flac_and_play; } else if ( - strstr(fullpath, ".mod") || - strstr(fullpath, ".s3m") || - strstr(fullpath, ".xm")) + string_ends_with(fullpath, ".mod") || + string_ends_with(fullpath, ".s3m") || + string_ends_with(fullpath, ".xm")) { mixer->type = AUDIO_MIXER_TYPE_MOD; nbio->type = NBIO_TYPE_MOD; @@ -589,34 +589,34 @@ bool task_push_audio_mixer_load( nbio->type = NBIO_TYPE_NONE; mixer->type = AUDIO_MIXER_TYPE_NONE; - if (strstr(fullpath, ".wav")) + if (string_ends_with(fullpath, ".wav")) { mixer->type = AUDIO_MIXER_TYPE_WAV; nbio->type = NBIO_TYPE_WAV; t->callback = task_audio_mixer_handle_upload_wav; } - else if (strstr(fullpath, ".ogg")) + else if (string_ends_with(fullpath, ".ogg")) { mixer->type = AUDIO_MIXER_TYPE_OGG; nbio->type = NBIO_TYPE_OGG; t->callback = task_audio_mixer_handle_upload_ogg; } - else if (strstr(fullpath, ".mp3")) + else if (string_ends_with(fullpath, ".mp3")) { mixer->type = AUDIO_MIXER_TYPE_MP3; nbio->type = NBIO_TYPE_MP3; t->callback = task_audio_mixer_handle_upload_mp3; } - else if (strstr(fullpath, ".flac")) + else if (string_ends_with(fullpath, ".flac")) { mixer->type = AUDIO_MIXER_TYPE_FLAC; nbio->type = NBIO_TYPE_FLAC; t->callback = task_audio_mixer_handle_upload_flac; } else if ( - strstr(fullpath, ".mod") || - strstr(fullpath, ".s3m") || - strstr(fullpath, ".xm")) + string_ends_with(fullpath, ".mod") || + string_ends_with(fullpath, ".s3m") || + string_ends_with(fullpath, ".xm")) { mixer->type = AUDIO_MIXER_TYPE_MOD; nbio->type = NBIO_TYPE_MOD;