Skip to content

Commit

Permalink
refactor parse(istream&, ec&)
Browse files Browse the repository at this point in the history
  • Loading branch information
grisumbras committed Nov 5, 2022
1 parent 3404427 commit ea45843
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/boost/json/impl/parse.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,29 @@ parse(
p.reset(std::move(sp));

char read_buffer[BOOST_JSON_STACK_BUFFER_SIZE / 2];
while( true )
do
{
if( is.rdstate() & std::ios::eofbit )
if( is.eof() )
{
p.finish(ec);
if( ec.failed() )
return nullptr;
break;
}

if( is.rdstate() != std::ios::goodbit )
if( !is )
{
BOOST_JSON_FAIL( ec, error::input_error );
return nullptr;
break;
}

is.read(read_buffer, sizeof(read_buffer));
auto const consumed = is.gcount();

p.write(read_buffer, consumed, ec);
if( ec.failed() )
return nullptr;
}
while( !ec.failed() );

if( ec.failed() )
return nullptr;

return p.release();
}
Expand Down

0 comments on commit ea45843

Please sign in to comment.