mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
(RGUI) rgui_update_menu_sublabel - use strtok_r instead of string_list
This commit is contained in:
parent
24f8bd1638
commit
5a863652b6
@ -7164,34 +7164,31 @@ static void rgui_update_menu_sublabel(rgui_t *rgui, size_t selection)
|
|||||||
|
|
||||||
if (!string_is_empty(entry.sublabel))
|
if (!string_is_empty(entry.sublabel))
|
||||||
{
|
{
|
||||||
size_t line_index;
|
char *tok, *save;
|
||||||
static const char* const
|
static const char* const
|
||||||
sublabel_spacer = RGUI_TICKER_SPACER;
|
sublabel_spacer = RGUI_TICKER_SPACER;
|
||||||
bool prev_line_empty = true;
|
bool prev_line_empty = true;
|
||||||
|
char *entry_sublabel_cpy = strdup(entry.sublabel);
|
||||||
|
|
||||||
/* Sanitise sublabel
|
/* Sanitise sublabel
|
||||||
* > Replace newline characters with standard delimiter
|
* > Replace newline characters with standard delimiter
|
||||||
* > Remove whitespace surrounding each sublabel line */
|
* > Remove whitespace surrounding each sublabel line */
|
||||||
struct string_list list = {0};
|
tok = strtok_r(entry_sublabel_cpy, "\n", &save);
|
||||||
|
|
||||||
string_list_initialize(&list);
|
while (tok)
|
||||||
|
|
||||||
if (string_split_noalloc(&list, entry.sublabel, "\n"))
|
|
||||||
{
|
{
|
||||||
for (line_index = 0; line_index < list.size; line_index++)
|
const char *line = string_trim_whitespace(tok);
|
||||||
|
if (!string_is_empty(line))
|
||||||
{
|
{
|
||||||
const char *line = string_trim_whitespace(
|
if (!prev_line_empty)
|
||||||
list.elems[line_index].data);
|
strlcat(rgui->menu_sublabel, sublabel_spacer, sizeof(rgui->menu_sublabel));
|
||||||
if (!string_is_empty(line))
|
strlcat(rgui->menu_sublabel, line, sizeof(rgui->menu_sublabel));
|
||||||
{
|
prev_line_empty = false;
|
||||||
if (!prev_line_empty)
|
|
||||||
strlcat(rgui->menu_sublabel, sublabel_spacer, sizeof(rgui->menu_sublabel));
|
|
||||||
strlcat(rgui->menu_sublabel, line, sizeof(rgui->menu_sublabel));
|
|
||||||
prev_line_empty = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
tok = strtok_r(NULL, "\n", &save);
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_deinitialize(&list);
|
free(entry_sublabel_cpy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user