From: Ulya Trofimovich Date: Mon, 10 Aug 2015 09:26:14 +0000 (+0100) Subject: Print single character as char rather than convert it to one-symbol string. X-Git-Tag: 0.15~145 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09fde6595a8882ed35d89511be43e204e3ac997c;p=re2c Print single character as char rather than convert it to one-symbol string. --- 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);