mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
(libretro-common) Some functions now return len
This commit is contained in:
parent
9e71a566cc
commit
827e631903
@ -71,27 +71,27 @@
|
|||||||
|
|
||||||
/* Time format strings with AM-PM designation require special
|
/* Time format strings with AM-PM designation require special
|
||||||
* handling due to platform dependence */
|
* handling due to platform dependence */
|
||||||
void strftime_am_pm(char *s, size_t len, const char* format,
|
size_t strftime_am_pm(char *s, size_t len, const char* format,
|
||||||
const void *ptr)
|
const void *ptr)
|
||||||
{
|
{
|
||||||
char *local = NULL;
|
size_t _len = 0;
|
||||||
|
char *local = NULL;
|
||||||
const struct tm *timeptr = (const struct tm*)ptr;
|
const struct tm *timeptr = (const struct tm*)ptr;
|
||||||
|
|
||||||
/* Ensure correct locale is set
|
/* Ensure correct locale is set
|
||||||
* > Required for localised AM/PM strings */
|
* > Required for localised AM/PM strings */
|
||||||
setlocale(LC_TIME, "");
|
setlocale(LC_TIME, "");
|
||||||
|
_len = strftime(s, len, format, timeptr);
|
||||||
strftime(s, len, format, timeptr);
|
|
||||||
#if !(defined(__linux__) && !defined(ANDROID))
|
#if !(defined(__linux__) && !defined(ANDROID))
|
||||||
if ((local = local_to_utf8_string_alloc(s)))
|
if ((local = local_to_utf8_string_alloc(s)))
|
||||||
{
|
{
|
||||||
if (!string_is_empty(local))
|
if (!string_is_empty(local))
|
||||||
strlcpy(s, local, len);
|
_len = strlcpy(s, local, len);
|
||||||
|
|
||||||
free(local);
|
free(local);
|
||||||
local = NULL;
|
local = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return _len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1422,7 +1422,7 @@ void fill_pathname_application_dir(char *s, size_t len)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_pathname_home_dir(char *s, size_t len)
|
size_t fill_pathname_home_dir(char *s, size_t len)
|
||||||
{
|
{
|
||||||
#ifdef __WINRT__
|
#ifdef __WINRT__
|
||||||
const char *home = uwp_dir_data;
|
const char *home = uwp_dir_data;
|
||||||
@ -1430,9 +1430,9 @@ void fill_pathname_home_dir(char *s, size_t len)
|
|||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
#endif
|
#endif
|
||||||
if (home)
|
if (home)
|
||||||
strlcpy(s, home, len);
|
return strlcpy(s, home, len);
|
||||||
else
|
*s = 0;
|
||||||
*s = 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ size_t fill_pathname_slash(char *path, size_t size);
|
|||||||
#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL)
|
#if !defined(RARCH_CONSOLE) && defined(RARCH_INTERNAL)
|
||||||
void fill_pathname_application_path(char *buf, size_t size);
|
void fill_pathname_application_path(char *buf, size_t size);
|
||||||
void fill_pathname_application_dir(char *buf, size_t size);
|
void fill_pathname_application_dir(char *buf, size_t size);
|
||||||
void fill_pathname_home_dir(char *buf, size_t size);
|
size_t fill_pathname_home_dir(char *buf, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -663,8 +663,10 @@ bool path_mkdir(const char *dir);
|
|||||||
bool path_is_directory(const char *path);
|
bool path_is_directory(const char *path);
|
||||||
|
|
||||||
/* Time format strings with AM-PM designation require special
|
/* Time format strings with AM-PM designation require special
|
||||||
* handling due to platform dependence */
|
* handling due to platform dependence
|
||||||
void strftime_am_pm(char *s, size_t len, const char* format,
|
* @return Length of the string written to @s
|
||||||
|
*/
|
||||||
|
size_t strftime_am_pm(char *s, size_t len, const char* format,
|
||||||
const void* timeptr);
|
const void* timeptr);
|
||||||
|
|
||||||
bool path_is_character_special(const char *path);
|
bool path_is_character_special(const char *path);
|
||||||
|
@ -5859,7 +5859,7 @@ static void materialui_render_header(
|
|||||||
gfx_display_ctx_datetime_t datetime;
|
gfx_display_ctx_datetime_t datetime;
|
||||||
char timedate_str[MUI_TIMEDATE_MAX_LENGTH];
|
char timedate_str[MUI_TIMEDATE_MAX_LENGTH];
|
||||||
|
|
||||||
timedate_str[0] = '\0';
|
timedate_str[0] = '\0';
|
||||||
|
|
||||||
datetime.s = timedate_str;
|
datetime.s = timedate_str;
|
||||||
datetime.len = sizeof(timedate_str);
|
datetime.len = sizeof(timedate_str);
|
||||||
@ -5874,7 +5874,7 @@ static void materialui_render_header(
|
|||||||
if (!string_is_equal(timedate_str, mui->sys_bar_cache.timedate_str))
|
if (!string_is_equal(timedate_str, mui->sys_bar_cache.timedate_str))
|
||||||
{
|
{
|
||||||
/* Cache new string */
|
/* Cache new string */
|
||||||
strlcpy(mui->sys_bar_cache.timedate_str, timedate_str,
|
size_t _len = strlcpy(mui->sys_bar_cache.timedate_str, timedate_str,
|
||||||
MUI_TIMEDATE_MAX_LENGTH * sizeof(char));
|
MUI_TIMEDATE_MAX_LENGTH * sizeof(char));
|
||||||
|
|
||||||
/* Cache width */
|
/* Cache width */
|
||||||
@ -5882,7 +5882,7 @@ static void materialui_render_header(
|
|||||||
= font_driver_get_message_width(
|
= font_driver_get_message_width(
|
||||||
mui->font_data.hint.font,
|
mui->font_data.hint.font,
|
||||||
mui->sys_bar_cache.timedate_str,
|
mui->sys_bar_cache.timedate_str,
|
||||||
strlen(mui->sys_bar_cache.timedate_str),
|
_len,
|
||||||
1.0f);
|
1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10488,9 +10488,7 @@ static void ozone_draw_header(
|
|||||||
if (timedate_enable)
|
if (timedate_enable)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_datetime_t datetime;
|
gfx_display_ctx_datetime_t datetime;
|
||||||
char timedate[255];
|
char timedate[256];
|
||||||
|
|
||||||
timedate[0] = '\0';
|
|
||||||
|
|
||||||
datetime.s = timedate;
|
datetime.s = timedate;
|
||||||
datetime.time_mode = settings->uints.menu_timedate_style;
|
datetime.time_mode = settings->uints.menu_timedate_style;
|
||||||
|
@ -6127,7 +6127,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
|||||||
if (timedate_enable)
|
if (timedate_enable)
|
||||||
{
|
{
|
||||||
gfx_display_ctx_datetime_t datetime;
|
gfx_display_ctx_datetime_t datetime;
|
||||||
char timedate[255];
|
char timedate[256];
|
||||||
|
size_t _len = 0;
|
||||||
size_t x_pos = 0;
|
size_t x_pos = 0;
|
||||||
|
|
||||||
if (percent_width)
|
if (percent_width)
|
||||||
@ -6169,10 +6170,10 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
|
|||||||
datetime.time_mode = settings->uints.menu_timedate_style;
|
datetime.time_mode = settings->uints.menu_timedate_style;
|
||||||
datetime.date_separator = settings->uints.menu_timedate_date_separator;
|
datetime.date_separator = settings->uints.menu_timedate_date_separator;
|
||||||
|
|
||||||
menu_display_timedate(&datetime);
|
_len = menu_display_timedate(&datetime);
|
||||||
|
|
||||||
title_header_max_width = x_pos + font_driver_get_message_width(
|
title_header_max_width = x_pos + font_driver_get_message_width(
|
||||||
xmb->font, timedate, strlen(timedate), 1.0f);
|
xmb->font, timedate, _len, 1.0f);
|
||||||
|
|
||||||
xmb_draw_text(shadows_enable, xmb, settings, timedate,
|
xmb_draw_text(shadows_enable, xmb, settings, timedate,
|
||||||
video_width - xmb->margins_title_left - xmb->icon_size / 4 - x_pos,
|
video_width - xmb->margins_title_left - xmb->icon_size / 4 - x_pos,
|
||||||
|
@ -640,7 +640,7 @@ bool menu_entries_list_search(const char *needle, size_t *idx)
|
|||||||
/* Display the date and time - time_mode will influence how
|
/* Display the date and time - time_mode will influence how
|
||||||
* the time representation will look like.
|
* the time representation will look like.
|
||||||
* */
|
* */
|
||||||
void menu_display_timedate(gfx_display_ctx_datetime_t *datetime)
|
size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime)
|
||||||
{
|
{
|
||||||
struct menu_state *menu_st = &menu_driver_state;
|
struct menu_state *menu_st = &menu_driver_state;
|
||||||
|
|
||||||
@ -1008,7 +1008,7 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime)
|
|||||||
|
|
||||||
/* Copy cached datetime string to input
|
/* Copy cached datetime string to input
|
||||||
* menu_display_ctx_datetime_t struct */
|
* menu_display_ctx_datetime_t struct */
|
||||||
strlcpy(datetime->s, menu_st->datetime_cache, datetime->len);
|
return strlcpy(datetime->s, menu_st->datetime_cache, datetime->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display current (battery) power state */
|
/* Display current (battery) power state */
|
||||||
|
@ -627,7 +627,7 @@ bool menu_driver_init(bool video_is_threaded);
|
|||||||
|
|
||||||
retro_time_t menu_driver_get_current_time(void);
|
retro_time_t menu_driver_get_current_time(void);
|
||||||
|
|
||||||
void menu_display_timedate(gfx_display_ctx_datetime_t *datetime);
|
size_t menu_display_timedate(gfx_display_ctx_datetime_t *datetime);
|
||||||
|
|
||||||
void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate);
|
void menu_display_powerstate(gfx_display_ctx_powerstate_t *powerstate);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user