1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 20:43:04 +01:00

Fix parsing of shortcuts

This commit is contained in:
Ted John
2021-01-17 16:11:52 +00:00
parent 46c3fd4e5f
commit 2b197d0fb2
8 changed files with 118 additions and 63 deletions

View File

@@ -254,35 +254,14 @@ namespace String
}
}
bool StartsWith(const utf8* str, const utf8* match, bool ignoreCase)
bool StartsWith(std::string_view str, std::string_view match, bool ignoreCase)
{
if (ignoreCase)
if (str.size() >= match.size())
{
while (*match != '\0')
{
if (*str == '\0' || tolower(*str++) != tolower(*match++))
{
return false;
}
}
return true;
auto view = str.substr(0, match.size());
return Equals(view, match, ignoreCase);
}
else
{
while (*match != '\0')
{
if (*str == '\0' || *str++ != *match++)
{
return false;
}
}
return true;
}
}
bool StartsWith(const std::string& str, const std::string& match, bool ignoreCase)
{
return StartsWith(str.c_str(), match.c_str(), ignoreCase);
return false;
}
bool EndsWith(std::string_view str, std::string_view match, bool ignoreCase)