Fixed many invalid uses of StringView::GetText(), where a null-terminated string was required.

Renamed GetText() to GetNonTerminatedText() to reduce chance of same bugs appearing in the future.
This commit is contained in:
Zbigniew Skowron
2021-08-08 22:04:54 +02:00
parent 6ac0d5d3f4
commit aecc81f5e5
14 changed files with 158 additions and 108 deletions

View File

@@ -278,18 +278,18 @@ String Localization::GetPluralString(const String& id, int32 n, const String& fa
{
CHECK_RETURN(n >= 1, fallback);
n--;
StringView result;
const String* result = nullptr;
for (auto& e : Instance.LocalizedStringTables)
{
const auto table = e.Get();
const auto messages = table ? table->Entries.TryGet(id) : nullptr;
if (messages && messages->Count() > n)
{
result = messages->At(n);
result = &messages->At(n);
break;
}
}
if (result.IsEmpty())
result = fallback;
return String::Format(result.GetText(), n);
if (!result)
result = &fallback;
return String::Format(result->GetText(), n);
}