Implement changes for Android, Xcode, C89 & CXX.

Fix bad match in removal of parens and brackets.
Use libretro string comparison features instead of a long char-wise
comparison.
This commit is contained in:
Tim Van den Langenbergh 2019-07-28 11:55:46 +02:00
parent 55f4c04ff2
commit 8bbfd52a5e
8 changed files with 34 additions and 64 deletions

View File

@ -1618,3 +1618,8 @@ SSL
#ifdef HAVE_EASTEREGG
#include "../cores/libretro-gong/gong.c"
#endif
/*============================================================
PLAYLIST NAME SANITIZATION
============================================================ */
#include "../libretro-common/playlists/label-sanitization.c"

View File

@ -21,6 +21,7 @@
*/
#include <playlists/label_sanitization.h>
#include <string/stdstring.h>
#include <string.h>
/*
@ -37,7 +38,7 @@ void label_sanitize(char *label, size_t size, bool (*left)(char*), bool (*right)
{
if (copy)
{
// check for the start of the range
/* check for the start of the range */
if ((*left)(&label[lindex]))
copy = false;
@ -80,35 +81,17 @@ bool left_parens_or_brackets(char *left)
bool right_parens_or_brackets(char *right)
{
return right[0] == ']' || right[0] == ']';
return right[0] == ')' || right[0] == ']';
}
bool left_parens_or_brackets_excluding_region(char *left)
{
if (left_parens_or_brackets(left))
{
if ((left[1] == 'A'
&& left[2] == 'u'
&& left[3] == 's'
&& left[4] == 'r'
&& left[5] == 'a'
&& left[6] == 'l'
&& left[7] == 'i'
&& left[8] == 'a')
|| (left[1] == 'E'
&& left[2] == 'u'
&& left[3] == 'r'
&& left[4] == 'o'
&& left[5] == 'p'
&& left[6] == 'e')
|| (left[1] == 'J'
&& left[2] == 'a'
&& left[3] == 'p'
&& left[4] == 'a'
&& left[5] == 'n')
|| (left[1] == 'U'
&& left[2] == 'S'
&& left[3] == 'A'))
if (string_is_equal_fast(&left[1], "Australia", 9)
|| string_is_equal_fast(&left[1], "Europe", 6)
|| string_is_equal_fast(&left[1], "Japan", 5)
|| string_is_equal_fast(&left[1], "USA", 3))
return false;
else
return true;
@ -121,10 +104,7 @@ bool left_parens_or_brackets_excluding_disc(char *left)
{
if (left_parens_or_brackets(left))
{
if (left[1] == 'D'
&& left[2] == 'i'
&& left[3] == 's'
&& left[4] == 'c')
if (string_is_equal_fast(&left[1], "Disc", 4))
return false;
else
return true;
@ -137,32 +117,11 @@ bool left_parens_or_brackets_excluding_region_or_disc(char *left)
{
if (left_parens_or_brackets(left))
{
if ((left[1] == 'A'
&& left[2] == 'u'
&& left[3] == 's'
&& left[4] == 'r'
&& left[5] == 'a'
&& left[6] == 'l'
&& left[7] == 'i'
&& left[8] == 'a')
|| (left[1] == 'E'
&& left[2] == 'u'
&& left[3] == 'r'
&& left[4] == 'o'
&& left[5] == 'p'
&& left[6] == 'e')
|| (left[1] == 'J'
&& left[2] == 'a'
&& left[3] == 'p'
&& left[4] == 'a'
&& left[5] == 'n')
|| (left[1] == 'U'
&& left[2] == 'S'
&& left[3] == 'A')
|| (left[1] == 'D'
&& left[2] == 'i'
&& left[3] == 's'
&& left[4] == 'c'))
if (string_is_equal_fast(&left[1], "Australia", 9)
|| string_is_equal_fast(&left[1], "Disc", 4)
|| string_is_equal_fast(&left[1], "Europe", 6)
|| string_is_equal_fast(&left[1], "Japan", 5)
|| string_is_equal_fast(&left[1], "USA", 3))
return false;
else
return true;
@ -174,6 +133,7 @@ bool left_parens_or_brackets_excluding_region_or_disc(char *left)
void label_default_display(char *label, size_t size)
{
return;
/* The default display will keep the label the same. */
}
void label_remove_parens(char *label, size_t size)

View File

@ -1113,7 +1113,11 @@ static void menu_action_setting_disp_set_label_playlist_label_display_mode(
strlcpy(s2, path, len2);
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + label_display_mode * 3), len);
int msg_index = (int)label_display_mode;
msg_index = msg_index * 3;
msg_index = msg_index + (int)MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT;
strlcpy(s, msg_hash_to_str((enum msg_hash_enums)msg_index), len);
}
static void menu_action_setting_disp_set_label_core_options(file_list_t* list,

View File

@ -445,7 +445,7 @@ static int playlist_label_display_mode_left(unsigned type, const char *label,
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
if (label_display_mode != LABEL_DISPLAY_MODE_DEFAULT)
label_display_mode--;
label_display_mode = (enum playlist_label_display_mode)((int)label_display_mode - 1);
else if (wraparound)
label_display_mode = LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX;

View File

@ -2919,7 +2919,7 @@ static int action_ok_core_deferred_set(const char *new_core_path,
strlcpy(resolved_core_path, new_core_path, sizeof(resolved_core_path));
playlist_resolve_path(PLAYLIST_SAVE, resolved_core_path, sizeof(resolved_core_path));
/* the update function reads our entry
/* the update function reads our entry
* as const, so these casts are safe */
entry.core_path = (char*)resolved_core_path;
entry.core_name = core_display_name;
@ -5375,7 +5375,7 @@ static int action_ok_push_dropdown_item_playlist_label_display_mode(const char *
{
playlist_t *playlist = playlist_get_cached();
playlist_set_label_display_mode(playlist, idx);
playlist_set_label_display_mode(playlist, (enum playlist_label_display_mode)idx);
/* In all cases, update file on disk */
playlist_write_file(playlist);

View File

@ -558,7 +558,7 @@ static int playlist_label_display_mode_right(unsigned type, const char *label,
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
if (label_display_mode != LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX)
label_display_mode++;
label_display_mode = (enum playlist_label_display_mode)((int)label_display_mode + 1);
else if (wraparound)
label_display_mode = LABEL_DISPLAY_MODE_DEFAULT;

View File

@ -3521,7 +3521,7 @@ typedef struct menu_displaylist_build_info_selective {
enum msg_hash_enums enum_idx;
enum menu_displaylist_parse_type parse_type;
bool checked;
} menu_displaylist_build_info_selective_t;
} menu_displaylist_build_info_selective_t;
unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ctl_state type)
{
@ -3752,11 +3752,12 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
if (playlist)
{
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
int i;
for (int i = 0; MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + i != MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX; i += 3)
for (i = 0; MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + i != MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX; i += 3)
{
if (menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + i),
msg_hash_to_str((enum msg_hash_enums)((int)MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + i)),
"",
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_LABEL_DISPLAY_MODE,
@ -4205,7 +4206,7 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
for (i = 0; i < ARRAY_SIZE(build_list); i++)
{
bool parse_setting = true;
if (build_list[i].checked &&
if (build_list[i].checked &&
string_is_equal(ui_companion_driver_get_ident(), "null"))
parse_setting = false;
if (parse_setting &&

View File

@ -2084,7 +2084,7 @@ json_cleanup:
start++;
if (*start >= '0' && *start <= '9')
playlist->label_display_mode = *start - '0';
playlist->label_display_mode = (enum playlist_label_display_mode)(*start - '0');
}
}