From 09fde6595a8882ed35d89511be43e204e3ac997c Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Mon, 10 Aug 2015 10:26:14 +0100 Subject: [PATCH] Print single character as char rather than convert it to one-symbol string. --- re2c/src/codegen/go_emit.cc | 2 +- re2c/src/codegen/output.cc | 6 ++++++ re2c/src/codegen/output.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/re2c/src/codegen/go_emit.cc b/re2c/src/codegen/go_emit.cc index ebd9e56c..c196e646 100644 --- a/re2c/src/codegen/go_emit.cc +++ b/re2c/src/codegen/go_emit.cc @@ -72,7 +72,7 @@ void Case::emit (OutputFile & o, uint32_t ind) { const uint32_t c = encoding.decodeUnsafe (b); if (isprint (c)) - o << " /* " << std::string (1, c) << " */"; + o << " /* " << static_cast (c) << " */"; } bool last_case = i == ranges.size () - 1 && b == ranges[i].second - 1; if (!last_case) diff --git a/re2c/src/codegen/output.cc b/re2c/src/codegen/output.cc index e8e26c4d..d24ac8f8 100644 --- a/re2c/src/codegen/output.cc +++ b/re2c/src/codegen/output.cc @@ -134,6 +134,12 @@ void OutputFile::write_user_start_label () } } +OutputFile & operator << (OutputFile & u, char c) +{ + u.stream () << c; + return u; +} + OutputFile & operator << (OutputFile & u, uint32_t n) { u.stream () << n; diff --git a/re2c/src/codegen/output.h b/re2c/src/codegen/output.h index 1f584da1..73b0c4ef 100644 --- a/re2c/src/codegen/output.h +++ b/re2c/src/codegen/output.h @@ -76,6 +76,7 @@ public: void write_line_info (uint32_t l, const char * fn); void write_version_time (); void write_user_start_label (); + friend OutputFile & operator << (OutputFile & o, char c); friend OutputFile & operator << (OutputFile & o, uint32_t n); friend OutputFile & operator << (OutputFile & o, const std::string & s); friend OutputFile & operator << (OutputFile & o, const char * s); -- 2.40.0