* Add TODO/FIXME localize notes

* More snprintf optimizations
This commit is contained in:
libretroadmin 2023-04-30 19:30:07 +02:00
parent 907efccb05
commit c087b044c2
6 changed files with 122 additions and 165 deletions

View file

@ -674,6 +674,7 @@ void runloop_runtime_log_deinit(
runloop_st->core_runtime_usec,
&hours, &minutes, &seconds);
/* TODO/FIXME - localize */
snprintf(log, sizeof(log),
"[Core]: Content ran for a total of:"
" %02u hours, %02u minutes, %02u seconds.",
@ -4976,6 +4977,7 @@ void core_options_reset(void)
void core_options_flush(void)
{
size_t _len;
runloop_state_t *runloop_st = &runloop_state;
core_option_manager_t *coreopts = runloop_st->core_options;
const char *path_core_options = path_get(RARCH_PATH_CORE_OPTIONS);
@ -5048,26 +5050,25 @@ void core_options_flush(void)
if (success)
{
/* Log result */
_len = strlcpy(msg, msg_hash_to_str(MSG_CORE_OPTIONS_FLUSHED),
sizeof(msg));
RARCH_LOG(
"[Core]: Saved core options to \"%s\".\n",
path_core_options ? path_core_options : "UNKNOWN");
snprintf(msg, sizeof(msg), "%s \"%s\"",
msg_hash_to_str(MSG_CORE_OPTIONS_FLUSHED),
core_options_file);
}
else
{
/* Log result */
_len = strlcpy(msg, msg_hash_to_str(MSG_CORE_OPTIONS_FLUSH_FAILED),
sizeof(msg));
RARCH_LOG(
"[Core]: Failed to save core options to \"%s\".\n",
path_core_options ? path_core_options : "UNKNOWN");
snprintf(msg, sizeof(msg), "%s \"%s\"",
msg_hash_to_str(MSG_CORE_OPTIONS_FLUSH_FAILED),
core_options_file);
}
snprintf(msg + _len, sizeof(msg) - _len, " \"%s\"",
core_options_file);
runloop_msg_queue_push(
msg, 1, 100, true,
NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
@ -6403,11 +6404,8 @@ static enum runloop_state_enum runloop_check_state(
cur_state_slot);
_len = strlcpy(msg, msg_hash_to_str(MSG_STATE_SLOT), sizeof(msg));
snprintf(msg + _len,
sizeof(msg) - _len,
": %d",
settings->ints.state_slot);
snprintf(msg + _len, sizeof(msg) - _len,
": %d", settings->ints.state_slot);
if (cur_state_slot < 0)
strlcat(msg, " (Auto)", sizeof(msg));
@ -6466,11 +6464,8 @@ static enum runloop_state_enum runloop_check_state(
cur_replay_slot);
_len = strlcpy(msg, msg_hash_to_str(MSG_REPLAY_SLOT), sizeof(msg));
snprintf(msg + _len,
sizeof(msg) - _len,
": %d",
settings->ints.replay_slot);
snprintf(msg + _len, sizeof(msg) - _len,
": %d", settings->ints.replay_slot);
if (cur_replay_slot < 0)
strlcat(msg, " (Auto)", sizeof(msg));
@ -7228,12 +7223,14 @@ bool runloop_get_savestate_path(char *path, size_t len, int state_slot)
if (string_is_empty(name_savestate))
return false;
if (state_slot > 0)
snprintf(path, len, "%s%d", name_savestate, state_slot);
else if (state_slot < 0)
if (state_slot < 0)
fill_pathname_join_delim(path, name_savestate, "auto", '.', len);
else
strlcpy(path, name_savestate, len);
{
size_t _len = strlcpy(path, name_savestate, len);
if (state_slot > 0)
snprintf(path + _len, len - _len, "%d", state_slot);
}
return true;
}
@ -7248,6 +7245,7 @@ bool runloop_get_current_replay_path(char *path, size_t len)
bool runloop_get_replay_path(char *path, size_t len, unsigned slot)
{
size_t _len;
runloop_state_t *runloop_st = &runloop_state;
const char *name_replay = NULL;
@ -7258,10 +7256,9 @@ bool runloop_get_replay_path(char *path, size_t len, unsigned slot)
if (string_is_empty(name_replay))
return false;
_len = strlcpy(path, name_replay, len);
if (slot >= 0)
snprintf(path, len, "%s%d", name_replay, slot);
else
strlcpy(path, name_replay, len);
snprintf(path + _len, len - _len, "%d", slot);
return true;
}