mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 09:02:50 -06:00
fix the estimation of the character size in PgfExprParser::putc
This commit is contained in:
@@ -248,21 +248,22 @@ uint32_t PgfExprParser::getc()
|
|||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PgfExprParser::putc(uint32_t ch)
|
void PgfExprParser::putc(uint32_t ucs)
|
||||||
{
|
{
|
||||||
size_t ch_len =
|
size_t ucs_len =
|
||||||
(ch < 0xe0 ? 1 :
|
(ucs < 0x80 ? 1 :
|
||||||
ch < 0xf0 ? 2 :
|
ucs < 0x800 ? 2 :
|
||||||
ch < 0xf8 ? 3 :
|
ucs < 0x10000 ? 3 :
|
||||||
ch < 0xfc ? 4 :
|
ucs < 0x200000 ? 4 :
|
||||||
5
|
ucs < 0x4000000 ? 5 :
|
||||||
|
6
|
||||||
);
|
);
|
||||||
size_t len = token_value ? token_value->size : 0;
|
size_t len = token_value ? token_value->size : 0;
|
||||||
|
|
||||||
token_value = (PgfText*)
|
token_value = (PgfText*)
|
||||||
realloc(token_value, sizeof(PgfText)+len+ch_len+1);
|
realloc(token_value, sizeof(PgfText)+len+ucs_len+1);
|
||||||
uint8_t *p = (uint8_t*) (token_value->text+len);
|
uint8_t *p = (uint8_t*) (token_value->text+len);
|
||||||
pgf_utf8_encode(ch, &p);
|
pgf_utf8_encode(ucs, &p);
|
||||||
token_value->size = p - ((uint8_t*) token_value->text);
|
token_value->size = p - ((uint8_t*) token_value->text);
|
||||||
*(p++) = 0;
|
*(p++) = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user