Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5291: bzip2_decompressor does not work properly with a filtering_streambuf
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-17 19:18:23
#5291: bzip2_decompressor does not work properly with a filtering_streambuf
---------------------------------------------------------+------------------
Reporter: Chris Steenwyk <chris.steenwyk@â¦> | Owner: turkanis
Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
Version: Boost 1.45.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------------------+------------------
Comment (by chris.steenwyk@â¦):
Sorry it took so long.
The code below works on boost 1.42 and generates an exception on 1.45. I
have also attached a patch to add this test into the test file
bzip2_test.cpp.
{{{
#include <string>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/test.hpp>
#include <boost/iostreams/filtering_stream.hpp>
std::vector<char> temp;
std::string source( "This is test data" );
std::vector<char> sourceVector( source.begin(), source.end() );
std::vector<char> dest;
// Write compressed source to temp
boost::iostreams::filtering_streambuf< boost::iostreams::output > out;
out.push( boost::iostreams::bzip2_compressor() );
out.push( boost::iostreams::back_inserter( temp ) );
boost::iostreams::copy( boost::make_iterator_range( source ), out );
// Add uncompressed source around the compressed source
temp.insert( temp.begin(), source.begin(), source.end() );
temp.insert( temp.end(), source.begin(), source.end() );
// Read compressed data from temp into dest
boost::iostreams::array_source inStr( &temp[ source.length() ],
temp.size() );
boost::iostreams::filtering_streambuf< boost::iostreams::input > in;
in.push( boost::iostreams::bzip2_decompressor() );
in.push( inStr );
boost::iostreams::copy( in, boost::iostreams::back_inserter( dest ) );
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5291#comment:2> 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:07 UTC