1
0
Fork 0

Fix fd2949d: use std::prev() to walk back from a possible string::end()

pull/13581/head
Patric Stout 2025-02-16 15:31:36 +01:00 committed by Patric Stout
parent 2eb32ece6d
commit 155aaa5967
1 changed files with 5 additions and 3 deletions

View File

@ -166,9 +166,11 @@ inline const char *Utf8PrevChar(const char *s)
inline std::string::iterator Utf8PrevChar(std::string::iterator &s)
{
auto *cur = &*s;
auto *prev = Utf8PrevChar(cur);
return s - (cur - prev);
auto cur = s;
do {
cur = std::prev(cur);
} while (IsUtf8Part(*cur));
return cur;
}
size_t Utf8StringLength(const char *s);