(menu_displaylist)

* Don't attempt to call msg_hash_to_str in a loop, cache it once outside
inside a local variable
* Do away with some spurious snprintf usage for RGUI (truncation does not matter
as pointed out by jdgleaver, so we needn't be concerned)
This commit is contained in:
LibretroAdmin 2022-08-27 09:02:43 +02:00
parent c0221ae340
commit 388183d971
1 changed files with 176 additions and 146 deletions

View File

@ -547,9 +547,7 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info,
tmp[len ] = ':'; tmp[len ] = ':';
tmp[len+1] = ' '; tmp[len+1] = ' ';
tmp[len+2] = '\0'; tmp[len+2] = '\0';
strlcat(tmp, strlcat(tmp, info_list[i].name, sizeof(tmp));
info_list[i].name,
sizeof(tmp));
if (menu_entries_append_enum(info->list, tmp, "", if (menu_entries_append_enum(info->list, tmp, "",
MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_ENUM_LABEL_CORE_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
@ -704,6 +702,12 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info,
if (update_missing_firmware) if (update_missing_firmware)
{ {
const char *missing_optional = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING_OPTIONAL);
const char *missing_required = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING_REQUIRED);
const char *present_optional = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT_OPTIONAL);
const char *present_required = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT_REQUIRED);
const char *rdb_entry_name =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME);
size_t len = strlcpy(tmp, size_t len = strlcpy(tmp,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE),
sizeof(tmp)); sizeof(tmp));
@ -723,17 +727,19 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info,
continue; continue;
snprintf(tmp, sizeof(tmp), "(!) %s %s", snprintf(tmp, sizeof(tmp), "(!) %s %s",
core_info->firmware[i].missing ? core_info->firmware[i].missing ?
(core_info->firmware[i].optional ? (
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING_OPTIONAL) : core_info->firmware[i].optional
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_MISSING_REQUIRED)) ? missing_optional
: missing_required)
: :
(core_info->firmware[i].optional ? (
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT_OPTIONAL) : core_info->firmware[i].optional
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PRESENT_REQUIRED)), ? present_optional
: present_required),
core_info->firmware[i].desc ? core_info->firmware[i].desc ?
core_info->firmware[i].desc : core_info->firmware[i].desc :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME) rdb_entry_name
); );
if (menu_entries_append_enum(info->list, tmp, "", if (menu_entries_append_enum(info->list, tmp, "",
@ -1136,6 +1142,10 @@ static unsigned menu_displaylist_parse_core_option_dropdown_list(
core_option_manager_t *coreopts = NULL; core_option_manager_t *coreopts = NULL;
struct core_option *option = NULL; struct core_option *option = NULL;
const char *val = NULL; const char *val = NULL;
const char *lbl_enabled = NULL;
const char *lbl_disabled = NULL;
const char *val_on_str = NULL;
const char *val_off_str = NULL;
unsigned j; unsigned j;
/* Fetch options */ /* Fetch options */
@ -1168,6 +1178,11 @@ static unsigned menu_displaylist_parse_core_option_dropdown_list(
string_is_empty(val)) string_is_empty(val))
goto end; goto end;
lbl_enabled = msg_hash_to_str(MENU_ENUM_LABEL_ENABLED);
lbl_disabled = msg_hash_to_str(MENU_ENUM_LABEL_DISABLED);
val_on_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON);
val_off_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF);
/* Loop over all option values */ /* Loop over all option values */
for (j = 0; j < option->vals->size; j++) for (j = 0; j < option->vals->size; j++)
{ {
@ -1176,10 +1191,10 @@ static unsigned menu_displaylist_parse_core_option_dropdown_list(
if (!string_is_empty(val_label_str)) if (!string_is_empty(val_label_str))
{ {
if (string_is_equal(val_label_str, msg_hash_to_str(MENU_ENUM_LABEL_ENABLED))) if (string_is_equal(val_label_str, lbl_enabled))
val_label_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON); val_label_str = val_on_str;
else if (string_is_equal(val_label_str, msg_hash_to_str(MENU_ENUM_LABEL_DISABLED))) else if (string_is_equal(val_label_str, lbl_disabled))
val_label_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF); val_label_str = val_off_str;
if (menu_entries_append_enum(info->list, if (menu_entries_append_enum(info->list,
val_label_str, val_label_str,
@ -1450,6 +1465,7 @@ static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t *
if (core_info_get_list(&core_info_list) && if (core_info_get_list(&core_info_list) &&
core_info_list) core_info_list)
{ {
const char *detect_core_str = NULL;
const core_info_t *core_infos = NULL; const core_info_t *core_infos = NULL;
size_t core_infos_size = 0; size_t core_infos_size = 0;
size_t core_idx = 0; size_t core_idx = 0;
@ -1462,6 +1478,9 @@ static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t *
core_info_list_get_supported_cores(core_info_list, core_info_list_get_supported_cores(core_info_list,
content_path, &core_infos, &core_infos_size); content_path, &core_infos, &core_infos_size);
detect_core_str = msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE);
for (core_idx = 0; core_idx < core_infos_size; core_idx++) for (core_idx = 0; core_idx < core_infos_size; core_idx++)
{ {
const core_info_t *core_info = (const core_info_t*)&core_infos[core_idx]; const core_info_t *core_info = (const core_info_t*)&core_infos[core_idx];
@ -1516,9 +1535,7 @@ static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t *
{ {
size_t _len; size_t _len;
char entry_alt_text[256]; char entry_alt_text[256];
_len = strlcpy(entry_alt_text, _len = strlcpy(entry_alt_text, detect_core_str,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE),
sizeof(entry_alt_text)); sizeof(entry_alt_text));
entry_alt_text[_len ] = ' '; entry_alt_text[_len ] = ' ';
entry_alt_text[_len+1] = '('; entry_alt_text[_len+1] = '(';
@ -2118,6 +2135,8 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
{SUPPORTS_V4L2 , MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_V4L2_SUPPORT}, {SUPPORTS_V4L2 , MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_V4L2_SUPPORT},
{SUPPORTS_LIBUSB , MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBUSB_SUPPORT}, {SUPPORTS_LIBUSB , MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBUSB_SUPPORT},
}; };
const char *val_yes_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES);
const char *val_no_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO);
for (i = 0; i < ARRAY_SIZE(info_list); i++) for (i = 0; i < ARRAY_SIZE(info_list); i++)
{ {
@ -2129,9 +2148,7 @@ static unsigned menu_displaylist_parse_system_info(file_list_t *list)
feat_str[len+1] = ' '; feat_str[len+1] = ' ';
feat_str[len+2] = '\0'; feat_str[len+2] = '\0';
strlcat(feat_str, strlcat(feat_str,
info_list[i].enabled ? info_list[i].enabled ? val_yes_str : val_no_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_YES) :
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO),
sizeof(feat_str)); sizeof(feat_str));
if (menu_entries_append_enum(list, feat_str, "", if (menu_entries_append_enum(list, feat_str, "",
MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY,
@ -2745,14 +2762,17 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
if (db_info_entry->developer) if (db_info_entry->developer)
{ {
const char *val_rdb_entry_dev =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DEVELOPER);
const char *rdb_entry_dev =
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER);
for (k = 0; k < db_info_entry->developer->size; k++) for (k = 0; k < db_info_entry->developer->size; k++)
{ {
if (db_info_entry->developer->elems[k].data) if (db_info_entry->developer->elems[k].data)
{ {
if (create_string_list_rdb_entry_string( if (create_string_list_rdb_entry_string(
MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER, MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DEVELOPER), val_rdb_entry_dev, rdb_entry_dev,
msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DEVELOPER),
db_info_entry->developer->elems[k].data, db_info_entry->developer->elems[k].data,
info->path, info->list) == -1) info->path, info->list) == -1)
goto error; goto error;
@ -4901,15 +4921,14 @@ static unsigned menu_displaylist_parse_content_information(
if (settings->bools.cheevos_enable && settings->arrays.cheevos_token[0] && if (settings->bools.cheevos_enable && settings->arrays.cheevos_token[0] &&
!string_is_empty(loaded_content_path)) !string_is_empty(loaded_content_path))
{ {
size_t _len = strlcpy(tmp, const char *cheevos_hash_str =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH);
sizeof(tmp)); size_t _len = strlcpy(tmp, cheevos_hash_str, sizeof(tmp));
tmp[_len ] = ':'; tmp[_len ] = ':';
tmp[_len+1] = ' '; tmp[_len+1] = ' ';
tmp[_len+2] = '\n'; tmp[_len+2] = '\n';
strlcat(tmp, rcheevos_get_hash(), sizeof(tmp)); strlcat(tmp, rcheevos_get_hash(), sizeof(tmp));
if (menu_entries_append_enum(info->list, tmp, if (menu_entries_append_enum(info->list, tmp, cheevos_hash_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH),
MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH, MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH,
0, 0, 0)) 0, 0, 0))
count++; count++;
@ -4993,6 +5012,10 @@ static int menu_displaylist_parse_input_device_type_list(
{ {
const struct retro_controller_description *desc = NULL; const struct retro_controller_description *desc = NULL;
const char *name = NULL; const char *name = NULL;
const char *val_none = NULL;
const char *val_retropad = NULL;
const char *val_retropad_an = NULL;
const char *val_unknown = NULL;
rarch_system_info_t *system = &runloop_state_get_ptr()->system; rarch_system_info_t *system = &runloop_state_get_ptr()->system;
@ -5020,6 +5043,11 @@ static int menu_displaylist_parse_input_device_type_list(
types = libretro_device_get_size(devices, ARRAY_SIZE(devices), port); types = libretro_device_get_size(devices, ARRAY_SIZE(devices), port);
current_device = input_config_get_device(port); current_device = input_config_get_device(port);
val_none = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE);
val_retropad = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RETROPAD);
val_retropad_an= msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RETROPAD_WITH_ANALOG);
val_unknown = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN);
for (i = 0; i < types; i++) for (i = 0; i < types; i++)
{ {
snprintf(device_id, sizeof(device_id), "%d", devices[i]); snprintf(device_id, sizeof(device_id), "%d", devices[i]);
@ -5040,16 +5068,16 @@ static int menu_displaylist_parse_input_device_type_list(
switch (devices[i]) switch (devices[i])
{ {
case RETRO_DEVICE_NONE: case RETRO_DEVICE_NONE:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE); name = val_none;
break; break;
case RETRO_DEVICE_JOYPAD: case RETRO_DEVICE_JOYPAD:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RETROPAD); name = val_retropad;
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RETROPAD_WITH_ANALOG); name = val_retropad_an;
break; break;
default: default:
name = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN); name = val_unknown;
break; break;
} }
} }
@ -5093,6 +5121,12 @@ end:
static int menu_displaylist_parse_input_device_index_list( static int menu_displaylist_parse_input_device_index_list(
menu_displaylist_info_t *info, settings_t *settings) menu_displaylist_info_t *info, settings_t *settings)
{ {
char device_id[10];
char device_label[128];
const char *device_name = NULL;
const char *val_port = NULL;
const char *val_na = NULL;
const char *val_disabled = NULL;
rarch_system_info_t *system = &runloop_state_get_ptr()->system; rarch_system_info_t *system = &runloop_state_get_ptr()->system;
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path); enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx); rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
@ -5105,22 +5139,22 @@ static int menu_displaylist_parse_input_device_index_list(
int current_device = -1; int current_device = -1;
unsigned max_devices = input_config_get_device_count(); unsigned max_devices = input_config_get_device_count();
char device_id[10];
char device_label[128];
const char *device_name = NULL;
device_id[0] = '\0'; device_id[0] = '\0';
device_label[0] = '\0'; device_label[0] = '\0';
if (!system || !settings || !setting) if (!system || !settings || !setting)
goto end; goto end;
port = setting->index_offset; port = setting->index_offset;
map = settings->uints.input_joypad_index[port]; map = settings->uints.input_joypad_index[port];
if (port >= MAX_USERS) if (port >= MAX_USERS)
goto end; goto end;
val_disabled = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED);
val_na = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE);
val_port = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT);
for (i = max_devices + 1; i--;) for (i = max_devices + 1; i--;)
{ {
snprintf(device_id, sizeof(device_id), "%d", i); snprintf(device_id, sizeof(device_id), "%d", i);
@ -5147,13 +5181,11 @@ static int menu_displaylist_parse_input_device_index_list(
strlcpy(device_label, device_name, sizeof(device_label)); strlcpy(device_label, device_name, sizeof(device_label));
} }
else else
snprintf(device_label, sizeof(device_label), "%s (%s %u)", snprintf(device_label, sizeof(device_label), "%s (%s %u)", val_na,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), val_port, map);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT),
map);
} }
else else
strlcpy(device_label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), sizeof(device_label)); strlcpy(device_label, val_disabled, sizeof(device_label));
/* Add menu entry */ /* Add menu entry */
if (menu_entries_append_enum(info->list, if (menu_entries_append_enum(info->list,
@ -5521,12 +5553,13 @@ static void bluetooth_scan_callback(retro_task_t *task,
void *user_data, const char *error) void *user_data, const char *error)
{ {
unsigned i; unsigned i;
file_list_t *file_list = NULL; file_list_t *file_list = NULL;
struct string_list *device_list = NULL; struct string_list *device_list = NULL;
const char *msg_connect_bluetooth =
const char *path = NULL; msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_BLUETOOTH);
const char *label = NULL; const char *path = NULL;
unsigned menu_type = 0; const char *label = NULL;
unsigned menu_type = 0;
menu_entries_get_last_stack(&path, &label, &menu_type, NULL, NULL); menu_entries_get_last_stack(&path, &label, &menu_type, NULL, NULL);
@ -5546,8 +5579,7 @@ static void bluetooth_scan_callback(retro_task_t *task,
{ {
const char *device = device_list->elems[i].data; const char *device = device_list->elems[i].data;
menu_entries_append_enum(file_list, menu_entries_append_enum(file_list,
device, device, msg_connect_bluetooth,
msg_hash_to_str(MENU_ENUM_LABEL_CONNECT_BLUETOOTH),
MENU_ENUM_LABEL_CONNECT_BLUETOOTH, MENU_ENUM_LABEL_CONNECT_BLUETOOTH,
MENU_BLUETOOTH, 0, 0); MENU_BLUETOOTH, 0, 0);
} }
@ -5928,7 +5960,6 @@ static unsigned menu_displaylist_populate_subsystem(
static const char utf8_star_char[] = "\xE2\x98\x85"; static const char utf8_star_char[] = "\xE2\x98\x85";
#endif #endif
unsigned i = 0; unsigned i = 0;
int n = 0;
bool is_rgui = string_is_equal(menu_driver, "rgui"); bool is_rgui = string_is_equal(menu_driver, "rgui");
/* Select appropriate 'star' marker for subsystem menu entries /* Select appropriate 'star' marker for subsystem menu entries
@ -5953,42 +5984,29 @@ static unsigned menu_displaylist_populate_subsystem(
{ {
if (content_get_subsystem_rom_id() < subsystem->num_roms) if (content_get_subsystem_rom_id() < subsystem->num_roms)
{ {
snprintf(s, sizeof(s), /* TODO/FIXME - localize string */
"Load %s %s", size_t _len = strlcpy(s, "Load", sizeof(s));
subsystem->desc, s[_len ] = ' ';
star_char); s[_len+1] = '\0';
_len = strlcat(s, subsystem->desc, sizeof(s));
s[_len ] = ' ';
s[_len+1] = '\0';
strlcat(s, star_char, sizeof(s));
/* If using RGUI with sublabels disabled, add the /* If using RGUI with sublabels disabled, add the
* appropriate text to the menu entry itself... */ * appropriate text to the menu entry itself... */
if (is_rgui && !menu_show_sublabels) if (is_rgui && !menu_show_sublabels)
{ {
char tmp[PATH_MAX_LENGTH]; strlcat(s, " [", sizeof(s));
/* TODO/FIXME - localize */
n = snprintf(tmp, sizeof(tmp), _len = strlcat(s, "Current Content:", sizeof(s));
"%s [%s %s]", s, "Current Content:", s[_len ] = ' ';
subsystem->roms[content_get_subsystem_rom_id()].desc); s[_len+1] = '\0';
_len = strlcat(s,
/* Stupid GCC will warn about snprintf() truncation even though subsystem->roms[content_get_subsystem_rom_id()].desc,
* we couldn't care less about it (if the menu entry label gets sizeof(s));
* truncated then the string will already be too long to view in s[_len ] = ']';
* any usable manner on screen, so the fact that the end is s[_len+1] = '\0';
* missing is irrelevant). There are two ways to silence this noise:
* 1) Make the destination buffers large enough that text cannot be
* truncated. This is a waste of memory.
* 2) Check the snprintf() return value (and take action). This is
* the most harmless option, so we just print a warning if anything
* is truncated.
* To reiterate: The actual warning generated here is pointless, and
* should be ignored. */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
{
if (verbosity_is_enabled())
{
RARCH_WARN("Menu subsystem entry: Description label truncated.\n");
}
}
strlcpy(s, tmp, sizeof(s));
} }
if (menu_entries_append_enum(list, if (menu_entries_append_enum(list,
@ -6000,10 +6018,14 @@ static unsigned menu_displaylist_populate_subsystem(
} }
else else
{ {
snprintf(s, sizeof(s), /* TODO/FIXME - localize string */
"Start %s %s", size_t _len = strlcpy(s, "Start", sizeof(s));
subsystem->desc, s[_len ] = ' ';
star_char); s[_len+1] = '\0';
_len = strlcat(s, subsystem->desc, sizeof(s));
s[_len ] = ' ';
s[_len+1] = '\0';
strlcat(s, star_char, sizeof(s));
/* If using RGUI with sublabels disabled, add the /* If using RGUI with sublabels disabled, add the
* appropriate text to the menu entry itself... */ * appropriate text to the menu entry itself... */
@ -6025,18 +6047,9 @@ static unsigned menu_displaylist_populate_subsystem(
if (!string_is_empty(rom_buff)) if (!string_is_empty(rom_buff))
{ {
n = snprintf(tmp, sizeof(tmp), "%s [%s]", s, rom_buff); strlcat(s, " [", sizeof(s));
strlcat(s, rom_buff, sizeof(s));
/* More snprintf() gcc warning suppression... */ strlcat(s, "]", sizeof(s));
if ((n < 0) || (n >= PATH_MAX_LENGTH))
{
if (verbosity_is_enabled())
{
RARCH_WARN("Menu subsystem entry: Description label truncated.\n");
}
}
strlcpy(s, tmp, sizeof(s));
} }
} }
@ -6061,22 +6074,12 @@ static unsigned menu_displaylist_populate_subsystem(
* anyway), but no harm in being safe... */ * anyway), but no harm in being safe... */
if (subsystem->num_roms > 0) if (subsystem->num_roms > 0)
{ {
char tmp[PATH_MAX_LENGTH]; strlcat(s, " [", sizeof(s));
/* TODO/FIXME - localize */
n = snprintf(tmp, sizeof(tmp), strlcat(s, "Current Content:", sizeof(s));
"%s [%s %s]", s, "Current Content:", strlcat(s, " ", sizeof(s));
subsystem->roms[0].desc); strlcat(s, subsystem->roms[0].desc, sizeof(s));
strlcat(s, "]", sizeof(s));
/* More snprintf() gcc warning suppression... */
if ((n < 0) || (n >= PATH_MAX_LENGTH))
{
if (verbosity_is_enabled())
{
RARCH_WARN("Menu subsystem entry: Description label truncated.\n");
}
}
strlcpy(s, tmp, sizeof(s));
} }
} }
@ -7231,13 +7234,14 @@ unsigned menu_displaylist_build_list(
{ {
size_t i; size_t i;
char buf[768]; char buf[768];
const char *msg_intf = msg_hash_to_str(MSG_INTERFACE);
for (i = 0; i < interfaces.size; i++) for (i = 0; i < interfaces.size; i++)
{ {
struct net_ifinfo_entry *entry = &interfaces.entries[i]; struct net_ifinfo_entry *entry = &interfaces.entries[i];
snprintf(buf, sizeof(buf), "%s (%s) : %s\n", snprintf(buf, sizeof(buf), "%s (%s) : %s\n", msg_intf,
msg_hash_to_str(MSG_INTERFACE), entry->name, entry->host); entry->name, entry->host);
if (menu_entries_append_enum(list, buf, entry->name, if (menu_entries_append_enum(list, buf, entry->name,
MENU_ENUM_LABEL_NETWORK_INFO_ENTRY, MENU_ENUM_LABEL_NETWORK_INFO_ENTRY,
MENU_SETTINGS_CORE_INFO_NONE, 0, 0)) MENU_SETTINGS_CORE_INFO_NONE, 0, 0))
@ -10510,6 +10514,11 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
char country[8]; char country[8];
const char *room_type; const char *room_type;
struct netplay_room *room; struct netplay_room *room;
const char *msg_int_nc = NULL;
const char *msg_int_relay = NULL;
const char *msg_int = NULL;
const char *msg_local = NULL;
const char *msg_room_pwd = NULL;
unsigned count = 0; unsigned count = 0;
core_info_list_t *coreinfos = NULL; core_info_list_t *coreinfos = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
@ -10580,6 +10589,12 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
core_info_get_list(&coreinfos); core_info_get_list(&coreinfos);
msg_int_nc = msg_hash_to_str(MSG_INTERNET_NOT_CONNECTABLE);
msg_int_relay = msg_hash_to_str(MSG_INTERNET_RELAY);
msg_int = msg_hash_to_str(MSG_INTERNET);
msg_local = msg_hash_to_str(MSG_LOCAL);
msg_room_pwd = msg_hash_to_str(MSG_ROOM_PASSWORDED);
for (i = 0; i < net_st->room_count; i++) for (i = 0; i < net_st->room_count; i++)
{ {
room = &net_st->room_list[i]; room = &net_st->room_list[i];
@ -10599,14 +10614,14 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
if (show_only_connectable) if (show_only_connectable)
continue; continue;
room_type = msg_hash_to_str(MSG_INTERNET_NOT_CONNECTABLE); room_type = msg_int_nc;
} }
else if (room->lan) else if (room->lan)
room_type = msg_hash_to_str(MSG_LOCAL); room_type = msg_local;
else if (room->host_method == NETPLAY_HOST_METHOD_MITM) else if (room->host_method == NETPLAY_HOST_METHOD_MITM)
room_type = msg_hash_to_str(MSG_INTERNET_RELAY); room_type = msg_int_relay;
else else
room_type = msg_hash_to_str(MSG_INTERNET); room_type = msg_int;
/* Get rid of any room running a core that we don't have installed, /* Get rid of any room running a core that we don't have installed,
if the user opt-in. */ if the user opt-in. */
@ -10628,8 +10643,7 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list)
{ {
if (!show_passworded) if (!show_passworded)
continue; continue;
snprintf(passworded, sizeof(passworded), "[%s] ", snprintf(passworded, sizeof(passworded), "[%s] ", msg_room_pwd);
msg_hash_to_str(MSG_ROOM_PASSWORDED));
} }
else else
*passworded = '\0'; *passworded = '\0';
@ -11007,6 +11021,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG) if (device == RETRO_DEVICE_JOYPAD || device == RETRO_DEVICE_ANALOG)
{ {
const char *msg_val_port =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT);
for (j = 0; j < RARCH_ANALOG_BIND_LIST_END; j++) for (j = 0; j < RARCH_ANALOG_BIND_LIST_END; j++)
{ {
char desc_label[400]; char desc_label[400];
@ -11032,8 +11048,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
const struct retro_keybind *keyptr = const struct retro_keybind *keyptr =
&input_config_binds[port][retro_id]; &input_config_binds[port][retro_id];
size_t _len = strlcpy(desc_label, size_t _len = strlcpy(desc_label,
msg_hash_to_str(keyptr->enum_idx), msg_hash_to_str(keyptr->enum_idx),
sizeof(desc_label)); sizeof(desc_label));
desc_label[_len ] = ' '; desc_label[_len ] = ' ';
desc_label[_len+1] = '\0'; desc_label[_len+1] = '\0';
strlcat(desc_label, descriptor, sizeof(desc_label)); strlcat(desc_label, descriptor, sizeof(desc_label));
@ -11047,8 +11063,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
&& !settings->bools.menu_show_sublabels) && !settings->bools.menu_show_sublabels)
{ {
snprintf(desc_label, sizeof(desc_label), snprintf(desc_label, sizeof(desc_label),
"%s [%s %u]", descriptor, "%s [%s %u]", descriptor, msg_val_port, port+1);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), port + 1);
strlcpy(descriptor, desc_label, sizeof(descriptor)); strlcpy(descriptor, desc_label, sizeof(descriptor));
} }
@ -11062,6 +11077,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
} }
else if (device == RETRO_DEVICE_KEYBOARD) else if (device == RETRO_DEVICE_KEYBOARD)
{ {
const char *val_port = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT);
for (j = 0; j < RARCH_ANALOG_BIND_LIST_END; j++) for (j = 0; j < RARCH_ANALOG_BIND_LIST_END; j++)
{ {
char desc_label[400]; char desc_label[400];
@ -11087,8 +11103,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
const struct retro_keybind *keyptr = const struct retro_keybind *keyptr =
&input_config_binds[port][retro_id]; &input_config_binds[port][retro_id];
size_t _len = strlcpy(desc_label, size_t _len = strlcpy(desc_label,
msg_hash_to_str(keyptr->enum_idx), msg_hash_to_str(keyptr->enum_idx),
sizeof(desc_label)); sizeof(desc_label));
desc_label[_len ] = ' '; desc_label[_len ] = ' ';
desc_label[_len+1] = '\0'; desc_label[_len+1] = '\0';
strlcat(desc_label, descriptor, sizeof(desc_label)); strlcat(desc_label, descriptor, sizeof(desc_label));
@ -11102,9 +11118,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
&& !settings->bools.menu_show_sublabels) && !settings->bools.menu_show_sublabels)
{ {
snprintf(desc_label, sizeof(desc_label), "%s [%s %u]", snprintf(desc_label, sizeof(desc_label), "%s [%s %u]",
descriptor, descriptor, val_port, port + 1);
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT),
port + 1);
strlcpy(descriptor, desc_label, sizeof(descriptor)); strlcpy(descriptor, desc_label, sizeof(descriptor));
} }
@ -11868,6 +11882,19 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
if (video_shader_enable) if (video_shader_enable)
{ {
const char *val_shdr =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER);
const char *shdr_pass =
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PASS);
const char *shdr_filter_pass =
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS);
const char *shdr_scale_pass =
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS);
const char *val_filter =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILTER);
const char *val_scale =
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCALE);
if (frontend_driver_can_watch_for_changes()) if (frontend_driver_can_watch_for_changes())
{ {
if (menu_entries_append_enum(info->list, if (menu_entries_append_enum(info->list,
@ -11929,30 +11956,33 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
for (i = 0; i < pass_count; i++) for (i = 0; i < pass_count; i++)
{ {
size_t _len;
char buf_tmp[64]; char buf_tmp[64];
char buf[128]; char buf[128];
buf[0] = buf_tmp[0] = '\0'; buf_tmp[0] = '\0';
snprintf(buf_tmp, sizeof(buf_tmp), snprintf(buf_tmp, sizeof(buf_tmp),"%s #%u", val_shdr, i);
"%s #%u", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER), i);
if (menu_entries_append_enum(info->list, buf_tmp, if (menu_entries_append_enum(info->list, buf_tmp, shdr_pass,
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_PASS),
MENU_ENUM_LABEL_VIDEO_SHADER_PASS, MENU_ENUM_LABEL_VIDEO_SHADER_PASS,
MENU_SETTINGS_SHADER_PASS_0 + i, 0, 0)) MENU_SETTINGS_SHADER_PASS_0 + i, 0, 0))
count++; count++;
snprintf(buf, sizeof(buf), "%s %s", buf_tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_FILTER)); _len = strlcpy(buf, buf_tmp, sizeof(buf));
if (menu_entries_append_enum(info->list, buf, buf[_len ] = ' ';
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS), buf[_len+1] = '\0';
strlcat(buf, val_filter, sizeof(buf));
if (menu_entries_append_enum(info->list, buf, shdr_filter_pass,
MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS, MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS,
MENU_SETTINGS_SHADER_PASS_FILTER_0 + i, 0, 0)) MENU_SETTINGS_SHADER_PASS_FILTER_0 + i, 0, 0))
count++; count++;
snprintf(buf, sizeof(buf), "%s %s", buf_tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SCALE)); _len = strlcpy(buf, buf_tmp, sizeof(buf));
if (menu_entries_append_enum(info->list, buf, buf[_len ] = ' ';
msg_hash_to_str(MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS), buf[_len+1] = '\0';
strlcat(buf, val_scale, sizeof(buf));
if (menu_entries_append_enum(info->list, buf, shdr_scale_pass,
MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS, MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS,
MENU_SETTINGS_SHADER_PASS_SCALE_0 + i, 0, 0)) MENU_SETTINGS_SHADER_PASS_SCALE_0 + i, 0, 0))
count++; count++;