StringUtil: Fix logical errors

pull/3544/head
Stenzek 2 months ago
parent faa75991a0
commit e32e64420e
No known key found for this signature in database

@ -31,7 +31,7 @@ static std::string DecodeUTF16StringImpl(const void* bytes, size_t size);
bool StringUtil::WildcardMatch(const char* subject, const char* mask, bool case_sensitive /*= true*/)
{
if (case_sensitive)
if (!case_sensitive)
{
const char* cp = nullptr;
const char* mp = nullptr;
@ -417,7 +417,7 @@ std::string StringUtil::ReplaceAll(const std::string_view subject, const std::st
void StringUtil::ReplaceAll(std::string* subject, const std::string_view search, const std::string_view replacement)
{
if (!subject->empty())
if (!subject->empty() && !search.empty())
{
std::string::size_type start_pos = 0;
while ((start_pos = subject->find(search, start_pos)) != std::string::npos)

@ -141,7 +141,7 @@ inline std::optional<T> FromCharsWithOptionalBase(std::string_view str, std::str
else if (str.starts_with("0b"))
{
base = 2;
str = str.substr(1);
str = str.substr(2);
}
else if (str.starts_with("0") && str.length() > 1)
{

Loading…
Cancel
Save