mirror of
https://github.com/nlohmann/json.git
synced 2026-08-21 00:23:17 +00:00
fix: leave the character that terminates a number in the input
Read the character following a number without consuming it, instead of consuming it and putting it back. input_stream_adapter now peeks with sgetc() and only steps over the character when the next one is requested or when the adapter is destroyed, so releasing it cannot fail - no putback position is required from the streambuf. Suggested by gregmarr in #5344. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -102,8 +102,8 @@ class parser
|
||||
if (!strict)
|
||||
{
|
||||
// the caller keeps using the input: position it right after
|
||||
// the value by giving back the character that terminated it
|
||||
m_lexer.restore_pending_unget();
|
||||
// the value by leaving the character that terminated it
|
||||
m_lexer.release_lookahead();
|
||||
}
|
||||
// in strict mode, input must be completely read
|
||||
else if (get_token() != token_type::end_of_input)
|
||||
@@ -136,7 +136,7 @@ class parser
|
||||
if (!strict)
|
||||
{
|
||||
// see above
|
||||
m_lexer.restore_pending_unget();
|
||||
m_lexer.release_lookahead();
|
||||
}
|
||||
// in strict mode, input must be completely read
|
||||
else if (get_token() != token_type::end_of_input)
|
||||
@@ -179,8 +179,8 @@ class parser
|
||||
if (result && !strict)
|
||||
{
|
||||
// the caller keeps using the input: position it right after the
|
||||
// value by giving back the character that terminated it
|
||||
m_lexer.restore_pending_unget();
|
||||
// value by leaving the character that terminated it
|
||||
m_lexer.release_lookahead();
|
||||
}
|
||||
// strict mode: next byte must be EOF
|
||||
else if (result && strict && (get_token() != token_type::end_of_input))
|
||||
|
||||
Reference in New Issue
Block a user