mirror of
https://github.com/libretro/RetroArch
synced 2025-03-22 16:20:58 +00:00
input_keyboard_osk_event_append and others: don't call strlen
implicitly, always leave it up to caller font_driver_get_message_width - try to avoid scenario where 'len' is 0
This commit is contained in:
parent
f34f4d060c
commit
25b76fdb54
@ -274,7 +274,7 @@ void gfx_widgets_msg_queue_push(
|
||||
msg_widget->width = font_driver_get_message_width(
|
||||
p_dispwidget->gfx_widget_fonts.msg_queue.font,
|
||||
title,
|
||||
msg_widget->msg_len, 1) +
|
||||
msg_widget->msg_len, 1.0f) +
|
||||
p_dispwidget->simple_widget_padding / 2;
|
||||
|
||||
task->frontend_userdata = msg_widget;
|
||||
@ -296,7 +296,7 @@ void gfx_widgets_msg_queue_push(
|
||||
p_dispwidget->gfx_widget_fonts.msg_queue.font,
|
||||
title,
|
||||
title_length,
|
||||
1);
|
||||
1.0f);
|
||||
msg_widget->text_height = p_dispwidget->gfx_widget_fonts.msg_queue.line_height;
|
||||
/* 1 byte uses for inserting '\n' */
|
||||
msg_len = title_length + 1 + 1;
|
||||
@ -361,7 +361,7 @@ void gfx_widgets_msg_queue_push(
|
||||
p_dispwidget->gfx_widget_fonts.msg_queue.font,
|
||||
title,
|
||||
len,
|
||||
1);
|
||||
1.0f);
|
||||
|
||||
msg_widget->msg_len = len;
|
||||
msg_widget->msg_transition_animation = 0;
|
||||
@ -1107,9 +1107,11 @@ static int gfx_widgets_draw_indicator(
|
||||
unsigned height = p_dispwidget->simple_widget_height;
|
||||
const char *txt = msg_hash_to_str(msg);
|
||||
|
||||
width = font_driver_get_message_width(p_dispwidget->gfx_widget_fonts.regular.font,
|
||||
width = font_driver_get_message_width(
|
||||
p_dispwidget->gfx_widget_fonts.regular.font,
|
||||
txt,
|
||||
(unsigned)strlen(txt), 1) + p_dispwidget->simple_widget_padding * 2;
|
||||
(unsigned)strlen(txt), 1.0f)
|
||||
+ p_dispwidget->simple_widget_padding * 2;
|
||||
|
||||
gfx_display_draw_quad(
|
||||
p_disp,
|
||||
|
@ -385,15 +385,18 @@ static void gfx_widget_achievement_popup_start(
|
||||
gfx_animation_ctx_entry_t entry;
|
||||
const dispgfx_widget_t *p_dispwidget = (const dispgfx_widget_t*)
|
||||
state->dispwidget_ptr;
|
||||
|
||||
size_t title_len = strlen(state->queue[state->queue_read_index].title);
|
||||
size_t stitle_len = strlen(state->queue[state->queue_read_index].subtitle);
|
||||
state->height = p_dispwidget->gfx_widget_fonts.regular.line_height * 4;
|
||||
state->width = MAX(
|
||||
font_driver_get_message_width(
|
||||
p_dispwidget->gfx_widget_fonts.regular.font,
|
||||
state->queue[state->queue_read_index].title, 0, 1),
|
||||
state->queue[state->queue_read_index].title, title_len,
|
||||
1.0f),
|
||||
font_driver_get_message_width(
|
||||
p_dispwidget->gfx_widget_fonts.regular.font,
|
||||
state->queue[state->queue_read_index].subtitle, 0, 1)
|
||||
state->queue[state->queue_read_index].subtitle, stitle_len,
|
||||
1.0f)
|
||||
);
|
||||
state->width += p_dispwidget->simple_widget_padding * 2;
|
||||
state->y = (float)(-(int)state->height);
|
||||
|
@ -975,10 +975,9 @@ int16_t input_joypad_analog_axis(
|
||||
|
||||
void input_keyboard_line_append(
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
const char *word)
|
||||
const char *word, size_t len)
|
||||
{
|
||||
int i;
|
||||
size_t len = strlen(word);
|
||||
char *newbuf = (char*)realloc(
|
||||
keyboard_line->buffer,
|
||||
keyboard_line->size + len * 2);
|
||||
@ -2356,7 +2355,8 @@ void input_event_osk_append(
|
||||
unsigned *osk_last_codepoint_len,
|
||||
int ptr,
|
||||
bool show_symbol_pages,
|
||||
const char *word)
|
||||
const char *word,
|
||||
size_t word_len)
|
||||
{
|
||||
#ifdef HAVE_LANGEXTRA
|
||||
if (string_is_equal(word, "\xe2\x87\xa6")) /* backspace character */
|
||||
@ -2387,7 +2387,7 @@ void input_event_osk_append(
|
||||
*osk_idx = ((enum osk_type)(OSK_TYPE_UNKNOWN + 1));
|
||||
else
|
||||
{
|
||||
input_keyboard_line_append(keyboard_line, word);
|
||||
input_keyboard_line_append(keyboard_line, word, word_len);
|
||||
osk_update_last_codepoint(
|
||||
osk_last_codepoint,
|
||||
osk_last_codepoint_len,
|
||||
|
@ -909,7 +909,7 @@ int16_t input_joypad_analog_axis(
|
||||
|
||||
void input_keyboard_line_append(
|
||||
struct input_keyboard_line *keyboard_line,
|
||||
const char *word);
|
||||
const char *word, size_t len);
|
||||
|
||||
/**
|
||||
* input_keyboard_start_line:
|
||||
|
@ -54,7 +54,8 @@ void input_event_osk_append(
|
||||
unsigned *osk_last_codepoint_len,
|
||||
int ptr,
|
||||
bool show_symbol_pages,
|
||||
const char *word);
|
||||
const char *word,
|
||||
size_t word_len);
|
||||
|
||||
void osk_update_last_codepoint(
|
||||
unsigned *last_codepoint,
|
||||
|
@ -2665,7 +2665,7 @@ static void materialui_render_messagebox(
|
||||
if (!string_is_empty(line))
|
||||
{
|
||||
int width = font_driver_get_message_width(
|
||||
mui->font_data.list.font, line, (unsigned)strlen(line), 1);
|
||||
mui->font_data.list.font, line, (unsigned)strlen(line), 1.0f);
|
||||
longest_width = (width > longest_width) ?
|
||||
width : longest_width;
|
||||
}
|
||||
@ -7789,7 +7789,7 @@ static void materialui_init_font(
|
||||
{
|
||||
/* Calculate a more realistic ticker_limit */
|
||||
int char_width =
|
||||
font_driver_get_message_width(font_data->font, str_latin, 1, 1);
|
||||
font_driver_get_message_width(font_data->font, str_latin, 1, 1.0f);
|
||||
|
||||
if (char_width > 0)
|
||||
font_data->glyph_width = (unsigned)char_width;
|
||||
@ -7799,7 +7799,7 @@ static void materialui_init_font(
|
||||
if (wideglyph_str)
|
||||
{
|
||||
int wideglyph_width =
|
||||
font_driver_get_message_width(font_data->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1);
|
||||
font_driver_get_message_width(font_data->font, wideglyph_str, (unsigned)strlen(wideglyph_str), 1.0f);
|
||||
|
||||
if (wideglyph_width > 0 && char_width > 0)
|
||||
font_data->wideglyph_width = wideglyph_width * 100 / char_width;
|
||||
|
@ -5351,7 +5351,7 @@ border_iterate:
|
||||
{
|
||||
/* Note: This entry can never be selected, so ticker_x_offset
|
||||
* is irrelevant here (i.e. this text will never scroll) */
|
||||
unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, (unsigned)strlen(rich_label), 1);
|
||||
unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, (unsigned)strlen(rich_label), 1.0f);
|
||||
x_offset = (video_info_width - (unsigned)
|
||||
ozone->dimensions_sidebar_width - entry_padding * 2)
|
||||
/ 2 - text_width / 2 - 60 * scale_factor;
|
||||
@ -6342,7 +6342,7 @@ static void ozone_draw_osk(ozone_handle_t *ozone,
|
||||
? 0
|
||||
: font_driver_get_message_width(
|
||||
ozone->fonts.entries_label.font, msg,
|
||||
(unsigned)strlen(msg), 1);
|
||||
(unsigned)strlen(msg), 1.0f);
|
||||
gfx_display_draw_quad(
|
||||
p_disp,
|
||||
userdata,
|
||||
@ -6454,7 +6454,7 @@ static void ozone_draw_messagebox(
|
||||
if (!string_is_empty(msg))
|
||||
{
|
||||
int width = font_driver_get_message_width(
|
||||
ozone->fonts.footer.font, msg, (unsigned)strlen(msg), 1);
|
||||
ozone->fonts.footer.font, msg, (unsigned)strlen(msg), 1.0f);
|
||||
|
||||
if (width > longest_width)
|
||||
longest_width = width;
|
||||
|
@ -5640,7 +5640,7 @@ bool menu_input_dialog_get_display_kb(void)
|
||||
char oldchar = buf[i+1];
|
||||
buf[i+1] = '\0';
|
||||
|
||||
input_keyboard_line_append(&input_st->keyboard_line, word);
|
||||
input_keyboard_line_append(&input_st->keyboard_line, word, strlen(word));
|
||||
|
||||
osk_update_last_codepoint(
|
||||
&input_st->osk_last_codepoint,
|
||||
@ -5978,7 +5978,8 @@ unsigned menu_event(
|
||||
&input_st->osk_last_codepoint_len,
|
||||
input_st->osk_ptr,
|
||||
show_osk_symbols,
|
||||
input_st->osk_grid[input_st->osk_ptr]);
|
||||
input_st->osk_grid[input_st->osk_ptr],
|
||||
strlen(input_st->osk_grid[input_st->osk_ptr]));
|
||||
}
|
||||
|
||||
if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn))
|
||||
@ -6400,7 +6401,6 @@ static int menu_input_pointer_post_iterate(
|
||||
if (point.retcode > -1)
|
||||
{
|
||||
bool show_osk_symbols = input_event_osk_show_symbol_pages(menu_st->driver_data);
|
||||
|
||||
input_st->osk_ptr = point.retcode;
|
||||
input_event_osk_append(
|
||||
&input_st->keyboard_line,
|
||||
@ -6409,7 +6409,8 @@ static int menu_input_pointer_post_iterate(
|
||||
&input_st->osk_last_codepoint_len,
|
||||
point.retcode,
|
||||
show_osk_symbols,
|
||||
input_st->osk_grid[input_st->osk_ptr]);
|
||||
input_st->osk_grid[input_st->osk_ptr],
|
||||
strlen(input_st->osk_grid[input_st->osk_ptr]));
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_MIST
|
||||
|
Loading…
x
Reference in New Issue
Block a user