]> granicus.if.org Git - re2c/commitdiff
Removed useless piece of code (pretty-printing octal characters).
authorUlya Trofimovich <skvadrik@gmail.com>
Sun, 9 Aug 2015 19:11:20 +0000 (20:11 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Sun, 9 Aug 2015 19:11:20 +0000 (20:11 +0100)
This piece of code could (and should) never be executed: EBCDIC and
non-pritables are handled prior to calling 'prtCh'.

re2c/src/codegen/print.cc
re2c/src/codegen/print.h

index 1c67fe4262306668a46ade9f7511dee548d9eead..2ab73d55858e0d9e925815247a556ddfcf3e1bf1 100644 (file)
@@ -6,11 +6,6 @@
 namespace re2c
 {
 
-char octCh(uint32_t c)
-{
-       return '0' + c % 8;
-}
-
 char hexCh(uint32_t c)
 {
        static const char * sHex = "0123456789ABCDEF";
@@ -65,15 +60,7 @@ void prtHex(std::ostream& o, uint32_t c)
 
 void prtCh(std::ostream& o, uint32_t c)
 {
-       if (encoding.is(Enc::EBCDIC))
-       {
-               prtHex(o, c);
-               return;
-       }
-
-       int oc = (int)(c);
-
-       switch (oc)
+       switch (c)
        {
                case '\'':
                o << (DFlag ? "'" : "\\'");
@@ -116,33 +103,8 @@ void prtCh(std::ostream& o, uint32_t c)
                break;
 
                default:
-
-               if ((oc < 256) && isprint(oc))
-               {
-                       o << (char) oc;
-               }
-               else if (encoding.szCodeUnit() == 4)
-               {
-                       o << "0x"
-                         << hexCh(oc >> 20)
-                         << hexCh(oc >> 16)
-                         << hexCh(oc >> 12)
-                         << hexCh(oc >>  8)
-                         << hexCh(oc >>  4)
-                         << hexCh(oc);
-               }
-               else if (encoding.szCodeUnit() == 2)
-               {
-                       o << "0x"
-                         << hexCh(oc >> 12)
-                         << hexCh(oc >>  8)
-                         << hexCh(oc >>  4)
-                         << hexCh(oc);
-               }
-               else
-               {
-                       o << '\\' << octCh(oc / 64) << octCh(oc / 8) << octCh(oc);
-               }
+               o << static_cast<char> (c);
+               break;
        }
 }
 
index 3d8483acb7e3d13ffc248cfa116e1d2d02c88269..59d97fdd2e99f5263b5e16d0456fde4ac2ecd156 100644 (file)
@@ -8,7 +8,6 @@
 namespace re2c
 {
 
-char octCh(uint32_t c);
 char hexCh(uint32_t c);
 void prtCh(std::ostream&, uint32_t);
 void prtHex(std::ostream&, uint32_t);