Upgrade to Compress::Zlib 2.007
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 24 Sep 2007 13:19:10 +0000 (13:19 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 24 Sep 2007 13:19:10 +0000 (13:19 +0000)
p4raw-id: //depot/perl@31953

ext/Compress/Zlib/Changes
ext/Compress/Zlib/README
ext/Compress/Zlib/lib/Compress/Zlib.pm
ext/Compress/Zlib/t/03zlib-v1.t
ext/Compress/Zlib/t/14gzopen.t

index bcc74fb..3ee2c93 100644 (file)
@@ -1,6 +1,13 @@
 CHANGES
 -------
 
+  2.007 22 September 20007
+
+      * lib/Compress/Zlib.pm -- 1.x Backward Compatability issues
+        gzclose - documented return value was wrong, should be 0 for ok.
+        gzflush - return value didn't match 1.x, should return 0 if ok.
+        [rt.cpan.org #29215] and Debian bug #440943 http://bugs.debian.org/440943
+
   2.006 1 September 20007
 
       * Makefile.PL
index 24a8317..13f3996 100644 (file)
@@ -1,9 +1,9 @@
 
                              Compress::Zlib
 
-                             Version 2.006
+                             Version 2.007
 
-                            1st September 2007
+                            22nd September 2007
 
 
        Copyright (c) 1995-2007 Paul Marquess. All rights reserved.
index b4b04cd..ec29575 100644 (file)
@@ -18,7 +18,7 @@ use warnings ;
 use bytes ;
 our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD);
 
-$VERSION = '2.006';
+$VERSION = '2.007';
 $XS_VERSION = $VERSION; 
 $VERSION = eval $VERSION;
 
@@ -242,8 +242,8 @@ sub Compress::Zlib::gzFile::gzflush
 
     my $gz = $self->[0] ;
     my $status = $gz->flush($f) ;
-    _save_gzerr($gz);
-    return $status ;
+    my $err = _save_gzerr($gz);
+    return $status ? 0 : $err;
 }
 
 sub Compress::Zlib::gzFile::gzclose
@@ -252,8 +252,8 @@ sub Compress::Zlib::gzFile::gzclose
     my $gz = $self->[0] ;
 
     my $status = $gz->close() ;
-    _save_gzerr($gz);
-    return ! $status ;
+    my $err = _save_gzerr($gz);
+    return $status ? 0 : $err;
 }
 
 sub Compress::Zlib::gzFile::gzeof
@@ -806,7 +806,7 @@ you fully understand the implications of what it does - overuse of C<flush>
 can seriously degrade the level of compression achieved. See the C<zlib>
 documentation for details.
 
-Returns 1 on success, 0 on failure.
+Returns 0 on success.
 
 
 =item B<$offset = $gz-E<gt>gztell() ;>
@@ -831,7 +831,7 @@ Returns 1 on success, 0 on failure.
 Closes the compressed file. Any pending data is flushed to the file
 before it is closed.
 
-Returns 1 on success, 0 on failure.
+Returns 0 on success.
 
 =item B<$gz-E<gt>gzsetparams($level, $strategy>
 
index 99a80f9..7358f4a 100644 (file)
@@ -23,10 +23,10 @@ BEGIN
 
     my $count = 0 ;
     if ($] < 5.005) {
-        $count = 383 ;
+        $count = 390 ;
     }
     else {
-        $count = 394 ;
+        $count = 401 ;
     }
 
 
@@ -1168,3 +1168,21 @@ sub trickle
     is slurp($name), $data1 . $data2 . $trailing, "got expected data from slurp" ;
     is trickle($name), $data1 . $data2 . $trailing, "got expected data from trickle" ;
 }
+
+{
+    title "gzclose & gzflush return codes";
+    # rt.29215
+
+    my $lex = new LexFile my $name ;
+    my $data1 = "the is some text";
+    my $status;
+
+    $fil = gzopen($name, "wb") ;
+    ok $fil, "opened first file"; 
+    is $fil->gzwrite($data1), length $data1, "write data1" ;
+    $status = $fil->gzflush(0xfff);
+    ok   $status, "flush not ok" ;
+    is $status, Z_STREAM_ERROR;
+    ok ! $fil->gzflush(), "flush ok" ;
+    ok ! $fil->gzclose(), "Closed";
+}
index 805bb0d..85970d2 100644 (file)
@@ -95,7 +95,7 @@ is $gzerrno, 0;
 
 is $fil->gzwrite($number), $num_len, "gzwrite returned $num_len" ;
 is $gzerrno, 0, 'gzerrno is 0';
-ok $fil->gzflush(Z_FINISH) ;
+ok $fil->gzflush(Z_FINISH) ;
 
 is $gzerrno, 0, 'gzerrno is 0';