mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-25 07:29:10 +00:00
Fix fd2949d
: use std::prev() to walk back from a possible string::end()
This commit is contained in:
committed by
Patric Stout
parent
2eb32ece6d
commit
155aaa5967
@@ -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);
|
||||
|
Reference in New Issue
Block a user