ignore the last character of a character array if it is the null character

This commit is contained in:
Francois Chabot 2019-01-22 14:28:46 -05:00
parent e89c946451
commit 9dc7b666e7
4 changed files with 4 additions and 6 deletions

View File

@ -399,7 +399,7 @@ class input_adapter
/// input adapter for array
template<class T, std::size_t N>
input_adapter(T (&array)[N])
: input_adapter(std::begin(array), std::end(array)) {}
: input_adapter(std::begin(array), array[N - 1] == 0 ? std::prev(std::end(array)) : std::end(array)) {}
/// input adapter for contiguous container
template<class ContiguousContainer, typename

View File

@ -1461,7 +1461,6 @@ scan_number_done:
// end of input (the null byte is needed when parsing from
// string literals)
case '\0':
case std::char_traits<char>::eof():
return token_type::end_of_input;

View File

@ -2554,7 +2554,7 @@ class input_adapter
/// input adapter for array
template<class T, std::size_t N>
input_adapter(T (&array)[N])
: input_adapter(std::begin(array), std::end(array)) {}
: input_adapter(std::begin(array), array[N - 1] == 0 ? std::prev(std::end(array)) : std::end(array)) {}
/// input adapter for contiguous container
template<class ContiguousContainer, typename
@ -4043,7 +4043,6 @@ scan_number_done:
// end of input (the null byte is needed when parsing from
// string literals)
case '\0':
case std::char_traits<char>::eof():
return token_type::end_of_input;

View File

@ -688,7 +688,7 @@ TEST_CASE("nst's JSONTestSuite")
"test/data/nst_json_testsuite/test_parsing/n_number_real_with_invalid_utf8_after_e.json",
"test/data/nst_json_testsuite/test_parsing/n_number_real_without_fractional_part.json",
"test/data/nst_json_testsuite/test_parsing/n_number_starting_with_dot.json",
//"test/data/nst_json_testsuite/test_parsing/n_number_then_00.json",
"test/data/nst_json_testsuite/test_parsing/n_number_then_00.json",
"test/data/nst_json_testsuite/test_parsing/n_number_with_alpha.json",
"test/data/nst_json_testsuite/test_parsing/n_number_with_alpha_char.json",
"test/data/nst_json_testsuite/test_parsing/n_number_with_leading_zero.json",
@ -1067,7 +1067,7 @@ TEST_CASE("nst's JSONTestSuite (2)")
"test/data/nst_json_testsuite2/test_parsing/n_incomplete_false.json",
"test/data/nst_json_testsuite2/test_parsing/n_incomplete_null.json",
"test/data/nst_json_testsuite2/test_parsing/n_incomplete_true.json",
//"test/data/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json",
"test/data/nst_json_testsuite2/test_parsing/n_multidigit_number_then_00.json",
"test/data/nst_json_testsuite2/test_parsing/n_number_++.json",
"test/data/nst_json_testsuite2/test_parsing/n_number_+1.json",
"test/data/nst_json_testsuite2/test_parsing/n_number_+Inf.json",