From d55a4460f19cdb31dc92cc53aab13b58a241ccbf Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sun, 9 Aug 2015 20:11:20 +0100 Subject: [PATCH] Removed useless piece of code (pretty-printing octal characters). 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 | 44 +++------------------------------------ re2c/src/codegen/print.h | 1 - 2 files changed, 3 insertions(+), 42 deletions(-) diff --git a/re2c/src/codegen/print.cc b/re2c/src/codegen/print.cc index 1c67fe42..2ab73d55 100644 --- a/re2c/src/codegen/print.cc +++ b/re2c/src/codegen/print.cc @@ -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 (c); + break; } } diff --git a/re2c/src/codegen/print.h b/re2c/src/codegen/print.h index 3d8483ac..59d97fdd 100644 --- a/re2c/src/codegen/print.h +++ b/re2c/src/codegen/print.h @@ -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); -- 2.40.0