]> granicus.if.org Git - re2c/commitdiff
Zero-extend code units when casing them from 'signed char' to 'uint32_t'.
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 20 Aug 2015 12:24:42 +0000 (13:24 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 20 Aug 2015 12:24:42 +0000 (13:24 +0100)
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
re2c/src/parse/scanner_lex.re
re2c/src/parse/unescape.cc

index 5ae87eef5725920759991b90d3e908d461d39528..1bc0fd61a77e31be285a544a561fd7b44f250d07 100644 (file)
@@ -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 <stdlib.h>
 #include <string.h>
@@ -978,7 +978,7 @@ yy158:
                                        } else {
                                                for (char * p = tok; p < cur; ++p)
                                                {
-                                                       cpoints.push_back (static_cast<uint32_t> (*p));
+                                                       cpoints.push_back (static_cast<uint8_t> (*p));
                                                }
                                                yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted);
                                                return STRING;
index 6f8570026edd686534646d178f0e02a041e87e85..f5e408dbac2fa28ed6911c2d4f623cfa0fb7097b 100644 (file)
@@ -361,7 +361,7 @@ start:
                                        } else {
                                                for (char * p = tok; p < cur; ++p)
                                                {
-                                                       cpoints.push_back (static_cast<uint32_t> (*p));
+                                                       cpoints.push_back (static_cast<uint8_t> (*p));
                                                }
                                                yylval.regexp = cpoint_string (cpoints, bCaseInsensitive || bCaseInverted);
                                                return STRING;
index e7aedc15544c4dca1a7d099f3357f7cf8d165c04..3cdf34193095d63a324b13041dc8d386b5c8a331 100644 (file)
@@ -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<uint32_t> (*s - '0');
+               n += static_cast<uint8_t> (*s - '0');
        }
        return n;
 }