From 1862ba5ceca8d2158edf2281d8b6a418e6ac06bf Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Mon, 4 Jul 2022 14:24:06 +0200 Subject: [PATCH] Define custom isdigit version. The expression parser now uses the custom isspace and isdigit --- src/runtime/c/pgf/expr.cxx | 12 ++++++------ src/runtime/c/pgf/text.cxx | 6 ++++++ src/runtime/c/pgf/text.h | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/runtime/c/pgf/expr.cxx b/src/runtime/c/pgf/expr.cxx index c24d1751c..b0a742d5a 100644 --- a/src/runtime/c/pgf/expr.cxx +++ b/src/runtime/c/pgf/expr.cxx @@ -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; } diff --git a/src/runtime/c/pgf/text.cxx b/src/runtime/c/pgf/text.cxx index c7b1770b3..017fc6237 100644 --- a/src/runtime/c/pgf/text.cxx +++ b/src/runtime/c/pgf/text.cxx @@ -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'); +} diff --git a/src/runtime/c/pgf/text.h b/src/runtime/c/pgf/text.h index aa6dd0edc..f2b34c828 100644 --- a/src/runtime/c/pgf/text.h +++ b/src/runtime/c/pgf/text.h @@ -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