From c73800f114cf34f4db5650a8eae1636c21645375 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Thu, 20 Aug 2015 13:24:42 +0100 Subject: [PATCH] Zero-extend code units when casing them from 'signed char' to 'uint32_t'. The problem starts with lexer: it should operate on unsigned chars (as re2c wants). Then these casts won't be needed at all. Mixing signed and unsigned chars is bad and lexer should be rewritten to use unsigned chars. --- re2c/bootstrap/src/parse/scanner_lex.cc | 4 ++-- re2c/src/parse/scanner_lex.re | 2 +- re2c/src/parse/unescape.cc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/re2c/bootstrap/src/parse/scanner_lex.cc b/re2c/bootstrap/src/parse/scanner_lex.cc index 5ae87eef..1bc0fd61 100644 --- a/re2c/bootstrap/src/parse/scanner_lex.cc +++ b/re2c/bootstrap/src/parse/scanner_lex.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.14.3 on Thu Aug 20 13:02:58 2015 */ +/* Generated by re2c 0.14.3 on Thu Aug 20 13:23:54 2015 */ #line 1 "../src/parse/scanner_lex.re" #include #include @@ -978,7 +978,7 @@ yy158: } else { for (char * p = tok; p < cur; ++p) { - cpoints.push_back (static_cast (*p)); + cpoints.push_back (static_cast (*p)); } yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted); return STRING; diff --git a/re2c/src/parse/scanner_lex.re b/re2c/src/parse/scanner_lex.re index 6f857002..f5e408db 100644 --- a/re2c/src/parse/scanner_lex.re +++ b/re2c/src/parse/scanner_lex.re @@ -361,7 +361,7 @@ start: } else { for (char * p = tok; p < cur; ++p) { - cpoints.push_back (static_cast (*p)); + cpoints.push_back (static_cast (*p)); } yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted); return STRING; diff --git a/re2c/src/parse/unescape.cc b/re2c/src/parse/unescape.cc index e7aedc15..3cdf3419 100644 --- a/re2c/src/parse/unescape.cc +++ b/re2c/src/parse/unescape.cc @@ -72,7 +72,7 @@ uint32_t unesc_oct (const char * s, const char * s_end) for (++s; s != s_end; ++s) { n <<= 3; - n += static_cast (*s - '0'); + n += static_cast (*s - '0'); } return n; } -- 2.40.0