Join core info lists with new string_list_join_concat().

This commit is contained in:
Themaister 2014-03-04 10:17:00 +01:00
parent 86fa251cd5
commit 6e42f4485d
3 changed files with 35 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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)
{