summaryrefslogtreecommitdiff
path: root/ext/Compress
diff options
context:
space:
mode:
authorPaul Marquess <paul.marquess@btinternet.com>2006-12-29 20:50:26 +0000
committerSteve Peters <steve@fisharerojo.org>2006-12-30 05:55:53 +0000
commitf6fd7794b9baf00eb9b1d47e4ad481f2e8866e76 (patch)
tree2caa94f5eb3d6ee23b0a6aaf07ae936066acae5c /ext/Compress
parentf8babb2524be4b18ced06634d930c03291c1f313 (diff)
downloadperl-f6fd7794b9baf00eb9b1d47e4ad481f2e8866e76.tar.gz
Update Compress Modules to version 2.002
From: "Paul Marquess" <Paul.Marquess@ntlworld.com> Message-ID: <000501c72b8a$f96b2ba0$6401a8c0@myopwv.com> p4raw-id: //depot/perl@29641
Diffstat (limited to 'ext/Compress')
-rw-r--r--ext/Compress/Raw/Zlib/Changes4
-rw-r--r--ext/Compress/Raw/Zlib/README4
-rw-r--r--ext/Compress/Raw/Zlib/lib/Compress/Raw/Zlib.pm2
-rw-r--r--ext/Compress/Zlib/Changes9
-rw-r--r--ext/Compress/Zlib/README4
-rw-r--r--ext/Compress/Zlib/lib/Compress/Zlib.pm36
-rw-r--r--ext/Compress/Zlib/t/03zlib-v1.t83
-rw-r--r--ext/Compress/Zlib/t/14gzopen.t3
8 files changed, 119 insertions, 26 deletions
diff --git a/ext/Compress/Raw/Zlib/Changes b/ext/Compress/Raw/Zlib/Changes
index 8cc76389ca..10939b5f02 100644
--- a/ext/Compress/Raw/Zlib/Changes
+++ b/ext/Compress/Raw/Zlib/Changes
@@ -1,6 +1,10 @@
CHANGES
-------
+ 2.002 29 December 2006
+
+ * Documentation updates.
+
2.001 1 November 2006
* Remove beta status.
diff --git a/ext/Compress/Raw/Zlib/README b/ext/Compress/Raw/Zlib/README
index 294900b9b3..5d8ab3be29 100644
--- a/ext/Compress/Raw/Zlib/README
+++ b/ext/Compress/Raw/Zlib/README
@@ -1,9 +1,9 @@
Compress::Raw::Zlib
- Version 2.001
+ Version 2.002
- 1st November 2006
+ 29th December 2006
Copyright (c) 2005-2006 Paul Marquess. All rights reserved.
diff --git a/ext/Compress/Raw/Zlib/lib/Compress/Raw/Zlib.pm b/ext/Compress/Raw/Zlib/lib/Compress/Raw/Zlib.pm
index b160c6f97d..0cc4b11432 100644
--- a/ext/Compress/Raw/Zlib/lib/Compress/Raw/Zlib.pm
+++ b/ext/Compress/Raw/Zlib/lib/Compress/Raw/Zlib.pm
@@ -13,7 +13,7 @@ use warnings ;
use bytes ;
our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD);
-$VERSION = '2.001';
+$VERSION = '2.002';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
diff --git a/ext/Compress/Zlib/Changes b/ext/Compress/Zlib/Changes
index fbdd1801b5..4a2112275e 100644
--- a/ext/Compress/Zlib/Changes
+++ b/ext/Compress/Zlib/Changes
@@ -1,6 +1,15 @@
CHANGES
-------
+ 2.002 29 December 2006
+
+ * Documentation updates.
+
+ * Fix append mode with gzopen.
+ rt-cpan.org 24041
+
+ * Allow gzopen to read from and write to a scalar reference.
+
2.001 1 November 2006
* Remove beta status.
diff --git a/ext/Compress/Zlib/README b/ext/Compress/Zlib/README
index e5291ad4da..e0caaf9c09 100644
--- a/ext/Compress/Zlib/README
+++ b/ext/Compress/Zlib/README
@@ -1,9 +1,9 @@
Compress::Zlib
- Version 2.001
+ Version 2.002
- 1st November 2006
+ 29th December 2006
Copyright (c) 1995-2006 Paul Marquess. All rights reserved.
diff --git a/ext/Compress/Zlib/lib/Compress/Zlib.pm b/ext/Compress/Zlib/lib/Compress/Zlib.pm
index de212cab93..cb9508b250 100644
--- a/ext/Compress/Zlib/lib/Compress/Zlib.pm
+++ b/ext/Compress/Zlib/lib/Compress/Zlib.pm
@@ -18,7 +18,7 @@ use warnings ;
use bytes ;
our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD);
-$VERSION = '2.001';
+$VERSION = '2.002';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
@@ -120,12 +120,14 @@ sub gzopen($$)
$defOpts{Level} = $1 if $mode =~ /(\d)/;
$defOpts{Strategy} = Z_FILTERED() if $mode =~ /f/i;
$defOpts{Strategy} = Z_HUFFMAN_ONLY() if $mode =~ /h/i;
+ $defOpts{Append} = 1 if $mode =~ /a/i;
my $infDef = $writing ? 'deflate' : 'inflate';
my @params = () ;
croak "gzopen: file parameter is not a filehandle or filename"
- unless isaFilehandle $file || isaFilename $file ;
+ unless isaFilehandle $file || isaFilename $file ||
+ (ref $file && ref $file eq 'SCALAR');
return undef unless $mode =~ /[rwa]/i ;
@@ -141,6 +143,7 @@ sub gzopen($$)
Transparent => 1,
Append => 0,
AutoClose => 1,
+ MultiStream => 1,
Strict => 0)
or $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError;
}
@@ -640,16 +643,19 @@ The C<Compress::Zlib> module can be split into two general areas of
functionality, namely a simple read/write interface to I<gzip> files
and a low-level in-memory compression/decompression interface.
-Each of these areas will be discussed separately below.
+Each of these areas will be discussed in the following sections.
=head2 Notes for users of Compress::Zlib version 1
-Version 2 of this module is a total rewrite. The net result of this is that
-C<Compress::Zlib> does not now access the zlib library directly.
+The main change in C<Compress::Zlib> version 2.x is that it does not now
+interface directly to the zlib library. Instead it uses the
+C<IO::Compress::Gzip> and C<IO::Uncompress::Gunzip> modules for
+reading/writing gzip files, and the C<Compress::Raw::Zlib> module for some
+low-level zlib access.
-It now uses the C<IO::Compress::Gzip> and C<IO::Uncompress::Gunzip> modules
-for reading/writing gzip files, and the C<Compress::Raw::Zlib> module for
-low-level zlib access.
+The interface provided by version 2 should be 100% backward compatible with
+version 1. If you find a difference in the expected behaviour please
+contact the author (See L</AUTHOR>). See L<GZIP INTERFACE>
If you are writing new code, your first port of call should be to use one
these new modules.
@@ -660,7 +666,7 @@ A number of functions are supplied in I<zlib> for reading and writing
I<gzip> files that conform to RFC 1952. This module provides an interface
to most of them.
-If you are upgrading from C<Compress::Zlib> 1.x, the following
+If you have previously used C<Compress::Zlib> 1.x, the following
enhancements/changes have been made to the C<gzopen> interface:
=over 5
@@ -717,16 +723,19 @@ This function opens either the I<gzip> file C<$filename> for reading or
writing or attaches to the opened filehandle, C<$filehandle>.
It returns an object on success and C<undef> on failure.
-When writing a gzip file this interface will always create the smallest
+When writing a gzip file this interface will I<always> create the smallest
possible gzip header (exactly 10 bytes). If you want greater control over
-the information stored in the gzip header (like the original filename or a
-comment) use L<IO::Compress::Gzip|IO::Compress::Gzip> instead.
+what gets stored in the gzip header (like the original filename or a
+comment) use L<IO::Compress::Gzip|IO::Compress::Gzip> instead. Similarly if
+you want to read the contents of the gzip header use
+L<IO::Uncompress::Gunzip|IO::Uncompress::Gunzip>.
The second parameter, C<$mode>, is used to specify whether the file is
opened for reading or writing and to optionally specify a compression
level and compression strategy when writing. The format of the C<$mode>
parameter is similar to the mode parameter to the 'C' function C<fopen>,
-so "rb" is used to open for reading and "wb" for writing.
+so "rb" is used to open for reading, "wb" for writing and "ab" for
+appending (writing at the end of the file).
To specify a compression level when writing, append a digit between 0
and 9 to the mode string -- 0 means no compression and 9 means maximum
@@ -744,7 +753,6 @@ level 4 and run-length encoding.
Refer to the I<zlib> documentation for the exact format of the C<$mode>
parameter.
-
=item B<$bytesread = $gz-E<gt>gzread($buffer [, $size]) ;>
Reads C<$size> bytes from the compressed file into C<$buffer>. If
diff --git a/ext/Compress/Zlib/t/03zlib-v1.t b/ext/Compress/Zlib/t/03zlib-v1.t
index c98de63b0d..0ad5440625 100644
--- a/ext/Compress/Zlib/t/03zlib-v1.t
+++ b/ext/Compress/Zlib/t/03zlib-v1.t
@@ -23,10 +23,10 @@ BEGIN
my $count = 0 ;
if ($] < 5.005) {
- $count = 353 ;
+ $count = 383 ;
}
else {
- $count = 364 ;
+ $count = 394 ;
}
@@ -494,7 +494,7 @@ EOM
{
title "Check all bytes can be handled";
- my $lex = "\r\n" . new LexFile my $name ;
+ my $lex = new LexFile my $name ;
my $data = join '', map { chr } 0x00 .. 0xFF;
$data .= "\r\nabd\r\n";
@@ -801,10 +801,10 @@ EOM
ok $@ =~ /^gzopen: file parameter is not a filehandle or filename at/
or print "# $@\n" ;
- my $x = Symbol::gensym() ;
- eval { gzopen($x, 0) ; } ;
- ok $@ =~ /^gzopen: file parameter is not a filehandle or filename at/
- or print "# $@\n" ;
+# my $x = Symbol::gensym() ;
+# eval { gzopen($x, 0) ; } ;
+# ok $@ =~ /^gzopen: file parameter is not a filehandle or filename at/
+# or print "# $@\n" ;
}
@@ -1090,5 +1090,74 @@ EOM
}
+sub slurp
+{
+ my $name = shift ;
+
+ my $input;
+ my $fil = gzopen($name, "rb") ;
+ ok $fil , "opened $name";
+ cmp_ok $fil->gzread($input, 50000), ">", 0, "read more than zero bytes";
+ ok ! $fil->gzclose(), "closed ok";
+
+ return $input;
+}
+
+sub trickle
+{
+ my $name = shift ;
+
+ my $got;
+ my $input;
+ $fil = gzopen($name, "rb") ;
+ ok $fil, "opened ok";
+ while ($fil->gzread($input, 50000) > 0)
+ {
+ $got .= $input;
+ $input = '';
+ }
+ ok ! $fil->gzclose(), "closed ok";
+ return $got;
+ return $input;
+}
+
+{
+
+ title "Append & MultiStream Tests";
+ # rt.24041
+
+ my $lex = new LexFile my $name ;
+ my $data1 = "the is the first";
+ my $data2 = "and this is the second";
+ my $trailing = "some trailing data";
+
+ my $fil;
+
+ title "One file";
+ $fil = gzopen($name, "wb") ;
+ ok $fil, "opened first file";
+ is $fil->gzwrite($data1), length $data1, "write data1" ;
+ ok ! $fil->gzclose(), "Closed";
+
+ is slurp($name), $data1, "got expected data from slurp";
+ is trickle($name), $data1, "got expected data from trickle";
+
+ title "Two files";
+ $fil = gzopen($name, "ab") ;
+ ok $fil, "opened second file";
+ is $fil->gzwrite($data2), length $data2, "write data2" ;
+ ok ! $fil->gzclose(), "Closed";
+
+ is slurp($name), $data1 . $data2, "got expected data from slurp";
+ is trickle($name), $data1 . $data2, "got expected data from trickle";
+
+ title "Trailing Data";
+ open F, ">>$name";
+ print F $trailing;
+ close F;
+
+ is slurp($name), $data1 . $data2 . $trailing, "got expected data from slurp" ;
+ is trickle($name), $data1 . $data2 . $trailing, "got expected data from trickle" ;
+}
diff --git a/ext/Compress/Zlib/t/14gzopen.t b/ext/Compress/Zlib/t/14gzopen.t
index bade158abd..f8011e59ff 100644
--- a/ext/Compress/Zlib/t/14gzopen.t
+++ b/ext/Compress/Zlib/t/14gzopen.t
@@ -486,6 +486,9 @@ foreach my $stdio ( ['-', '-'], [*STDIN, *STDOUT])
SKIP:
{
my $lex = new LexFile my $name ;
+ skip "Cannot create non-readable file", 3
+ if $^O eq 'cygwin';
+
writeFile($name, "abc");
chmod 0222, $name ;