mirror of https://github.com/OpenTTD/OpenTTD
Codechange: All ParagraphLayoutFactory::AppendToBuffer assume that the buffer has at least some space.
Assert on that.pull/11320/head
parent
baf7cc858b
commit
55da426d44
|
@ -96,8 +96,9 @@ public:
|
||||||
* @param c The character to add.
|
* @param c The character to add.
|
||||||
* @return The number of buffer spaces that were used.
|
* @return The number of buffer spaces that were used.
|
||||||
*/
|
*/
|
||||||
/* static */ size_t FallbackParagraphLayoutFactory::AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c)
|
/* static */ size_t FallbackParagraphLayoutFactory::AppendToBuffer(char32_t *buff, [[maybe_unused]] const char32_t *buffer_last, char32_t c)
|
||||||
{
|
{
|
||||||
|
assert(buff < buffer_last);
|
||||||
*buff = c;
|
*buff = c;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -522,6 +522,7 @@ std::unique_ptr<const ICUParagraphLayout::Line> ICUParagraphLayout::NextLine(int
|
||||||
|
|
||||||
/* static */ size_t ICUParagraphLayoutFactory::AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c)
|
/* static */ size_t ICUParagraphLayoutFactory::AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c)
|
||||||
{
|
{
|
||||||
|
assert(buff < buffer_last);
|
||||||
/* Transform from UTF-32 to internal ICU format of UTF-16. */
|
/* Transform from UTF-32 to internal ICU format of UTF-16. */
|
||||||
int32_t length = 0;
|
int32_t length = 0;
|
||||||
UErrorCode err = U_ZERO_ERROR;
|
UErrorCode err = U_ZERO_ERROR;
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c)
|
static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c)
|
||||||
{
|
{
|
||||||
|
assert(buff < buffer_last);
|
||||||
if (c >= 0x010000U) {
|
if (c >= 0x010000U) {
|
||||||
/* Character is encoded using surrogates in UTF-16. */
|
/* Character is encoded using surrogates in UTF-16. */
|
||||||
if (buff + 1 <= buffer_last) {
|
if (buff + 1 <= buffer_last) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
*/
|
*/
|
||||||
static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c)
|
static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c)
|
||||||
{
|
{
|
||||||
|
assert(buff < buffer_last);
|
||||||
if (c >= 0x010000U) {
|
if (c >= 0x010000U) {
|
||||||
/* Character is encoded using surrogates in UTF-16. */
|
/* Character is encoded using surrogates in UTF-16. */
|
||||||
if (buff + 1 <= buffer_last) {
|
if (buff + 1 <= buffer_last) {
|
||||||
|
|
Loading…
Reference in New Issue