mirror of https://github.com/OpenTTD/OpenTTD
Fix fd2949d: use std::prev() to walk back from a possible string::end()
parent
2eb32ece6d
commit
155aaa5967
|
@ -166,9 +166,11 @@ inline const char *Utf8PrevChar(const char *s)
|
||||||
|
|
||||||
inline std::string::iterator Utf8PrevChar(std::string::iterator &s)
|
inline std::string::iterator Utf8PrevChar(std::string::iterator &s)
|
||||||
{
|
{
|
||||||
auto *cur = &*s;
|
auto cur = s;
|
||||||
auto *prev = Utf8PrevChar(cur);
|
do {
|
||||||
return s - (cur - prev);
|
cur = std::prev(cur);
|
||||||
|
} while (IsUtf8Part(*cur));
|
||||||
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Utf8StringLength(const char *s);
|
size_t Utf8StringLength(const char *s);
|
||||||
|
|
Loading…
Reference in New Issue