From 5c8f03d88199a4cf75f02f8ccd6f06df7e0ca882 Mon Sep 17 00:00:00 2001 From: Daniel Parker Date: Wed, 8 Jan 2025 13:57:36 -0500 Subject: [PATCH] Revert 1.0.0 parsing change --- include/jsoncons/json_object.hpp | 2 +- include/jsoncons/json_parser.hpp | 48 +++++--------------------------- include/jsoncons/json_reader.hpp | 1 - 3 files changed, 8 insertions(+), 43 deletions(-) diff --git a/include/jsoncons/json_object.hpp b/include/jsoncons/json_object.hpp index 0106dfd2f..887962323 100644 --- a/include/jsoncons/json_object.hpp +++ b/include/jsoncons/json_object.hpp @@ -542,7 +542,7 @@ namespace jsoncons { { for (auto s = first; s != last; ++s) { - members_.emplace_back(key_type(s->first.c_str(), s->first.size(), get_allocator()), s->second); + members_.emplace_back(key_type((*s).first.c_str(), (*s).first.size(), get_allocator()), (*s).second); } std::stable_sort(members_.begin(),members_.end(), [](const key_value_type& a, const key_value_type& b) -> bool {return a.key().compare(b.key()) < 0;}); diff --git a/include/jsoncons/json_parser.hpp b/include/jsoncons/json_parser.hpp index 569e40bf7..40380b472 100644 --- a/include/jsoncons/json_parser.hpp +++ b/include/jsoncons/json_parser.hpp @@ -2178,55 +2178,21 @@ class basic_json_parser : public ser_context state_ = json_parse_state::string; return; } - case '\r': - { - position_ += (input_ptr_ - sb + 1); - more_ = err_handler_(json_errc::illegal_character_in_string, *this); - if (!more_) - { - ec = json_errc::illegal_character_in_string; - state_ = json_parse_state::string; - return; - } - // recovery - keep - string_buffer_.append(sb, input_ptr_ - sb + 1); - ++input_ptr_; - push_state(state_); - state_ = json_parse_state::cr; - return; - } case '\n': - { - ++line_; - ++position_; - mark_position_ = position_; - more_ = err_handler_(json_errc::illegal_character_in_string, *this); - if (!more_) - { - ec = json_errc::illegal_character_in_string; - state_ = json_parse_state::string; - return; - } - // recovery - keep - string_buffer_.append(sb, input_ptr_ - sb + 1); - ++input_ptr_; - return; - } + case '\r': case '\t': { position_ += (input_ptr_ - sb + 1); - more_ = err_handler_(json_errc::illegal_character_in_string, *this); - if (!more_) + if (!err_handler_(json_errc::illegal_character_in_string, *this)) { + more_ = false; ec = json_errc::illegal_character_in_string; - state_ = json_parse_state::string; return; } - // recovery - keep - string_buffer_.append(sb, input_ptr_ - sb + 1); - ++input_ptr_; - state_ = json_parse_state::string; - return; + // recovery - skip + string_buffer_.append(sb,input_ptr_-sb); + sb = input_ptr_ + 1; + break; } case '\\': { diff --git a/include/jsoncons/json_reader.hpp b/include/jsoncons/json_reader.hpp index b3d8ccf70..3afd19881 100644 --- a/include/jsoncons/json_reader.hpp +++ b/include/jsoncons/json_reader.hpp @@ -390,7 +390,6 @@ namespace jsoncons { bool eof() const { - std::cout << "parser no more source: " << parser_.source_exhausted() << ", source eof: " << source_.eof() << "\n"; return parser_.source_exhausted() && source_.eof(); }