(menu_cbs_deferred_push) Get rid of string_list usage
This commit is contained in:
parent
e2b0d70ec0
commit
6ac25079bf
|
@ -16,7 +16,6 @@
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <lists/string_list.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "../../config.h"
|
#include "../../config.h"
|
||||||
|
@ -513,19 +512,16 @@ static int general_push(menu_displaylist_info_t *info,
|
||||||
case PUSH_ARCHIVE_OPEN_DETECT_CORE:
|
case PUSH_ARCHIVE_OPEN_DETECT_CORE:
|
||||||
case PUSH_DETECT_CORE_LIST:
|
case PUSH_DETECT_CORE_LIST:
|
||||||
{
|
{
|
||||||
char newstr1[PATH_MAX_LENGTH];
|
|
||||||
struct string_list str_list2 = {0};
|
|
||||||
struct retro_system_info *sysinfo =
|
struct retro_system_info *sysinfo =
|
||||||
&runloop_state_get_ptr()->system.info;
|
&runloop_state_get_ptr()->system.info;
|
||||||
bool filter_by_current_core = settings->bools.filter_by_current_core;
|
bool filter_by_current_core = settings->bools.filter_by_current_core;
|
||||||
|
|
||||||
newstr1[0] = '\0';
|
|
||||||
|
|
||||||
string_list_initialize(&str_list2);
|
|
||||||
|
|
||||||
if (sysinfo && !string_is_empty(sysinfo->valid_extensions))
|
if (sysinfo && !string_is_empty(sysinfo->valid_extensions))
|
||||||
string_split_noalloc(&str_list2,
|
{
|
||||||
sysinfo->valid_extensions, "|");
|
_len += strlcpy(newstr2 + _len,
|
||||||
|
sysinfo->valid_extensions,
|
||||||
|
sizeof(newstr2) - _len);
|
||||||
|
}
|
||||||
|
|
||||||
if (!filter_by_current_core)
|
if (!filter_by_current_core)
|
||||||
{
|
{
|
||||||
|
@ -533,64 +529,74 @@ static int general_push(menu_displaylist_info_t *info,
|
||||||
core_info_get_list(&list);
|
core_info_get_list(&list);
|
||||||
if (list && !string_is_empty(list->all_ext))
|
if (list && !string_is_empty(list->all_ext))
|
||||||
{
|
{
|
||||||
unsigned x;
|
char *tok, *save;
|
||||||
union string_list_elem_attr attr;
|
char *all_ext_cpy = strdup(list->all_ext);
|
||||||
struct string_list str_list = {0};
|
|
||||||
string_list_initialize(&str_list);
|
|
||||||
attr.i = 0;
|
|
||||||
|
|
||||||
string_split_noalloc(&str_list,
|
/* If the current core already supports
|
||||||
list->all_ext, "|");
|
* this extension, skip adding it */
|
||||||
|
for ( tok = strtok_r(all_ext_cpy, "|", &save); tok;
|
||||||
for (x = 0; x < str_list.size; x++)
|
tok = strtok_r(NULL, "|", &save))
|
||||||
{
|
{
|
||||||
/* Is extension not already added to
|
bool exists = false;
|
||||||
* str_list2? This is the case if
|
|
||||||
* the current core already supports
|
if (!string_is_empty(newstr2))
|
||||||
* this extension. If so, it was added
|
|
||||||
* in the loop above this one */
|
|
||||||
if (!string_list_find_elem(&str_list2,
|
|
||||||
str_list.elems[x].data))
|
|
||||||
{
|
{
|
||||||
const char *elem = str_list.elems[x].data;
|
char *tok2, *save2;
|
||||||
string_list_append(&str_list2, elem, attr);
|
char *newstr2_cpy = strdup(newstr2);
|
||||||
|
for ( tok2 = strtok_r(newstr2_cpy, "|", &save2); tok2;
|
||||||
|
tok2 = strtok_r(NULL, "|", &save2))
|
||||||
|
{
|
||||||
|
if (string_is_equal(tok, tok2))
|
||||||
|
{
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(newstr2_cpy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If extension wasn't found in string,
|
||||||
|
* add it */
|
||||||
|
if (!exists)
|
||||||
|
{
|
||||||
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
|
_len += strlcpy(newstr2 + _len, "|",
|
||||||
|
sizeof(newstr2) - _len);
|
||||||
|
_len += strlcpy(newstr2 + _len, tok,
|
||||||
|
sizeof(newstr2) - _len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_deinitialize(&str_list);
|
free(all_ext_cpy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string_list_join_concat(newstr1, sizeof(newstr1),
|
|
||||||
&str_list2, "|");
|
|
||||||
string_list_deinitialize(&str_list2);
|
|
||||||
|
|
||||||
_len += strlcpy(newstr2 + _len, newstr1, sizeof(newstr2) - _len);
|
|
||||||
#if defined(HAVE_AUDIOMIXER)
|
#if defined(HAVE_AUDIOMIXER)
|
||||||
if (multimedia_builtin_mediaplayer_enable)
|
if (multimedia_builtin_mediaplayer_enable)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_DR_MP3)
|
#if defined(HAVE_DR_MP3)
|
||||||
if (newstr2[_len-1] != '\0')
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
||||||
_len += strlcpy(newstr2 + _len, "mp3", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "mp3", sizeof(newstr2) - _len);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_STB_VORBIS)
|
#if defined(HAVE_STB_VORBIS)
|
||||||
if (newstr2[_len-1] != '\0')
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
||||||
_len += strlcpy(newstr2 + _len, "ogg", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "ogg", sizeof(newstr2) - _len);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_DR_FLAC)
|
#if defined(HAVE_DR_FLAC)
|
||||||
if (newstr2[_len-1] != '\0')
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
||||||
_len += strlcpy(newstr2 + _len, "flac", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "flac", sizeof(newstr2) - _len);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_RWAV)
|
#if defined(HAVE_RWAV)
|
||||||
if (newstr2[_len-1] != '\0')
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
||||||
_len += strlcpy(newstr2 + _len, "wav", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "wav", sizeof(newstr2) - _len);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_IBXM
|
#ifdef HAVE_IBXM
|
||||||
if (newstr2[_len-1] != '\0')
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
||||||
_len += strlcpy(newstr2 + _len, "s3m", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "s3m", sizeof(newstr2) - _len);
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
||||||
|
@ -613,8 +619,11 @@ static int general_push(menu_displaylist_info_t *info,
|
||||||
#elif defined(HAVE_MPV)
|
#elif defined(HAVE_MPV)
|
||||||
libretro_mpv_retro_get_system_info(&sysinfo);
|
libretro_mpv_retro_get_system_info(&sysinfo);
|
||||||
#endif
|
#endif
|
||||||
_len += strlcpy(newstr2 + _len, "|", sizeof(newstr2) - _len);
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
_len += strlcpy(newstr2 + _len, sysinfo.valid_extensions, sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|",
|
||||||
|
sizeof(newstr2) - _len);
|
||||||
|
_len += strlcpy(newstr2 + _len, sysinfo.valid_extensions,
|
||||||
|
sizeof(newstr2) - _len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -623,10 +632,11 @@ static int general_push(menu_displaylist_info_t *info,
|
||||||
{
|
{
|
||||||
struct retro_system_info sysinfo = {0};
|
struct retro_system_info sysinfo = {0};
|
||||||
libretro_imageviewer_retro_get_system_info(&sysinfo);
|
libretro_imageviewer_retro_get_system_info(&sysinfo);
|
||||||
_len += strlcpy(newstr2 + _len, "|",
|
if (_len > 0 && newstr2[_len-1] != '\0')
|
||||||
sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, "|",
|
||||||
_len += strlcpy(newstr2 + _len, sysinfo.valid_extensions,
|
sizeof(newstr2) - _len);
|
||||||
sizeof(newstr2) - _len);
|
_len += strlcpy(newstr2 + _len, sysinfo.valid_extensions,
|
||||||
|
sizeof(newstr2) - _len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue