(ozone) ozone_draw_osk - use strtok_r instead of string_list

This commit is contained in:
libretroadmin 2024-06-16 16:38:42 +02:00
parent 5a863652b6
commit 36e9d4a79d

View File

@ -6675,19 +6675,20 @@ static void ozone_draw_osk(
unsigned video_height,
const char *label, const char *str)
{
unsigned i;
char message[2048];
gfx_display_t *p_disp = (gfx_display_t*)disp_userdata;
const char *text = str;
unsigned text_color = 0xffffffff;
gfx_display_t *p_disp = (gfx_display_t*)disp_userdata;
const char *text = str;
unsigned text_color = 0xffffffff;
static float ozone_osk_backdrop[16] = {
0.00, 0.00, 0.00, 0.15,
0.00, 0.00, 0.00, 0.15,
0.00, 0.00, 0.00, 0.15,
0.00, 0.00, 0.00, 0.15,
};
char *tok, *save;
unsigned i = 0;
static retro_time_t last_time = 0;
struct string_list list = {0};
unsigned list_size = 0;
float scale_factor = ozone->last_scale_factor;
unsigned margin = 75 * scale_factor;
unsigned padding = 10 * scale_factor;
@ -6797,12 +6798,12 @@ static void ozone_draw_osk(
ozone->fonts.entries_label.wideglyph_width,
0);
string_list_initialize(&list);
string_split_noalloc(&list, message, "\n");
tok = strtok_r(message, "\n", &save);
list_size = string_count_occurrences_single_character(message, '\n');
for (i = 0; i < list.size; i++)
while (tok)
{
const char *msg = list.elems[i].data;
const char *msg = tok;
gfx_display_draw_text(
ozone->fonts.entries_label.font,
@ -6819,7 +6820,7 @@ static void ozone_draw_osk(
false);
/* Cursor */
if (i == list.size - 1)
if (i == list_size - 1)
{
if (ozone->flags & OZONE_FLAG_OSK_CURSOR)
{
@ -6850,6 +6851,9 @@ static void ozone_draw_osk(
}
else
y_offset += 25 * scale_factor;
tok = strtok_r(NULL, "\n", &save);
i++;
}
/* Keyboard */
@ -6868,8 +6872,6 @@ static void ozone_draw_osk(
input_st->osk_ptr,
ozone->theme->text_rgba);
}
string_list_deinitialize(&list);
}
static void ozone_draw_messagebox(