From 6e42f4485d0860ed8b6ffab41b5f07d0d9fd15ab Mon Sep 17 00:00:00 2001 From: Themaister Date: Tue, 4 Mar 2014 10:17:00 +0100 Subject: [PATCH] Join core info lists with new string_list_join_concat(). --- file_path.c | 16 ++++++++++++++++ file_path.h | 1 + frontend/menu/menu_common.c | 27 ++++++++++++++++++--------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/file_path.c b/file_path.c index 214181ea06..d2d304557c 100644 --- a/file_path.c +++ b/file_path.c @@ -211,6 +211,22 @@ bool string_list_append(struct string_list *list, const char *elem, union string return true; } +void string_list_join_concat(char *buffer, size_t size, const struct string_list *list, const char *sep) +{ + size_t len = strlen(buffer); + rarch_assert(len < size); + buffer += len; + size -= len; + + size_t i; + for (i = 0; i < list->size; i++) + { + strlcat(buffer, list->elems[i].data, size); + if ((i + 1) < list->size) + strlcat(buffer, sep, size); + } +} + struct string_list *string_split(const char *str, const char *delim) { char *copy = NULL; diff --git a/file_path.h b/file_path.h index 32f04fd864..eceadf2dae 100644 --- a/file_path.h +++ b/file_path.h @@ -60,6 +60,7 @@ struct string_list *string_split(const char *str, const char *delim); struct string_list *string_list_new(void); bool string_list_append(struct string_list *list, const char *elem, union string_list_elem_attr attr); void string_list_free(struct string_list *list); +void string_list_join_concat(char *buffer, size_t size, const struct string_list *list, const char *sep); bool path_is_directory(const char *path); bool path_file_exists(const char *path); diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index a46113042c..df146da60c 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -1933,17 +1933,26 @@ void menu_populate_entries(void *data, unsigned menu_type) rgui->core_info_current.display_name ? rgui->core_info_current.display_name : ""); file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); - snprintf(tmp, sizeof(tmp), "Authors: %s", - rgui->core_info_current.authors ? rgui->core_info_current.authors : ""); - file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); + if (rgui->core_info_current.authors_list) + { + strlcpy(tmp, "Authors: ", sizeof(tmp)); + string_list_join_concat(tmp, sizeof(tmp), rgui->core_info_current.authors_list, ", "); + file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); + } - snprintf(tmp, sizeof(tmp), "Permissions: %s", - rgui->core_info_current.permissions ? rgui->core_info_current.permissions : ""); - file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); + if (rgui->core_info_current.permissions_list) + { + strlcpy(tmp, "Permissions: ", sizeof(tmp)); + string_list_join_concat(tmp, sizeof(tmp), rgui->core_info_current.permissions_list, ", "); + file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); + } - snprintf(tmp, sizeof(tmp), "Supported extensions: %s", - rgui->core_info_current.supported_extensions ? rgui->core_info_current.supported_extensions : ""); - file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); + if (rgui->core_info_current.supported_extensions_list) + { + strlcpy(tmp, "Supported extensions: ", sizeof(tmp)); + string_list_join_concat(tmp, sizeof(tmp), rgui->core_info_current.supported_extensions_list, ", "); + file_list_push(rgui->selection_buf, tmp, RGUI_SETTINGS_CORE_INFO_NONE, 0); + } if (rgui->core_info_current.firmware_count > 0) {