Ticket #9893: 0002-property_tree-fix-GCC-4.7.3-Wtype-limits-warning.patch

File 0002-property_tree-fix-GCC-4.7.3-Wtype-limits-warning.patch, 3.2 KB (added by mstahl@…, 9 years ago)

patch that applies to git master

  • include/boost/property_tree/detail/json_parser_write.hpp

    From c75e5acc20697df61fced39bce94fb8a6f2efb52 Mon Sep 17 00:00:00 2001
    From: Adam Co <rattles2013@gmail.com>
    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 <mstahl@redhat.com>
    ---
     .../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 b namespace boost { namespace property_tree { namespace json_parser  
    3232            // This assumes an ASCII superset. But so does everything in PTree.
    3333            // We escape everything outside ASCII, because this code can't
    3434            // handle high unicode characters.
    35             if (*b == 0x20 || *b == 0x21 || (*b >= 0x23 && *b <= 0x2E) ||
    36                 (*b >= 0x30 && *b <= 0x5B) || (*b >= 0x5D && *b <= 0xFF))
    37                 result += *b;
    38             else if (*b == Ch('\b')) result += Ch('\\'), result += Ch('b');
    39             else if (*b == Ch('\f')) result += Ch('\\'), result += Ch('f');
    40             else if (*b == Ch('\n')) result += Ch('\\'), result += Ch('n');
    41             else if (*b == Ch('\r')) result += Ch('\\'), result += Ch('r');
    42             else if (*b == Ch('\t')) result += Ch('\\'), result += Ch('t');
    43             else if (*b == Ch('/')) result += Ch('\\'), result += Ch('/');
    44             else if (*b == Ch('"'))  result += Ch('\\'), result += Ch('"');
    45             else if (*b == Ch('\\')) result += Ch('\\'), result += Ch('\\');
     35            typename std::basic_string<Ch>::traits_type::int_type bDref = *b;
     36            if (bDref == 0x20 || bDref == 0x21 || (bDref >= 0x23 && bDref <= 0x2E) ||
     37                (bDref >= 0x30 && bDref <= 0x5B) || (bDref >= 0x5D && bDref <= 0xFF))
     38                result += bDref;
     39            else if (bDref == Ch('\b')) result += Ch('\\'), result += Ch('b');
     40            else if (bDref == Ch('\f')) result += Ch('\\'), result += Ch('f');
     41            else if (bDref == Ch('\n')) result += Ch('\\'), result += Ch('n');
     42            else if (bDref == Ch('\r')) result += Ch('\\'), result += Ch('r');
     43            else if (bDref == Ch('\t')) result += Ch('\\'), result += Ch('t');
     44            else if (bDref == Ch('/')) result += Ch('\\'), result += Ch('/');
     45            else if (bDref == Ch('"'))  result += Ch('\\'), result += Ch('"');
     46            else if (bDref == Ch('\\')) result += Ch('\\'), result += Ch('\\');
    4647            else
    4748            {
    4849                const char *hexdigits = "0123456789ABCDEF";
    4950                typedef typename make_unsigned<Ch>::type UCh;
    5051                unsigned long u = (std::min)(static_cast<unsigned long>(
    51                                                  static_cast<UCh>(*b)),
     52                                                 static_cast<UCh>(bDref)),
    5253                                             0xFFFFul);
    5354                int d1 = u / 4096; u -= d1 * 4096;
    5455                int d2 = u / 256; u -= d2 * 256;