| 1 | diff -ur boost.org/boost/property_tree/detail/json_parser_write.hpp boost/boost/property_tree/detail/json_parser_write.hpp
|
|---|
| 2 | --- boost.org/boost/property_tree/detail/json_parser_write.hpp 2014-04-20 13:27:59.126224368 +0300
|
|---|
| 3 | +++ boost/boost/property_tree/detail/json_parser_write.hpp 2014-04-20 13:32:35.206229552 +0300
|
|---|
| 4 | @@ -29,25 +29,26 @@
|
|---|
| 5 | typename std::basic_string<Ch>::const_iterator e = s.end();
|
|---|
| 6 | while (b != e)
|
|---|
| 7 | {
|
|---|
| 8 | + typename std::basic_string<Ch>::traits_type::int_type bDref = *b;
|
|---|
| 9 | // This assumes an ASCII superset. But so does everything in PTree.
|
|---|
| 10 | // We escape everything outside ASCII, because this code can't
|
|---|
| 11 | // handle high unicode characters.
|
|---|
| 12 | - if (*b == 0x20 || *b == 0x21 || (*b >= 0x23 && *b <= 0x2E) ||
|
|---|
| 13 | - (*b >= 0x30 && *b <= 0x5B) || (*b >= 0x5D && *b <= 0xFF))
|
|---|
| 14 | - result += *b;
|
|---|
| 15 | - else if (*b == Ch('\b')) result += Ch('\\'), result += Ch('b');
|
|---|
| 16 | - else if (*b == Ch('\f')) result += Ch('\\'), result += Ch('f');
|
|---|
| 17 | - else if (*b == Ch('\n')) result += Ch('\\'), result += Ch('n');
|
|---|
| 18 | - else if (*b == Ch('\r')) result += Ch('\\'), result += Ch('r');
|
|---|
| 19 | - else if (*b == Ch('/')) result += Ch('\\'), result += Ch('/');
|
|---|
| 20 | - else if (*b == Ch('"')) result += Ch('\\'), result += Ch('"');
|
|---|
| 21 | - else if (*b == Ch('\\')) result += Ch('\\'), result += Ch('\\');
|
|---|
| 22 | + if (bDref == 0x20 || bDref == 0x21 || (bDref >= 0x23 && bDref <= 0x2E) ||
|
|---|
| 23 | + (bDref >= 0x30 && bDref <= 0x5B) || (bDref >= 0x5D && bDref <= 0xFF))
|
|---|
| 24 | + result += bDref;
|
|---|
| 25 | + else if (bDref == Ch('\b')) result += Ch('\\'), result += Ch('b');
|
|---|
| 26 | + else if (bDref == Ch('\f')) result += Ch('\\'), result += Ch('f');
|
|---|
| 27 | + else if (bDref == Ch('\n')) result += Ch('\\'), result += Ch('n');
|
|---|
| 28 | + else if (bDref == Ch('\r')) result += Ch('\\'), result += Ch('r');
|
|---|
| 29 | + else if (bDref == Ch('/')) result += Ch('\\'), result += Ch('/');
|
|---|
| 30 | + else if (bDref == Ch('"')) result += Ch('\\'), result += Ch('"');
|
|---|
| 31 | + else if (bDref == Ch('\\')) result += Ch('\\'), result += Ch('\\');
|
|---|
| 32 | else
|
|---|
| 33 | {
|
|---|
| 34 | const char *hexdigits = "0123456789ABCDEF";
|
|---|
| 35 | typedef typename make_unsigned<Ch>::type UCh;
|
|---|
| 36 | unsigned long u = (std::min)(static_cast<unsigned long>(
|
|---|
| 37 | - static_cast<UCh>(*b)),
|
|---|
| 38 | + static_cast<UCh>(bDref)),
|
|---|
| 39 | 0xFFFFul);
|
|---|
| 40 | int d1 = u / 4096; u -= d1 * 4096;
|
|---|
| 41 | int d2 = u / 256; u -= d2 * 256;
|
|---|