libluna: Fix comparison of StringViews without null termination
All checks were successful
continuous-integration/drone/push Build is passing

This regressed in de7e58c274, and made value arguments pretty much unusable.

This really needs a test...
This commit is contained in:
apio 2023-07-25 17:25:18 +02:00
parent 9bb3fed611
commit 7f990b161b
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -50,12 +50,14 @@ const char& StringView::operator[](usize index) const
bool StringView::operator==(const char* other) const
{
return !strcmp(m_string, other);
if (m_length != strlen(other)) return false;
return !strncmp(m_string, other, m_length);
}
bool StringView::operator==(StringView other) const
{
return !strcmp(m_string, other.m_string);
if (m_length != other.m_length) return false;
return !strncmp(m_string, other.m_string, m_length);
}
Result<Vector<String>> StringView::split(StringView delim) const