@@ -201,16 +201,18 @@ static void task_overlay_redefine_eightway_direction(
201201 char * str , input_bits_t * data )
202202{
203203 unsigned bit ;
204- char * tok , * save = NULL ;
205-
204+ char * cur = str ;
205+ char * next ;
206206 BIT256_CLEAR_ALL (* data );
207-
208- for (tok = strtok_r (str , "|" , & save ); tok ;
209- tok = strtok_r (NULL , "|" , & save ))
207+ while (cur && * cur )
210208 {
211- bit = input_config_translate_str_to_bind_id (tok );
209+ next = strchr (cur , '|' );
210+ if (next )
211+ * next ++ = '\0' ;
212+ bit = input_config_translate_str_to_bind_id (cur );
212213 if (bit < RARCH_CUSTOM_BIND_LIST_END )
213214 BIT256_SET (* data , bit );
215+ cur = next ;
214216 }
215217}
216218
@@ -330,7 +332,6 @@ static bool task_overlay_load_desc(
330332 char overlay [256 ];
331333 unsigned list_size = 0 ;
332334 char * elems [6 ] = {NULL , NULL , NULL , NULL , NULL , NULL };
333- char * tok , * save = NULL ;
334335 float tmp_float = 0.0f ;
335336 bool tmp_bool = false;
336337 bool by_pixel = false;
@@ -366,10 +367,23 @@ static bool task_overlay_load_desc(
366367
367368 /* Tokenize in-place — overlay[] is a local buffer,
368369 * no heap allocation needed */
369- for (tok = strtok_r (overlay , ", " , & save );
370- tok && list_size < 6 ;
371- tok = strtok_r (NULL , ", " , & save ))
372- elems [list_size ++ ] = tok ;
370+ {
371+ char * p = overlay ;
372+ while (* p && list_size < 6 )
373+ {
374+ /* skip delimiters */
375+ while (* p == ',' || * p == ' ' )
376+ p ++ ;
377+ if (!* p )
378+ break ;
379+ elems [list_size ++ ] = p ;
380+ /* advance to next delimiter or end */
381+ while (* p && * p != ',' && * p != ' ' )
382+ p ++ ;
383+ if (* p )
384+ * p ++ = '\0' ;
385+ }
386+ }
373387
374388 if (list_size < 6 )
375389 {
@@ -378,7 +392,7 @@ static bool task_overlay_load_desc(
378392 }
379393
380394 /* elems[0] (key) will be mutated by the button-parsing
381- * strtok_r below, so read x/y/box from their own pointers
395+ * below, so read x/y/box from their own pointers
382396 * before that happens. They are separate tokens in the
383397 * buffer and won't be touched. */
384398 box = elems [3 ];
@@ -402,13 +416,19 @@ static bool task_overlay_load_desc(
402416 }
403417 else
404418 {
405- char * save2 = NULL ;
406- const char * tmp = strtok_r ( elems [0 ], "|" , & save2 ) ;
419+ const char * tmp ;
420+ char * p = elems [0 ];
407421
408422 desc -> type = OVERLAY_TYPE_BUTTONS ;
409423
410- for (; tmp ; tmp = strtok_r ( NULL , "|" , & save2 ) )
424+ while ( p )
411425 {
426+ char * delim = strchr (p , '|' );
427+ if (delim )
428+ * delim = '\0' ;
429+ tmp = p ;
430+ p = delim ? delim + 1 : NULL ;
431+
412432 if (!string_is_equal (tmp , "nul" ))
413433 {
414434 unsigned bind_id = input_config_translate_str_to_bind_id (tmp );
0 commit comments