From 66449802e44718d196fbc4fb44fa26e498759861 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 26 Dec 2015 07:37:44 +0100 Subject: [PATCH] (menu) Start going through string_is_empty --- menu/cbs/menu_cbs_deferred_push.c | 3 ++- menu/cbs/menu_cbs_ok.c | 21 ++++++++++----------- menu/cbs/menu_cbs_title.c | 6 +++--- menu/drivers/materialui.c | 6 +++--- menu/drivers/menu_generic.c | 3 ++- menu/drivers/rgui.c | 3 ++- menu/drivers/xmb.c | 6 +++--- menu/drivers/zarch.c | 5 +++-- menu/intl/menu_hash_us.c | 3 ++- menu/intl/menu_hash_uspseudo.c | 3 ++- menu/menu_cbs.c | 5 +++-- menu/menu_displaylist.c | 29 +++++++++++++++-------------- menu/menu_driver.c | 11 +++++++---- menu/menu_entries.c | 7 ++++--- menu/menu_setting.c | 5 +++-- 15 files changed, 64 insertions(+), 52 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index e4a0036ec5..300babc8e3 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -14,6 +14,7 @@ */ #include +#include #include "../menu_driver.h" #include "../menu_cbs.h" @@ -189,7 +190,7 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch(menu_displ database_info_build_query(query, sizeof(query), info->label, str_list->elems[0].data); - if (query[0] == '\0') + if (string_is_empty(query)) goto end; strlcpy(info->path, str_list->elems[1].data, sizeof(info->path)); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 3e715542d9..4bdf9f2138 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -15,6 +15,7 @@ #include #include +#include #include "../menu_driver.h" #include "../menu_cbs.h" @@ -228,10 +229,10 @@ int generic_action_ok_displaylist_push(const char *path, case ACTION_OK_DL_CONFIGURATIONS_LIST: info.type = type; info.directory_ptr = idx; - if (settings->menu_config_directory[0] != '\0') - info_path = settings->menu_config_directory; - else + if (string_is_empty(settings->menu_config_directory)) info_path = label; + else + info_path = settings->menu_config_directory; info_label = label; break; case ACTION_OK_DL_COMPRESSED_ARCHIVE_PUSH_DETECT_CORE: @@ -1317,9 +1318,9 @@ static int action_ok_option_create(const char *path, /* Config directory: config_directory. * Try config directory setting first, * fallback to the location of the current configuration file. */ - if (settings->menu_config_directory[0] != '\0') + if (!string_is_empty(settings->menu_config_directory)) strlcpy(config_directory, settings->menu_config_directory, PATH_MAX_LENGTH); - else if (global->path.config[0] != '\0') + else if (!string_is_empty(global->path.config)) fill_pathname_basedir(config_directory, global->path.config, PATH_MAX_LENGTH); else { @@ -1327,12 +1328,10 @@ static int action_ok_option_create(const char *path, return false; } - core_name = system ? system->info.library_name : NULL; + core_name = system ? system->info.library_name : NULL; game_name = global ? path_basename(global->name.base) : NULL; - if (!core_name || !game_name) - return false; - if (core_name[0] == '\0' || game_name == '\0') + if (string_is_empty(core_name) || string_is_empty(game_name)) return false; /* Concatenate strings into full paths for game_path */ @@ -1443,7 +1442,7 @@ static int generic_action_ok_network(const char *path, menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - if (settings->network.buildbot_url[0] == '\0') + if (string_is_empty(settings->network.buildbot_url)) return -1; event_command(EVENT_CMD_NETWORK_INIT); @@ -1964,7 +1963,7 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, { uint32_t elem0_hash = menu_hash_calculate(elem0); - if (elem0[0] != '\0' && (is_rdb_entry(elem0_hash) == 0)) + if (!string_is_empty(elem0) && (is_rdb_entry(elem0_hash) == 0)) { BIND_ACTION_OK(cbs, action_ok_rdb_entry_submenu); return 0; diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 939b726964..22d110cd0b 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -131,7 +131,7 @@ static int action_get_title_generic(char *s, size_t len, const char *path, { struct string_list *list_path = NULL; - if (path && path[0] != '\0') + if (!string_is_empty(path)) list_path = string_split(path, "|"); if (list_path) @@ -141,7 +141,7 @@ static int action_get_title_generic(char *s, size_t len, const char *path, strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path)); string_list_free(list_path); snprintf(s, len, "%s - %s", text, - (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); + (string_is_empty(elem0_path)) ? "" : path_basename(elem0_path)); } else strlcpy(s, "N/A", len); @@ -284,7 +284,7 @@ static int action_get_title_group_settings(const char *path, const char *label, strlcpy(s, elem0, len); - if (elem1[0] != '\0') + if (!string_is_empty(elem1)) { strlcat(s, " - ", len); strlcat(s, elem1, len); diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 2e6e770107..96c474c42a 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -19,13 +19,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include "menu_generic.h" @@ -154,7 +154,7 @@ static void mui_context_reset_textures(mui_handle_t *mui, const char *iconpath) break; } - if (path[0] == '\0' || !path_file_exists(path)) + if (string_is_empty(path) || !path_file_exists(path)) continue; texture_image_load(&ti, path); @@ -862,7 +862,7 @@ static void mui_frame(void *data) mui_render_messagebox(msg); } - if (mui->box_message[0] != '\0') + if (!string_is_empty(mui->box_message)) { mui_render_quad(mui, 0, 0, width, height, width, height, &black_bg[0]); mui_render_messagebox(mui->box_message); diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 16524455e2..ac95ed709a 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -16,6 +16,7 @@ */ #include +#include #include "menu_generic.h" @@ -355,7 +356,7 @@ int menu_iterate_render(void *data, void *userdata) if (BIT64_GET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER)) menu_display_ctl(MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, NULL); - if (BIT64_GET(menu->state, MENU_STATE_RENDER_MESSAGEBOX) && menu->menu_state.msg[0] != '\0') + if (BIT64_GET(menu->state, MENU_STATE_RENDER_MESSAGEBOX) && !string_is_empty(menu->menu_state.msg)) { menu_driver_ctl(RARCH_MENU_CTL_RENDER_MESSAGEBOX, NULL); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index ed751b41fb..4afb2a19ff 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -635,7 +636,7 @@ static void rgui_render(void *data) rgui_render_messagebox(msg); } - if (rgui->msgbox[0] != '\0') + if (!string_is_empty(rgui->msgbox)) { rgui_render_messagebox(rgui->msgbox); rgui->msgbox[0] = '\0'; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 173c643da6..7283a3033a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1446,7 +1446,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, } ticker_limit = 35; - if (entry.value[0] == '\0') + if (string_is_empty(entry.value)) { if (settings->menu.boxart_enable && xmb->boxart) ticker_limit = 40; @@ -1759,7 +1759,7 @@ static void xmb_frame(void *data) render_background = true; } - if (xmb->box_message[0] != '\0') + if (!string_is_empty(xmb->box_message)) { strlcpy(msg, xmb->box_message, sizeof(msg)); @@ -2150,7 +2150,7 @@ static void xmb_context_reset_textures(xmb_handle_t *xmb, const char *iconpath) break; } - if (path[0] == '\0' || !path_file_exists(path)) + if (string_is_empty(path) || !path_file_exists(path)) continue; texture_image_load(&ti, path); diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index da5f255901..eb6f90dd40 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -691,7 +692,7 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, zui_tabbed_t *tabbed) if (zui->load_dlist) { fill_pathname_parent_dir(parent_dir, zui->load_cwd, sizeof(parent_dir)); - if (parent_dir[0] != '\0' && + if (!string_is_empty(parent_dir) && zarch_zui_list_item(zui, tabbed, 0, tabbed->tabline_size + 73, " ..", 0, NULL /* TODO/FIXME */)) { zarch_zui_render_lay_root_load_set_new_path(zui, parent_dir); @@ -1082,7 +1083,7 @@ static void *zarch_init(void **userdata) zui->header_height = 1000; /* dpi / 3; */ zui->font_size = 28; - if (settings->menu.wallpaper[0] != '\0') + if (!string_is_empty(settings->menu.wallpaper)) rarch_task_push_image_load(settings->menu.wallpaper, "cb_menu_wallpaper", menu_display_handle_wallpaper_upload, NULL); diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 35cd941213..92801ea0cc 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -18,6 +18,7 @@ #include #include +#include #include "../menu_hash.h" #include "../../configuration.h" @@ -2710,7 +2711,7 @@ int menu_hash_get_help_us(uint32_t hash, char *s, size_t len) menu_hash_to_str(MENU_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU) ); default: - if (s[0] == '\0') + if (string_is_empty(s)) strlcpy(s, menu_hash_to_str(MENU_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); return -1; } diff --git a/menu/intl/menu_hash_uspseudo.c b/menu/intl/menu_hash_uspseudo.c index fd8fcededc..1cad6d3e12 100644 --- a/menu/intl/menu_hash_uspseudo.c +++ b/menu/intl/menu_hash_uspseudo.c @@ -19,6 +19,7 @@ #include #include +#include #include "../menu_hash.h" #include "../../configuration.h" @@ -2576,7 +2577,7 @@ int menu_hash_get_help_us(uint32_t hash, char *s, size_t len) menu_hash_to_str(MENU_LABEL_VALUE_INPUT_OVERLAY_HIDE_IN_MENU) ); default: - if (s[0] == '\0') + if (string_is_empty(s)) strlcpy(s, menu_hash_to_str(MENU_LABEL_VALUE_NO_INFORMATION_AVAILABLE), len); return -1; } diff --git a/menu/menu_cbs.c b/menu/menu_cbs.c index cea69ee973..ebcb7e11f8 100644 --- a/menu/menu_cbs.c +++ b/menu/menu_cbs.c @@ -14,6 +14,7 @@ */ #include +#include #include #include "menu_driver.h" @@ -28,7 +29,7 @@ static void menu_cbs_init_log(const char *entry_label, const char *bind_label, const char *label) { #ifdef DEBUG_LOG - if (label && label[0] != '\0') + if (!string_is_empty(label)) RARCH_LOG("[%s]\t\t\tFound %s bind : [%s]\n", entry_label, bind_label, label); #endif } @@ -73,7 +74,7 @@ void menu_cbs_init(void *data, RARCH_LOG("\n"); #endif - repr_label = (label && label[0] != '\0') ? label : path; + repr_label = (!string_is_empty(label)) ? label : path; ret = menu_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index dabf587dde..14a0a304d8 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "menu_driver.h" #include "menu_navigation.h" @@ -947,10 +948,10 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, fill_short_pathname_representation(path_short, path, sizeof(path_short)); strlcpy(fill_buf, - (label && label[0] != '\0') ? label : path_short, + (!string_is_empty(label)) ? label : path_short, sizeof(fill_buf)); - if (core_name && core_name[0] != '\0') + if (!string_is_empty(core_name)) { if (core_name_hash != MENU_VALUE_DETECT) { @@ -1484,7 +1485,7 @@ static int menu_database_parse_query(file_list_t *list, const char *path, for (i = 0; i < db_list->count; i++) { - if (db_list->list[i].name && db_list->list[i].name[0] != '\0') + if (!string_is_empty(db_list->list[i].name)) menu_entries_push(list, db_list->list[i].name, path, MENU_FILE_RDB_ENTRY, 0, 0); } @@ -1833,7 +1834,7 @@ static int menu_displaylist_parse_horizontal_content_actions(menu_displaylist_in content_playlist_get_index(playlist, idx, NULL, &label, &core_path, &core_name, NULL, &db_name); - if (db_name && db_name[0] != '\0') + if (!string_is_empty(db_name)) { char db_path[PATH_MAX_LENGTH] = {0}; @@ -2156,7 +2157,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool ho char out_dir[PATH_MAX_LENGTH]; fill_pathname_parent_dir(out_dir, info->path, sizeof(out_dir)); - if (out_dir[0] != '\0') + if (!string_is_empty(out_dir)) { menu_entries_push(info->list, "..", info->path, MENU_FILE_PARENT_DIRECTORY, 0, 0); @@ -2900,7 +2901,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) break; case DISPLAYLIST_DATABASE_QUERY: ret = menu_database_parse_query(info->list, - info->path, (info->path_c[0] == '\0') ? NULL : info->path_c); + info->path, string_is_empty(info->path_c) ? NULL : info->path_c); strlcpy(info->path, info->path_b, sizeof(info->path)); info->need_sort = true; @@ -3313,14 +3314,7 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list) strlcpy(info.label, menu_hash_to_str(MENU_LABEL_CONTENT_COLLECTION_LIST), sizeof(info.label)); - if (settings->playlist_directory[0] != '\0') - { - strlcpy(info.path, settings->playlist_directory, - sizeof(info.path)); - if (menu_displaylist_push_list(&info, DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL) != 0) - return -1; - } - else + if (string_is_empty(settings->playlist_directory)) { menu_entries_clear(info.list); menu_entries_push(info.list, @@ -3330,6 +3324,13 @@ int menu_displaylist_push(file_list_t *list, file_list_t *menu_list) info.need_refresh = true; info.need_push = true; } + else + { + strlcpy(info.path, settings->playlist_directory, + sizeof(info.path)); + if (menu_displaylist_push_list(&info, DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL) != 0) + return -1; + } menu_displaylist_push_list_process(&info); return 0; case MENU_VALUE_HORIZONTAL_MENU: diff --git a/menu/menu_driver.c b/menu/menu_driver.c index cb24892472..613bd38602 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -17,6 +17,7 @@ #include #include +#include #include "menu_driver.h" #include "menu_cbs.h" @@ -604,9 +605,11 @@ void *menu_init(const void *data) menu->help_screen_type = MENU_HELP_WELCOME; settings->menu_show_start_screen = false; - if (settings->bundle_assets_extract_enable && - settings->bundle_assets_src_path[0] != '\0' && settings->bundle_assets_dst_path[0] != '\0' && - settings->bundle_assets_extract_version_current != settings->bundle_assets_extract_last_version + if ( + settings->bundle_assets_extract_enable + && !string_is_empty(settings->bundle_assets_src_path) + && !string_is_empty(settings->bundle_assets_dst_path) + && settings->bundle_assets_extract_version_current != settings->bundle_assets_extract_last_version ) { menu->help_screen_type = MENU_HELP_EXTRACT; @@ -657,7 +660,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) case RARCH_MENU_CTL_PLAYLIST_INIT: { const char *path = (const char*)data; - if (!path || path[0] == '\0') + if (!string_is_empty(path)) return false; menu_driver_playlist = content_playlist_init(path, COLLECTION_SIZE); diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f3565ab82a..495d27c86a 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -16,6 +16,7 @@ #include #include +#include #include "menu_driver.h" #include "menu_cbs.h" @@ -359,7 +360,7 @@ void menu_entries_get(size_t i, menu_entry_t *entry) menu_entries_get_last_stack(NULL, &label, NULL, NULL); - entry->path[0] = entry->value[0] = entry->label[0] = '\0'; + entry->path[0] = entry->value[0] = string_is_empty(entry->label); menu_entries_get_at_offset(selection_buf, i, &path, &entry_label, &entry->type, &entry->entry_idx, NULL); @@ -419,9 +420,9 @@ int menu_entries_get_core_title(char *s, size_t len) if (!settings->menu.core_enable) return -1; - if (!core_name || core_name[0] == '\0') + if (string_is_empty(core_name)) core_name = info->info.library_name; - if (!core_name || core_name[0] == '\0') + if (string_is_empty(core_name)) core_name = menu_hash_to_str(MENU_VALUE_NO_CORE); if (!core_version) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index aa0156c69a..ca7148ded8 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "menu_setting.h" @@ -1877,7 +1878,7 @@ rarch_setting_t *menu_setting_find(const char *label) if (strcmp(label, name) != 0) continue; - if (short_description[0] == '\0') + if (string_is_empty(short_description)) return NULL; if (setting->read_handler) @@ -2911,7 +2912,7 @@ void general_write_handler(void *data) break; case MENU_LABEL_NETPLAY_IP_ADDRESS: #ifdef HAVE_NETPLAY - global->has_set.netplay_ip_address = (setting->value.string[0] != '\0'); + global->has_set.netplay_ip_address = (!string_is_empty(setting->value.string)); #endif break; case MENU_LABEL_NETPLAY_MODE: