From f9a412dc11e1aedce2630a31cc643498df9c336e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 31 Jan 2018 22:43:55 +0100 Subject: [PATCH] Create fill_pathname_join_concat_noext and use it --- libretro-common/file/file_path.c | 10 ++++ libretro-common/include/file/file_path.h | 6 +++ menu/menu_displaylist.c | 68 +++++++++++------------- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 162704fde9..adf519871b 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -863,6 +863,16 @@ void fill_pathname_join_special_ext(char *out_path, strlcat(out_path, ext, size); } +void fill_pathname_join_concat_noext( + char *out_path, + const char *dir, const char *path, + const char *concat, + size_t size) +{ + fill_pathname_noext(out_path, dir, path, size); + strlcat(out_path, concat, size); +} + void fill_pathname_join_concat(char *out_path, const char *dir, const char *path, const char *concat, diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 2bba202781..8d54de7c69 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -348,6 +348,12 @@ void fill_pathname_join_special_ext(char *out_path, const char *last, const char *ext, size_t size); +void fill_pathname_join_concat_noext( + char *out_path, + const char *dir, const char *path, + const char *concat, + size_t size); + void fill_pathname_join_concat(char *out_path, const char *dir, const char *path, const char *concat, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 3d311fc984..e9b71ce2e1 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -196,23 +196,23 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) if (core_info->systemname) { - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_NAME), ": ", + core_info->systemname, sizeof(tmp)); - strlcat(tmp, core_info->systemname, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); } if (core_info->system_manufacturer) { - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SYSTEM_MANUFACTURER), ": ", + core_info->system_manufacturer, sizeof(tmp)); - strlcat(tmp, core_info->system_manufacturer, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); } @@ -381,11 +381,12 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) (void)tmp_string; #ifdef HAVE_GIT_VERSION - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext( + tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION), ": ", + retroarch_git_version, sizeof(tmp)); - strlcat(tmp, retroarch_git_version, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); #endif @@ -530,11 +531,12 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) tmp2[0] = '\0'; - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext( + tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_IDENTIFIER), ": ", + frontend->ident, sizeof(tmp)); - strlcat(tmp, frontend->ident, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); @@ -544,11 +546,10 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) { frontend->get_lakka_version(tmp2, sizeof(tmp2)); - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION), ": ", - sizeof(tmp)); - strlcat(tmp, frontend->get_lakka_version ? + frontend->get_lakka_version ? tmp2 : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", @@ -561,11 +562,10 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) { frontend->get_name(tmp2, sizeof(tmp2)); - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_NAME), ": ", - sizeof(tmp)); - strlcat(tmp, frontend->get_name ? + frontend->get_name ? tmp2 : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", @@ -690,12 +690,12 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) break; } - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE), ": ", + tmp2, sizeof(tmp)); - strlcat(tmp, tmp2, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); @@ -706,12 +706,11 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) video_context_driver_get_ident(&ident_info); tmp_string = ident_info.ident; - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_VIDEO_CONTEXT_DRIVER), ": ", - sizeof(tmp)); - strlcat(tmp, tmp_string ? tmp_string + tmp_string ? tmp_string : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), sizeof(tmp)); menu_entries_append_enum(info->list, tmp, "", @@ -764,12 +763,10 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) } #endif - fill_pathname_noext(feat_str, + fill_pathname_join_concat_noext(feat_str, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBRETRODB_SUPPORT), ": ", - sizeof(feat_str)); - strlcat(feat_str, _libretrodb_supp ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO), @@ -778,12 +775,11 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - fill_pathname_noext(feat_str, + fill_pathname_join_concat_noext(feat_str, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_OVERLAY_SUPPORT), ": ", - sizeof(feat_str)); - strlcat(feat_str, _overlay_supp ? + _overlay_supp ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO), sizeof(feat_str)); @@ -791,12 +787,11 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - fill_pathname_noext(feat_str, + fill_pathname_join_concat_noext(feat_str, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_COMMAND_IFACE_SUPPORT), ": ", - sizeof(feat_str)); - strlcat(feat_str, _command_supp + _command_supp ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO), sizeof(feat_str)); @@ -1489,8 +1484,9 @@ static int create_string_list_rdb_entry_string( string_list_join_concat(output_label, str_len, str_list, "|"); - fill_pathname_noext(tmp, desc, ": ", path_size); - strlcat(tmp, actual_string, path_size); + fill_pathname_join_concat_noext(tmp, desc, ": ", + actual_string, + path_size); menu_entries_append_enum(list, tmp, output_label, enum_idx, 0, 0, 0); @@ -1684,11 +1680,11 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info) if (db_info_entry->name) { - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME), ": ", + db_info_entry->name, sizeof(tmp)); - strlcat(tmp, db_info_entry->name, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_NAME), MENU_ENUM_LABEL_RDB_ENTRY_NAME, @@ -1696,11 +1692,11 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info) } if (db_info_entry->description) { - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DESCRIPTION), ": ", + db_info_entry->description, sizeof(tmp)); - strlcat(tmp, db_info_entry->description, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION), MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION, @@ -1708,11 +1704,11 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info) } if (db_info_entry->genre) { - fill_pathname_noext(tmp, + fill_pathname_join_concat_noext(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GENRE), ": ", + db_info_entry->genre, sizeof(tmp)); - strlcat(tmp, db_info_entry->genre, sizeof(tmp)); menu_entries_append_enum(info->list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_GENRE), MENU_ENUM_LABEL_RDB_ENTRY_GENRE,