Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65978 - in branches/release/boost/property_tree: . detail
From: sebastian.redl_at_[hidden]
Date: 2010-10-15 09:56:19


Author: cornedbee
Date: 2010-10-15 09:56:17 EDT (Fri, 15 Oct 2010)
New Revision: 65978
URL: http://svn.boost.org/trac/boost/changeset/65978

Log:
Merge more PTree fixes to release (boost)
Properties modified:
   branches/release/boost/property_tree/ (props changed)
Text files modified:
   branches/release/boost/property_tree/detail/json_parser_read.hpp | 30 +++++++++++++++++-------------
   branches/release/boost/property_tree/detail/json_parser_write.hpp | 10 +++++++---
   2 files changed, 24 insertions(+), 16 deletions(-)

Modified: branches/release/boost/property_tree/detail/json_parser_read.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/json_parser_read.hpp (original)
+++ branches/release/boost/property_tree/detail/json_parser_read.hpp 2010-10-15 09:56:17 EDT (Fri, 15 Oct 2010)
@@ -128,6 +128,7 @@
                 {
                     case Ch('\"'): c.string += Ch('\"'); break;
                     case Ch('\\'): c.string += Ch('\\'); break;
+ case Ch('/'): c.string += Ch('/'); break;
                     case Ch('b'): c.string += Ch('\b'); break;
                     case Ch('f'): c.string += Ch('\f'); break;
                     case Ch('n'): c.string += Ch('\n'); break;
@@ -238,21 +239,24 @@
                           !chset_p(detail::widen<Ch>("-+").c_str()) >>
                           +digit_p)
                         ;
-
- string
+
+ string
                     = +(lexeme_d[confix_p('\"', *character, '\"')])
                         ;
-
- character
- = (anychar_p - "\\" - "\"")[typename Context::a_char(self.c)]
- | ch_p("\\") >> expect_escape(escape)
- ;
-
- escape
- = chset_p(detail::widen<Ch>("\"\\bfnrt").c_str())[typename Context::a_escape(self.c)]
- | 'u' >> uint_parser<unsigned long, 16, 4, 4>()[typename Context::a_unicode(self.c)]
- ;
-
+
+ character
+ = (anychar_p - "\\" - "\"")
+ [typename Context::a_char(self.c)]
+ | ch_p("\\") >> expect_escape(escape)
+ ;
+
+ escape
+ = chset_p(detail::widen<Ch>("\"\\/bfnrt").c_str())
+ [typename Context::a_escape(self.c)]
+ | 'u' >> uint_parser<unsigned long, 16, 4, 4>()
+ [typename Context::a_unicode(self.c)]
+ ;
+
                 // Debug
                 BOOST_SPIRIT_DEBUG_RULE(root);
                 BOOST_SPIRIT_DEBUG_RULE(object);

Modified: branches/release/boost/property_tree/detail/json_parser_write.hpp
==============================================================================
--- branches/release/boost/property_tree/detail/json_parser_write.hpp (original)
+++ branches/release/boost/property_tree/detail/json_parser_write.hpp 2010-10-15 09:56:17 EDT (Fri, 15 Oct 2010)
@@ -12,6 +12,7 @@
 
 #include <boost/property_tree/ptree.hpp>
 #include <boost/next_prior.hpp>
+#include <boost/type_traits/make_unsigned.hpp>
 #include <string>
 #include <ostream>
 #include <iomanip>
@@ -31,19 +32,22 @@
             // 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 <= 0x5B) || (*b >= 0x5D && *b <= 0xFF))
+ 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('/')) result += Ch('\\'), result += Ch('/');
             else if (*b == Ch('"')) result += Ch('\\'), result += Ch('"');
             else if (*b == Ch('\\')) result += Ch('\\'), result += Ch('\\');
             else
             {
                 const char *hexdigits = "0123456789ABCDEF";
- unsigned long u = (std::min)(static_cast<unsigned long>(*b),
+ typedef typename make_unsigned<Ch>::type UCh;
+ unsigned long u = (std::min)(static_cast<unsigned long>(
+ static_cast<UCh>(*b)),
                                              0xFFFFul);
                 int d1 = u / 4096; u -= d1 * 4096;
                 int d2 = u / 256; u -= d2 * 256;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk