Subject: [Boost-bugs] [Boost C++ Libraries] #8572: iosteams indirect_streambuf::init_put_area should seek if data has been read from the get buffer
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-14 15:54:33
#8572: iosteams indirect_streambuf::init_put_area should seek if data has been
read from the get buffer
-----------------------------------------------------+----------------------
Reporter: Alan Birtles <alan.birtles@â¦> | Owner: turkanis
Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
-----------------------------------------------------+----------------------
The following code with std::fstream prints 0x1801 but with
boost::iostream prints 0x2000:
{{{
boost::iostreams::stream< boost::iostreams::file > ios(
boost::iostreams::file( "test.dat", std::ios_base::binary |
std::ios_base::in | std::ios_base::out | std::ios_base::trunc ), 0x800 );
//std::fstream ios( "test.dat", std::ios_base::binary |
std::ios_base::in | std::ios_base::out | std::ios_base::trunc );
char buffer[ 0x2000 ];
ios.write( buffer, 0x2000 );
ios.seekg( -0x1000, std::ios_base::cur );
ios.get();
ios.write( buffer, 0x800 );
std::cout << std::hex << ios.tellp() << std::endl;
std::cout << std::hex << ios.tellg() << std::endl;
}}}
I believe the problem lies in indirect_streambuf::init_put_area. The
current implementation is:
{{{
if (shared_buffer() && gptr() != 0)
setg(0, 0, 0);
if (output_buffered())
setp(out().begin(), out().end());
else
setp(0, 0);
}}}
I think it should be:
{{{
if (shared_buffer() && gptr() != 0)
{
obj().seek(gptr()-egptr(), BOOST_IOS::cur, BOOST_IOS::in, next_);
setg(0, 0, 0);
}
if (output_buffered())
setp(out().begin(), out().end());
else
setp(0, 0);
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8572> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC