Skip to content

Commit

Permalink
print_buf_lines - extended was never used as a parameter (always set to
Browse files Browse the repository at this point in the history
false), so change function
  • Loading branch information
LibretroAdmin committed Dec 23, 2024
1 parent 72acdb4 commit 1340e75
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 16 deletions.
89 changes: 74 additions & 15 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -11939,13 +11939,14 @@ static unsigned menu_displaylist_build_shader_parameter(
}

#ifdef HAVE_NETWORKING
static unsigned print_buf_lines(file_list_t *list, char *buf,
const char *label, int buf_size,
#if 0
static size_t print_buf_lines(file_list_t *list, char *buf,
const char *label, size_t buf_size,
enum msg_file_type type, bool append, bool extended)
{
char c;
unsigned count = 0;
int i = 0;
size_t i;
size_t count = 0;
char *line_start = buf;

if (!buf || !buf_size)
Expand Down Expand Up @@ -12057,6 +12058,64 @@ static unsigned print_buf_lines(file_list_t *list, char *buf,

return count;
}
#else
static size_t print_buf_lines(file_list_t *list, char *buf,
const char *label, size_t buf_size,
enum msg_file_type type, bool append)
{
char c;
size_t i;
size_t count = 0;
char *line_start = buf;

if (!buf || !buf_size)
return 0;

for (i = 0; i < buf_size; i++)
{
size_t ln;

/* The end of the buffer, print the last bit */
if (*(buf + i) == '\0')
break;

if (*(buf + i) != '\n')
continue;

/* Found a line ending, print the line and compute new line_start */
c = *(buf + i + 1); /* Save the next character */
*(buf + i + 1) = '\0'; /* Replace with \0 */

/* We need to strip the newline. */
ln = strlen(line_start) - 1;
if (line_start[ln] == '\n')
line_start[ln] = '\0';

if (append)
{
if (menu_entries_append(list, line_start, label,
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0, NULL))
count++;
}
else
{
menu_entries_prepend(list, line_start, label,
MENU_ENUM_LABEL_URL_ENTRY, type, 0, 0);
count++;
}

/* Restore the saved character */
*(buf + i + 1) = c;
line_start = buf + i + 1;
}

if (append && type != FILE_TYPE_DOWNLOAD_LAKKA)
file_list_sort_on_alt(list);
/* If the buffer was completely full, and didn't end
* with a newline, just ignore the partial last line. */
return count;
}
#endif

static unsigned menu_displaylist_netplay_kick(file_list_t *list)
{
Expand Down Expand Up @@ -13264,8 +13323,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
menu_entries_clear(info->list);
#ifdef HAVE_NETWORKING
count = print_buf_lines(info->list, menu->core_buf, "",
(int)menu->core_len, FILE_TYPE_DOWNLOAD_CORE_CONTENT,
true, false);
menu->core_len, FILE_TYPE_DOWNLOAD_CORE_CONTENT,
true);

if (count == 0)
menu_entries_append(info->list,
Expand Down Expand Up @@ -13298,8 +13357,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,

if ((count = print_buf_lines(
info->list, menu->core_buf, new_label,
(int)menu->core_len, FILE_TYPE_DOWNLOAD_URL,
false, false)) == 0)
menu->core_len, FILE_TYPE_DOWNLOAD_URL,
false)) == 0)
menu_entries_append(info->list,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
Expand Down Expand Up @@ -13327,7 +13386,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
"cores", sizeof(new_label));

if ((count = print_buf_lines(info->list, menu->core_buf, new_label,
(int)menu->core_len, FILE_TYPE_DOWNLOAD_URL, true, false)) == 0)
menu->core_len, FILE_TYPE_DOWNLOAD_URL, true)) == 0)
menu_entries_append(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),
Expand All @@ -13344,8 +13403,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
menu_entries_clear(info->list);
#ifdef HAVE_NETWORKING
count = print_buf_lines(info->list, menu->core_buf, "",
(int)menu->core_len, FILE_TYPE_DOWNLOAD_CORE_SYSTEM_FILES,
true, false);
menu->core_len, FILE_TYPE_DOWNLOAD_CORE_SYSTEM_FILES,
true);

if (count == 0)
menu_entries_append(info->list,
Expand Down Expand Up @@ -13448,8 +13507,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
menu_entries_clear(info->list);
#ifdef HAVE_NETWORKING
count = print_buf_lines(info->list, menu->core_buf, "",
(int)menu->core_len, FILE_TYPE_DOWNLOAD_THUMBNAIL_CONTENT,
true, false);
menu->core_len, FILE_TYPE_DOWNLOAD_THUMBNAIL_CONTENT,
true);

if (count == 0)
menu_entries_append(info->list,
Expand Down Expand Up @@ -13486,8 +13545,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
menu_entries_clear(info->list);
#ifdef HAVE_NETWORKING
count = print_buf_lines(info->list, menu->core_buf, "",
(int)menu->core_len, FILE_TYPE_DOWNLOAD_LAKKA,
true, false);
menu->core_len, FILE_TYPE_DOWNLOAD_LAKKA,
true);

if (count == 0)
menu_entries_append(info->list,
Expand Down
3 changes: 2 additions & 1 deletion menu/menu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,10 @@ typedef struct

const menu_ctx_driver_t *driver_ctx;
void *userdata;

char *core_buf;
size_t core_len;

size_t core_len;
/* This is used for storing intermediary variables
* that get used later on during menu actions -
* for instance, selecting a shader pass for a shader
Expand Down

0 comments on commit 1340e75

Please sign in to comment.