From c75e5acc20697df61fced39bce94fb8a6f2efb52 Mon Sep 17 00:00:00 2001 From: Adam Co Date: Tue, 22 Apr 2014 13:02:13 +0200 Subject: [PATCH 2/2] property_tree: fix GCC 4.7.3 -Wtype-limits warning Signed-off-by: Michael Stahl --- .../property_tree/detail/json_parser_write.hpp | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/include/boost/property_tree/detail/json_parser_write.hpp b/include/boost/property_tree/detail/json_parser_write.hpp index b52c8ea..eeaa9f1 100644 --- a/include/boost/property_tree/detail/json_parser_write.hpp +++ b/include/boost/property_tree/detail/json_parser_write.hpp @@ -32,23 +32,24 @@ namespace boost { namespace property_tree { namespace json_parser // This assumes an ASCII superset. But so does everything in PTree. // We escape everything outside ASCII, because this code can't // handle high unicode characters. - if (*b == 0x20 || *b == 0x21 || (*b >= 0x23 && *b <= 0x2E) || - (*b >= 0x30 && *b <= 0x5B) || (*b >= 0x5D && *b <= 0xFF)) - result += *b; - else if (*b == Ch('\b')) result += Ch('\\'), result += Ch('b'); - else if (*b == Ch('\f')) result += Ch('\\'), result += Ch('f'); - else if (*b == Ch('\n')) result += Ch('\\'), result += Ch('n'); - else if (*b == Ch('\r')) result += Ch('\\'), result += Ch('r'); - else if (*b == Ch('\t')) result += Ch('\\'), result += Ch('t'); - else if (*b == Ch('/')) result += Ch('\\'), result += Ch('/'); - else if (*b == Ch('"')) result += Ch('\\'), result += Ch('"'); - else if (*b == Ch('\\')) result += Ch('\\'), result += Ch('\\'); + typename std::basic_string::traits_type::int_type bDref = *b; + if (bDref == 0x20 || bDref == 0x21 || (bDref >= 0x23 && bDref <= 0x2E) || + (bDref >= 0x30 && bDref <= 0x5B) || (bDref >= 0x5D && bDref <= 0xFF)) + result += bDref; + else if (bDref == Ch('\b')) result += Ch('\\'), result += Ch('b'); + else if (bDref == Ch('\f')) result += Ch('\\'), result += Ch('f'); + else if (bDref == Ch('\n')) result += Ch('\\'), result += Ch('n'); + else if (bDref == Ch('\r')) result += Ch('\\'), result += Ch('r'); + else if (bDref == Ch('\t')) result += Ch('\\'), result += Ch('t'); + else if (bDref == Ch('/')) result += Ch('\\'), result += Ch('/'); + else if (bDref == Ch('"')) result += Ch('\\'), result += Ch('"'); + else if (bDref == Ch('\\')) result += Ch('\\'), result += Ch('\\'); else { const char *hexdigits = "0123456789ABCDEF"; typedef typename make_unsigned::type UCh; unsigned long u = (std::min)(static_cast( - static_cast(*b)), + static_cast(bDref)), 0xFFFFul); int d1 = u / 4096; u -= d1 * 4096; int d2 = u / 256; u -= d2 * 256; -- 1.8.3.1