mirror of
https://github.com/libretro/RetroArch
synced 2025-03-21 04:21:13 +00:00
(libretro-common) Cleanups
This commit is contained in:
parent
74fc0ba494
commit
e2c277d2ea
@ -26,20 +26,19 @@
|
|||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
const size_t disc_strings_length = 3;
|
#define DISC_STRINGS_LENGTH 3
|
||||||
|
#define REGION_STRINGS_LENGTH 20
|
||||||
|
|
||||||
const char *disc_strings[3] = {
|
const char *disc_strings[DISC_STRINGS_LENGTH] = {
|
||||||
"(CD",
|
"(CD",
|
||||||
"(Disc",
|
"(Disc",
|
||||||
"(Disk"
|
"(Disk"
|
||||||
};
|
};
|
||||||
|
|
||||||
const size_t region_strings_length = 20;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We'll use the standard No-Intro regions for now.
|
* We'll use the standard No-Intro regions for now.
|
||||||
*/
|
*/
|
||||||
const char *region_strings[20] = {
|
const char *region_strings[REGION_STRINGS_LENGTH] = {
|
||||||
"(Australia)", /* Don’t use with Europe */
|
"(Australia)", /* Don’t use with Europe */
|
||||||
"(Brazil)",
|
"(Brazil)",
|
||||||
"(Canada)", /* Don’t use with USA */
|
"(Canada)", /* Don’t use with USA */
|
||||||
@ -129,16 +128,16 @@ static bool left_exclusion(char *left,
|
|||||||
char exclusion_string[32];
|
char exclusion_string[32];
|
||||||
char comparison_string[32];
|
char comparison_string[32];
|
||||||
|
|
||||||
strlcpy(exclusion_string, left, 32);
|
strlcpy(exclusion_string, left, sizeof(exclusion_string));
|
||||||
string_to_upper(exclusion_string);
|
string_to_upper(exclusion_string);
|
||||||
|
|
||||||
for (i = 0; i < (unsigned)strings_count; i++)
|
for (i = 0; i < (unsigned)strings_count; i++)
|
||||||
{
|
{
|
||||||
strlcpy(comparison_string, strings[i], 32);
|
strlcpy(comparison_string, strings[i], sizeof(comparison_string));
|
||||||
string_to_upper(comparison_string);
|
string_to_upper(comparison_string);
|
||||||
|
|
||||||
if (string_is_equal_fast(exclusion_string,
|
if (string_is_equal(exclusion_string,
|
||||||
comparison_string, strlen(comparison_string)))
|
comparison_string))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,20 +147,20 @@ static bool left_exclusion(char *left,
|
|||||||
static bool left_parens_or_brackets_excluding_region(char *left)
|
static bool left_parens_or_brackets_excluding_region(char *left)
|
||||||
{
|
{
|
||||||
return left_parens_or_brackets(left)
|
return left_parens_or_brackets(left)
|
||||||
&& !left_exclusion(left, region_strings, region_strings_length);
|
&& !left_exclusion(left, region_strings, REGION_STRINGS_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool left_parens_or_brackets_excluding_disc(char *left)
|
static bool left_parens_or_brackets_excluding_disc(char *left)
|
||||||
{
|
{
|
||||||
return left_parens_or_brackets(left)
|
return left_parens_or_brackets(left)
|
||||||
&& !left_exclusion(left, disc_strings, disc_strings_length);
|
&& !left_exclusion(left, disc_strings, DISC_STRINGS_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool left_parens_or_brackets_excluding_region_or_disc(char *left)
|
static bool left_parens_or_brackets_excluding_region_or_disc(char *left)
|
||||||
{
|
{
|
||||||
return left_parens_or_brackets(left)
|
return left_parens_or_brackets(left)
|
||||||
&& !left_exclusion(left, region_strings, region_strings_length)
|
&& !left_exclusion(left, region_strings, REGION_STRINGS_LENGTH)
|
||||||
&& !left_exclusion(left, disc_strings, disc_strings_length);
|
&& !left_exclusion(left, disc_strings, DISC_STRINGS_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_remove_parens(char *label)
|
void label_remove_parens(char *label)
|
||||||
@ -176,20 +175,24 @@ void label_remove_brackets(char *label)
|
|||||||
|
|
||||||
void label_remove_parens_and_brackets(char *label)
|
void label_remove_parens_and_brackets(char *label)
|
||||||
{
|
{
|
||||||
label_sanitize(label, left_parens_or_brackets, right_parens_or_brackets);
|
label_sanitize(label, left_parens_or_brackets,
|
||||||
|
right_parens_or_brackets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_keep_region(char *label)
|
void label_keep_region(char *label)
|
||||||
{
|
{
|
||||||
label_sanitize(label, left_parens_or_brackets_excluding_region, right_parens_or_brackets);
|
label_sanitize(label, left_parens_or_brackets_excluding_region,
|
||||||
|
right_parens_or_brackets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_keep_disc(char *label)
|
void label_keep_disc(char *label)
|
||||||
{
|
{
|
||||||
label_sanitize(label, left_parens_or_brackets_excluding_disc, right_parens_or_brackets);
|
label_sanitize(label, left_parens_or_brackets_excluding_disc,
|
||||||
|
right_parens_or_brackets);
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_keep_region_and_disc(char *label)
|
void label_keep_region_and_disc(char *label)
|
||||||
{
|
{
|
||||||
label_sanitize(label, left_parens_or_brackets_excluding_region_or_disc, right_parens_or_brackets);
|
label_sanitize(label, left_parens_or_brackets_excluding_region_or_disc,
|
||||||
|
right_parens_or_brackets);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user