Define custom isdigit version. The expression parser now uses the custom isspace and isdigit

This commit is contained in:
Krasimir Angelov
2022-07-04 14:24:06 +02:00
parent 69a2b8a448
commit 1862ba5cec
3 changed files with 15 additions and 6 deletions

View File

@@ -435,7 +435,7 @@ void PgfExprParser::token()
token_pos = pos;
token_value = NULL;
while (isspace(ch)) {
while (pgf_utf8_is_space(ch)) {
token_pos = pos;
if (!getc()) {
token_tag = PGF_TOKEN_EOF;
@@ -481,7 +481,7 @@ void PgfExprParser::token()
if (ch == '>') {
getc();
token_tag = PGF_TOKEN_RARROW;
} else if (isdigit(ch)) {
} else if (pgf_utf8_is_digit(ch)) {
putc('-');
goto digit;
}
@@ -548,18 +548,18 @@ void PgfExprParser::token()
token_tag = PGF_TOKEN_WILD;
else
token_tag = PGF_TOKEN_IDENT;
} else if (isdigit(ch)) {
} else if (pgf_utf8_is_digit(ch)) {
digit:
do {
putc(ch);
if (!getc())
break;
} while (isdigit(ch));
} while (pgf_utf8_is_digit(ch));
if (ch == '.') {
putc(ch);
if (getc()) {
while (isdigit(ch)) {
while (pgf_utf8_is_digit(ch)) {
putc(ch);
if (!getc())
break;
@@ -577,7 +577,7 @@ digit:
bool PgfExprParser::lookahead(int ch)
{
while (isspace(this->ch)) {
while (pgf_utf8_is_space(this->ch)) {
if (!getc())
break;
}

View File

@@ -324,3 +324,9 @@ bool pgf_utf8_is_space(uint32_t c)
return false;
}
PGF_INTERNAL
bool pgf_utf8_is_digit(uint32_t c)
{
return (c >= '0' && c <= '9');
}

View File

@@ -38,4 +38,7 @@ uint32_t pgf_utf8_to_upper(uint32_t c);
PGF_INTERNAL_DECL
bool pgf_utf8_is_space(uint32_t c);
PGF_INTERNAL
bool pgf_utf8_is_digit(uint32_t c);
#endif