From 36e9d4a79d04463dbfa2e895eac721469749b84d Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 16 Jun 2024 16:38:42 +0200 Subject: [PATCH] (ozone) ozone_draw_osk - use strtok_r instead of string_list --- menu/drivers/ozone.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index dea1efd67e..30320973fd 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -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(