Remove NOT_REACHED from Layouter::GetCharPosition
Return begin/end value for unknown code point index or out of range input See: #596, #598, https://github.com/OpenTTD/OpenTTD/issues/11291
This commit is contained in:
@@ -230,10 +230,13 @@ Point Layouter::GetCharPosition(std::string_view::const_iterator ch) const
|
|||||||
const auto &line = this->front();
|
const auto &line = this->front();
|
||||||
|
|
||||||
/* Pointer to the end-of-string marker? Return total line width. */
|
/* Pointer to the end-of-string marker? Return total line width. */
|
||||||
if (ch == this->string.end()) {
|
if (ch >= this->string.end()) {
|
||||||
Point p = { line->GetWidth(), 0 };
|
Point p = { line->GetWidth(), 0 };
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
if (ch < this->string.begin()) {
|
||||||
|
return { 0, 0 };
|
||||||
|
}
|
||||||
|
|
||||||
/* Find the code point index which corresponds to the char
|
/* Find the code point index which corresponds to the char
|
||||||
* pointer into our UTF-8 source string. */
|
* pointer into our UTF-8 source string. */
|
||||||
@@ -264,7 +267,8 @@ Point Layouter::GetCharPosition(std::string_view::const_iterator ch) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NOT_REACHED();
|
/* Code point index not found, just give up */
|
||||||
|
return { 0, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user