dont remove null terminator in remove repetition

This commit is contained in:
Akash Mozumdar 2019-06-09 07:31:45 -04:00
parent e453b571ba
commit 121606af14

View File

@ -312,9 +312,9 @@ namespace Util
bool RemoveRepetition(std::wstring& text) bool RemoveRepetition(std::wstring& text)
{ {
wchar_t* end = text.data() + text.size(); wchar_t* end = text.data() + text.size();
for (int len = text.size() / 3; len > 6; --len) for (int length = text.size() / 3; length > 6; --length)
if (wcsncmp(end - len * 3, end - len * 2, len) == 0 && wcsncmp(end - len * 3, end - len * 1, len) == 0) if (wcsncmp(end - length * 3, end - length * 2, length) == 0 && wcsncmp(end - length * 3, end - length * 1, length) == 0)
return RemoveRepetition(text = end - len), true; return RemoveRepetition(text = std::wstring(end - length, length)), true;
return false; return false;
} }