@@ -1977,14 +1977,16 @@ parse_number(const char* p,
19771977 std::integral_constant<bool , StackEmpty_> stack_empty,
19781978 std::integral_constant<char , First_> first)
19791979{
1980+ bool const precise_parsing = opt_.numbers == number_precision::precise;
1981+ bool const no_parsing = opt_.numbers == number_precision::none;
1982+
19801983 // only one of these will be true if we are not resuming
19811984 // if negative then !zero_first && !nonzero_first
19821985 // if zero_first then !nonzero_first && !negative
19831986 // if nonzero_first then !zero_first && !negative
19841987 bool const negative = first == ' -' ;
19851988 bool const zero_first = first == ' 0' ;
19861989 bool const nonzero_first = first == ' +' ;
1987- bool const precise_parsing = opt_.precise_parsing ;
19881990 detail::const_stream_wrapper cs (p, end_);
19891991 number num;
19901992 const char * begin = cs.begin ();
@@ -2034,7 +2036,10 @@ parse_number(const char* p,
20342036 return fail (cs.begin (), error::syntax, &loc);
20352037 }
20362038
2037- num.mant = detail::parse_unsigned ( 0 , cs.begin (), n1 );
2039+ if ( !no_parsing )
2040+ num.mant = detail::parse_unsigned ( 0 , cs.begin (), n1 );
2041+ else
2042+ num.mant = 0 ;
20382043
20392044 cs += n1;
20402045
@@ -2062,7 +2067,7 @@ parse_number(const char* p,
20622067 ++cs;
20632068 goto do_exp1;
20642069 }
2065- if (negative)
2070+ if ( negative && !no_parsing )
20662071 num.mant = ~num.mant + 1 ;
20672072 goto finish_signed;
20682073 }
@@ -2089,7 +2094,8 @@ parse_number(const char* p,
20892094 goto do_num7;
20902095 }
20912096
2092- num.mant = detail::parse_unsigned ( num.mant , cs.begin (), n2 );
2097+ if ( !no_parsing )
2098+ num.mant = detail::parse_unsigned ( num.mant , cs.begin (), n2 );
20932099
20942100 BOOST_ASSERT (num.bias == 0 );
20952101
@@ -2225,7 +2231,8 @@ parse_number(const char* p,
22252231 if ( num.mant > 922337203685477580 || (
22262232 num.mant == 922337203685477580 && c > ' 8' ))
22272233 break ;
2228- num.mant = 10 * num.mant + ( c - ' 0' );
2234+ else if ( !no_parsing )
2235+ num.mant = 10 * num.mant + ( c - ' 0' );
22292236 continue ;
22302237 }
22312238 goto do_num6; // [.eE]
@@ -2259,7 +2266,8 @@ parse_number(const char* p,
22592266 if ( num.mant > 1844674407370955161 || (
22602267 num.mant == 1844674407370955161 && c > ' 5' ))
22612268 break ;
2262- num.mant = 10 * num.mant + ( c - ' 0' );
2269+ else if ( !no_parsing )
2270+ num.mant = 10 * num.mant + ( c - ' 0' );
22632271 }
22642272 else
22652273 {
@@ -2498,7 +2506,7 @@ parse_number(const char* p,
24982506 c >= ' 0' && c <= ' 9' ))
24992507 {
25002508 ++cs;
2501- if (BOOST_JSON_LIKELY (
2509+ if (!no_parsing && BOOST_JSON_LIKELY (
25022510 num.mant <= 9007199254740991 )) // 2^53-1
25032511 {
25042512 --num.bias ;
@@ -2623,7 +2631,8 @@ parse_number(const char* p,
26232631 return fail (cs.begin (), error::exponent_overflow, &loc);
26242632 }
26252633 ++cs;
2626- num.exp = 10 * num.exp + ( c - ' 0' );
2634+ if ( !no_parsing )
2635+ num.exp = 10 * num.exp + ( c - ' 0' );
26272636 continue ;
26282637 }
26292638 }
@@ -2693,6 +2702,8 @@ parse_number(const char* p,
26932702 BOOST_ASSERT ( err.ptr == data + full_size );
26942703 (void )err;
26952704 }
2705+ else if ( no_parsing )
2706+ d = 0 ;
26962707 else
26972708 d = detail::dec_to_float (
26982709 num.mant ,
0 commit comments