]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/iostreams/filter/bzip2.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / iostreams / filter / bzip2.hpp
index b9c04a7ce12f10dc64718ecd1061633b74fe00ae..a468e05804620825dabd5c9581c9f66bf0cb6d5c 100644 (file)
@@ -175,6 +175,7 @@ protected:
     int check_end(const char* src_begin, const char* dest_begin);
     int compress(int action);
     int decompress();
+    int end(bool compress, std::nothrow_t);
     void end(bool compress);
 private:
     void do_init( bool compress, 
@@ -201,6 +202,7 @@ class bzip2_compressor_impl
 {
 public: 
     bzip2_compressor_impl(const bzip2_params&);
+    ~bzip2_compressor_impl();
     bool filter( const char*& src_begin, const char* src_end,
                  char*& dest_begin, char* dest_end, bool flush );
     void close();
@@ -224,6 +226,7 @@ class bzip2_decompressor_impl
 { 
 public:
     bzip2_decompressor_impl(bool small = bzip2::default_small);
+    ~bzip2_decompressor_impl();
     bool filter( const char*& begin_in, const char* end_in,
                  char*& begin_out, char* end_out, bool flush );
     void close();
@@ -313,6 +316,10 @@ template<typename Alloc>
 bzip2_compressor_impl<Alloc>::bzip2_compressor_impl(const bzip2_params& p)
     : bzip2_base(p), eof_(false) { }
 
+template<typename Alloc>
+bzip2_compressor_impl<Alloc>::~bzip2_compressor_impl()
+{ (void) bzip2_base::end(true, std::nothrow); }
+
 template<typename Alloc>
 bool bzip2_compressor_impl<Alloc>::filter
     ( const char*& src_begin, const char* src_end,
@@ -349,27 +356,33 @@ template<typename Alloc>
 bzip2_decompressor_impl<Alloc>::bzip2_decompressor_impl(bool small)
     : bzip2_base(bzip2_params(small)), eof_(false) { }
 
+template<typename Alloc>
+bzip2_decompressor_impl<Alloc>::~bzip2_decompressor_impl()
+{ (void) bzip2_base::end(false, std::nothrow); }
+
 template<typename Alloc>
 bool bzip2_decompressor_impl<Alloc>::filter
     ( const char*& src_begin, const char* src_end,
       char*& dest_begin, char* dest_end, bool flush )
 {
-    if (eof_) {
-        // reset the stream if there are more characters
-        if(src_begin == src_end)
-            return false;
-        else
-            close();
-    }
-    if (!ready()) 
-        init();
-    before(src_begin, src_end, dest_begin, dest_end);
-    int result = decompress();
-    if(result == bzip2::ok && flush)
-        result = check_end(src_begin, dest_begin);
-    after(src_begin, dest_begin);
-    bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
-    eof_ = result == bzip2::stream_end;
+    do {
+        if (eof_) {
+            // reset the stream if there are more characters
+            if(src_begin == src_end)
+                return false;
+            else
+                close();
+        }
+        if (!ready()) 
+            init();
+        before(src_begin, src_end, dest_begin, dest_end);
+        int result = decompress();
+        if(result == bzip2::ok && flush)
+            result = check_end(src_begin, dest_begin);
+        after(src_begin, dest_begin);
+        bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
+        eof_ = result == bzip2::stream_end;
+    } while (eof_ && src_begin != src_end && dest_begin != dest_end);
     return true; 
 }