Skip to content

Commit

Permalink
Revert 1.0.0 parsing change
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Jan 8, 2025
1 parent f5db1e6 commit 5c8f03d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 43 deletions.
2 changes: 1 addition & 1 deletion include/jsoncons/json_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;});
Expand Down
48 changes: 7 additions & 41 deletions include/jsoncons/json_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\\':
{
Expand Down
1 change: 0 additions & 1 deletion include/jsoncons/json_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 5c8f03d

Please sign in to comment.