mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-19 05:52:27 +01:00
Fix undefined use of cctype functions
This commit is contained in:
@@ -392,9 +392,10 @@ namespace OpenRCT2::Ui
|
|||||||
{
|
{
|
||||||
filtersb << ' ';
|
filtersb << ' ';
|
||||||
}
|
}
|
||||||
else if (isalpha(c))
|
else if (isalpha(static_cast<unsigned char>(c)))
|
||||||
{
|
{
|
||||||
filtersb << '[' << static_cast<char>(tolower(c)) << static_cast<char>(toupper(c)) << ']';
|
auto uc = static_cast<unsigned char>(c);
|
||||||
|
filtersb << '[' << static_cast<char>(tolower(uc)) << static_cast<char>(toupper(uc)) << ']';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1497,13 +1497,13 @@ static bool filter_string(const ObjectRepositoryItem* item)
|
|||||||
|
|
||||||
// Make use of lowercase characters only
|
// Make use of lowercase characters only
|
||||||
for (int32_t i = 0; name_lower[i] != '\0'; i++)
|
for (int32_t i = 0; name_lower[i] != '\0'; i++)
|
||||||
name_lower[i] = static_cast<char>(tolower(name_lower[i]));
|
name_lower[i] = static_cast<char>(tolower(static_cast<unsigned char>(name_lower[i])));
|
||||||
for (int32_t i = 0; type_lower[i] != '\0'; i++)
|
for (int32_t i = 0; type_lower[i] != '\0'; i++)
|
||||||
type_lower[i] = static_cast<char>(tolower(type_lower[i]));
|
type_lower[i] = static_cast<char>(tolower(static_cast<unsigned char>(type_lower[i])));
|
||||||
for (int32_t i = 0; object_path[i] != '\0'; i++)
|
for (int32_t i = 0; object_path[i] != '\0'; i++)
|
||||||
object_path[i] = static_cast<char>(tolower(object_path[i]));
|
object_path[i] = static_cast<char>(tolower(static_cast<unsigned char>(object_path[i])));
|
||||||
for (int32_t i = 0; filter_lower[i] != '\0'; i++)
|
for (int32_t i = 0; filter_lower[i] != '\0'; i++)
|
||||||
filter_lower[i] = static_cast<char>(tolower(filter_lower[i]));
|
filter_lower[i] = static_cast<char>(tolower(static_cast<unsigned char>(filter_lower[i])));
|
||||||
|
|
||||||
// Check if the searched string exists in the name, ride type, or filename
|
// Check if the searched string exists in the name, ride type, or filename
|
||||||
bool inName = strstr(name_lower, filter_lower) != nullptr;
|
bool inName = strstr(name_lower, filter_lower) != nullptr;
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ private:
|
|||||||
utf8 filterStringLower[sizeof(_filterString)];
|
utf8 filterStringLower[sizeof(_filterString)];
|
||||||
String::Set(filterStringLower, sizeof(filterStringLower), _filterString);
|
String::Set(filterStringLower, sizeof(filterStringLower), _filterString);
|
||||||
for (int32_t i = 0; filterStringLower[i] != '\0'; i++)
|
for (int32_t i = 0; filterStringLower[i] != '\0'; i++)
|
||||||
filterStringLower[i] = static_cast<utf8>(tolower(filterStringLower[i]));
|
filterStringLower[i] = static_cast<utf8>(tolower(static_cast<unsigned char>(filterStringLower[i])));
|
||||||
|
|
||||||
// Fill the set with indices for tracks that match the filter
|
// Fill the set with indices for tracks that match the filter
|
||||||
for (uint16_t i = 0; i < _trackDesigns.size(); i++)
|
for (uint16_t i = 0; i < _trackDesigns.size(); i++)
|
||||||
@@ -101,7 +101,7 @@ private:
|
|||||||
utf8 trackNameLower[USER_STRING_MAX_LENGTH];
|
utf8 trackNameLower[USER_STRING_MAX_LENGTH];
|
||||||
String::Set(trackNameLower, sizeof(trackNameLower), _trackDesigns[i].name);
|
String::Set(trackNameLower, sizeof(trackNameLower), _trackDesigns[i].name);
|
||||||
for (int32_t j = 0; trackNameLower[j] != '\0'; j++)
|
for (int32_t j = 0; trackNameLower[j] != '\0'; j++)
|
||||||
trackNameLower[j] = static_cast<utf8>(tolower(trackNameLower[j]));
|
trackNameLower[j] = static_cast<utf8>(tolower(static_cast<unsigned char>(trackNameLower[j])));
|
||||||
|
|
||||||
if (strstr(trackNameLower, filterStringLower) != nullptr)
|
if (strstr(trackNameLower, filterStringLower) != nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ namespace String
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i < a.size(); i++)
|
for (size_t i = 0; i < a.size(); i++)
|
||||||
{
|
{
|
||||||
if (tolower(a[i]) != tolower(b[i]))
|
if (tolower(static_cast<unsigned char>(a[i])) != tolower(static_cast<unsigned char>(b[i])))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ namespace String
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tolower(ai) != tolower(bi))
|
else if (tolower(static_cast<unsigned char>(ai)) != tolower(static_cast<unsigned char>(bi)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -822,7 +822,7 @@ namespace String
|
|||||||
for (auto c : value)
|
for (auto c : value)
|
||||||
{
|
{
|
||||||
// Keep alphanumeric and other accepted characters intact
|
// Keep alphanumeric and other accepted characters intact
|
||||||
if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
|
if (std::isalnum(static_cast<unsigned char>(c)) || c == '-' || c == '_' || c == '.' || c == '~')
|
||||||
{
|
{
|
||||||
escaped << c;
|
escaped << c;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace OpenRCT2::Scripting
|
|||||||
auto result = s.substr(sizeof("PERMISSION_") - 1);
|
auto result = s.substr(sizeof("PERMISSION_") - 1);
|
||||||
for (auto& c : result)
|
for (auto& c : result)
|
||||||
{
|
{
|
||||||
c = std::tolower(c);
|
c = std::tolower(static_cast<unsigned char>(c));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ int32_t strcicmp(char const* a, char const* b)
|
|||||||
{
|
{
|
||||||
for (;; a++, b++)
|
for (;; a++, b++)
|
||||||
{
|
{
|
||||||
int32_t d = tolower(*a) - tolower(*b);
|
int32_t d = tolower(static_cast<unsigned char>(*a)) - tolower(static_cast<unsigned char>(*b));
|
||||||
if (d != 0 || !*a)
|
if (d != 0 || !*a)
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ int32_t strlogicalcmp(const char* s1, const char* s2)
|
|||||||
return *s1 != '\0';
|
return *s1 != '\0';
|
||||||
if (*s1 == '\0')
|
if (*s1 == '\0')
|
||||||
return -1;
|
return -1;
|
||||||
if (!(isdigit(*s1) && isdigit(*s2)))
|
if (!(isdigit(static_cast<unsigned char>(*s1)) && isdigit(static_cast<unsigned char>(*s2))))
|
||||||
{
|
{
|
||||||
if (toupper(*s1) != toupper(*s2))
|
if (toupper(*s1) != toupper(*s2))
|
||||||
return toupper(*s1) - toupper(*s2);
|
return toupper(*s1) - toupper(*s2);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ static std::string sanitizeTestName(const std::string& name)
|
|||||||
std::string res;
|
std::string res;
|
||||||
for (char c : nameOnly)
|
for (char c : nameOnly)
|
||||||
{
|
{
|
||||||
if (isalnum(c))
|
if (isalnum(static_cast<unsigned char>(c)))
|
||||||
res += c;
|
res += c;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user