diff options
author | Paul Marquess <paul.marquess@btinternet.com> | 2007-07-01 01:50:01 +0100 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2007-07-02 16:52:30 +0000 |
commit | 93d092e27236bf0069d60659d00503bf5d187b7b (patch) | |
tree | ed63fb0858d068a7037784690c4857144ac650e1 /ext/Compress | |
parent | 277189c8ad3fc0d1dcd4c757f62b0a7bf5bacaa0 (diff) | |
download | perl-93d092e27236bf0069d60659d00503bf5d187b7b.tar.gz |
compression modules update to version 2.005
From: "Paul Marquess" <Paul.Marquess@ntlworld.com>
Message-ID: <000c01c7bb71$6189ae20$6601a8c0@myopwv.com>
p4raw-id: //depot/perl@31520
Diffstat (limited to 'ext/Compress')
-rw-r--r-- | ext/Compress/Raw/Zlib/Changes | 5 | ||||
-rw-r--r-- | ext/Compress/Raw/Zlib/Makefile.PL | 1 | ||||
-rw-r--r-- | ext/Compress/Raw/Zlib/README | 4 | ||||
-rw-r--r-- | ext/Compress/Raw/Zlib/lib/Compress/Raw/Zlib.pm | 2 | ||||
-rw-r--r-- | ext/Compress/Zlib/Changes | 5 | ||||
-rwxr-xr-x | ext/Compress/Zlib/Makefile.PL | 24 | ||||
-rw-r--r-- | ext/Compress/Zlib/README | 4 | ||||
-rw-r--r-- | ext/Compress/Zlib/lib/Compress/Zlib.pm | 28 | ||||
-rw-r--r-- | ext/Compress/Zlib/t/08encoding.t | 65 |
9 files changed, 102 insertions, 36 deletions
diff --git a/ext/Compress/Raw/Zlib/Changes b/ext/Compress/Raw/Zlib/Changes index ef8ddab889..ffd51a30b2 100644 --- a/ext/Compress/Raw/Zlib/Changes +++ b/ext/Compress/Raw/Zlib/Changes @@ -1,6 +1,11 @@ CHANGES ------- + 2.005 18 June 2007 + + * Only include ppport.h when not being built with perl. + [core patch #30655] + 2.004 3 March 2007 * Fixed lvalue substr issue diff --git a/ext/Compress/Raw/Zlib/Makefile.PL b/ext/Compress/Raw/Zlib/Makefile.PL index e151ac9afc..3eb400624c 100644 --- a/ext/Compress/Raw/Zlib/Makefile.PL +++ b/ext/Compress/Raw/Zlib/Makefile.PL @@ -82,7 +82,6 @@ WriteMakefile( : () ), - ( $BUILD_ZLIB ? zlib_files($ZLIB_LIB) diff --git a/ext/Compress/Raw/Zlib/README b/ext/Compress/Raw/Zlib/README index 35bd1c2f4e..523f3b312e 100644 --- a/ext/Compress/Raw/Zlib/README +++ b/ext/Compress/Raw/Zlib/README @@ -1,9 +1,9 @@ Compress::Raw::Zlib - Version 2.004 + Version 2.005 - 3rd March 2007 + 18th June 2007 Copyright (c) 2005-2007 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 02ff3d1668..5a0098b5c6 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.004_01'; +$VERSION = '2.005'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/ext/Compress/Zlib/Changes b/ext/Compress/Zlib/Changes index 8c02d4b653..eff627b37d 100644 --- a/ext/Compress/Zlib/Changes +++ b/ext/Compress/Zlib/Changes @@ -1,6 +1,11 @@ CHANGES ------- + 2.005 18 June 2007 + + * Added info about removing Compress::Zlib version 1, before + installing version 2. + 2.004 3 March 2007 * rewrote memGzip using IO::Compress::Gzip::gzip diff --git a/ext/Compress/Zlib/Makefile.PL b/ext/Compress/Zlib/Makefile.PL index a7e3a6ad7c..f09008e663 100755 --- a/ext/Compress/Zlib/Makefile.PL +++ b/ext/Compress/Zlib/Makefile.PL @@ -3,11 +3,12 @@ use strict ; require 5.004 ; -$::VERSION = '2.004' ; +$::VERSION = '2.005' ; use private::MakeUtil; use ExtUtils::MakeMaker 5.16 ; + UpDowngrade(getPerlFiles('MANIFEST')) unless $ENV{PERL_CORE}; @@ -47,5 +48,26 @@ WriteMakefile( ) ; +# Check for Compress::Zlib version 1. +eval "require Compress::Zlib; " ; +if ( ! $ENV{PERL_CORE} && ! $@ && $Compress::Zlib::VERSION < 2) +{ + my $ver = $Compress::Zlib::VERSION ; + print <<EOM + +I see you already have Compress::Zlib version $ver installed. +Version 1 MUST be removed for version 2 to operate correctly. + +The easiest way to do that is to install Compress::Zlib like this + + make install UNINST=1 + +If you run the CPAN shell run this before installing Compress::Zlib + + o conf make_install_arg UNINST=1 + +EOM +} + # end of file Makefile.PL diff --git a/ext/Compress/Zlib/README b/ext/Compress/Zlib/README index 7d2f0de374..8a36799cee 100644 --- a/ext/Compress/Zlib/README +++ b/ext/Compress/Zlib/README @@ -1,9 +1,9 @@ Compress::Zlib - Version 2.004 + Version 2.005 - 3rd March 2007 + 18th June 2007 Copyright (c) 1995-2007 Paul Marquess. All rights reserved. diff --git a/ext/Compress/Zlib/lib/Compress/Zlib.pm b/ext/Compress/Zlib/lib/Compress/Zlib.pm index fe1892653b..e10763232e 100644 --- a/ext/Compress/Zlib/lib/Compress/Zlib.pm +++ b/ext/Compress/Zlib/lib/Compress/Zlib.pm @@ -8,17 +8,17 @@ use Carp ; use IO::Handle ; use Scalar::Util qw(dualvar); -use IO::Compress::Base::Common 2.004 ; -use Compress::Raw::Zlib 2.004 ; -use IO::Compress::Gzip 2.004 ; -use IO::Uncompress::Gunzip 2.004 ; +use IO::Compress::Base::Common 2.005 ; +use Compress::Raw::Zlib 2.005 ; +use IO::Compress::Gzip 2.005 ; +use IO::Uncompress::Gunzip 2.005 ; use strict ; use warnings ; use bytes ; our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD); -$VERSION = '2.004'; +$VERSION = '2.005'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -193,6 +193,9 @@ sub Compress::Zlib::gzFile::gzwrite return _set_gzerr(Z_STREAM_ERROR()) if $self->[1] ne 'deflate'; + $] >= 5.008 and (utf8::downgrade($_[0], 1) + or croak "Wide character in gzwrite"); + my $status = $gz->write($_[0]) ; _save_gzerr($gz); return $status ; @@ -301,6 +304,9 @@ sub compress($;$) $in = \$_[0] ; } + $] >= 5.008 and (utf8::downgrade($$in, 1) + or croak "Wide character in compress"); + my $level = (@_ == 2 ? $_[1] : Z_DEFAULT_COMPRESSION() ); $x = new Compress::Raw::Zlib::Deflate -AppendOutput => 1, -Level => $level @@ -328,6 +334,9 @@ sub uncompress($) $in = \$_[0] ; } + $] >= 5.008 and (utf8::downgrade($$in, 1) + or croak "Wide character in uncompress"); + $x = new Compress::Raw::Zlib::Inflate -ConsumeInput => 0 or return undef ; $err = $x->inflate($in, $output) ; @@ -438,7 +447,7 @@ sub inflate package Compress::Zlib ; -use IO::Compress::Gzip::Constants 2.004 ; +use IO::Compress::Gzip::Constants 2.005 ; sub memGzip($) { @@ -447,6 +456,9 @@ sub memGzip($) # if the deflation buffer isn't a reference, make it one my $string = (ref $_[0] ? $_[0] : \$_[0]) ; + $] >= 5.008 and (utf8::downgrade($$string, 1) + or croak "Wide character in memGzip"); + IO::Compress::Gzip::gzip($string, \$out, Minimal => 1) or return undef ; @@ -518,6 +530,9 @@ sub memGunzip($) # if the buffer isn't a reference, make it one my $string = (ref $_[0] ? $_[0] : \$_[0]); + $] >= 5.008 and (utf8::downgrade($$string, 1) + or croak "Wide character in memGunzip"); + _removeGzipHeader($string) == Z_OK() or return undef; @@ -1443,3 +1458,4 @@ modify it under the same terms as Perl itself. + diff --git a/ext/Compress/Zlib/t/08encoding.t b/ext/Compress/Zlib/t/08encoding.t index 3ebbfbbca6..f377609e57 100644 --- a/ext/Compress/Zlib/t/08encoding.t +++ b/ext/Compress/Zlib/t/08encoding.t @@ -28,7 +28,7 @@ BEGIN $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 16 + $extra ; + plan tests => 29 + $extra ; use_ok('Compress::Zlib', 2); } @@ -41,30 +41,32 @@ is Compress::Zlib::zlib_version, ZLIB_VERSION, "ZLIB_VERSION matches Compress::Zlib::zlib_version" ; -if(0) { + title "memGzip" ; # length of this string is 2 characters my $s = "\x{df}\x{100}"; - my $cs = Compress::Zlib::memGzip($s); + my $cs = Compress::Zlib::memGzip(Encode::encode_utf8($s)); # length stored at end of gzip file should be 4 my ($crc, $len) = unpack ("VV", substr($cs, -8, 8)); - is $len, 4, "length is 4"; + is $len, 4, " length is 4"; } { - title "memGzip" ; - # length of this string is 2 characters - my $s = "\x{df}\x{100}"; + title "memGunzip when compressed gzip has been encoded" ; + my $s = "hello world" ; - my $cs = Compress::Zlib::memGzip(Encode::encode_utf8($s)); + my $co = Compress::Zlib::memGzip($s); + is Compress::Zlib::memGunzip(my $x = $co), $s, " match uncompressed"; - # length stored at end of gzip file should be 4 - my ($crc, $len) = unpack ("VV", substr($cs, -8, 8)); - - is $len, 4, " length is 4"; + utf8::upgrade($co); + + my $un = Compress::Zlib::memGunzip($co); + ok $un, " got uncompressed"; + + is $un, $s, " uncompressed matched original"; } { @@ -73,23 +75,17 @@ if(0) my $s = "\x{df}\x{100}"; my $s_copy = $s ; - #my $cs = compress($s); my $ces = compress(Encode::encode_utf8($s_copy)); ok $ces, " compressed ok" ; - #is $s, $ces ; - - #my $un = uncompress($cs); - #is $un, $s; - my $un = Encode::decode_utf8(uncompress($ces)); - #my $un = uncompress($ces); is $un, $s, " decode_utf8 ok"; - #$un = Encode::decode_utf8(uncompress($cs)); - #is $un, $s; - + utf8::upgrade($ces); + $un = Encode::decode_utf8(uncompress($ces)); + is $un, $s, " decode_utf8 ok"; + } { @@ -116,5 +112,28 @@ if(0) is $s, Encode::decode_utf8($uncomp), " decode_utf8 ok" ; } -# Add tests that check that the module traps use of wide chars +{ + title "Catch wide characters"; + + my $a = "a\xFF\x{100}"; + eval { Compress::Zlib::memGzip($a) }; + like($@, qr/Wide character in memGzip/, " wide characters in memGzip"); + + eval { Compress::Zlib::memGunzip($a) }; + like($@, qr/Wide character in memGunzip/, " wide characters in memGunzip"); + + eval { Compress::Zlib::compress($a) }; + like($@, qr/Wide character in compress/, " wide characters in compress"); + + eval { Compress::Zlib::uncompress($a) }; + like($@, qr/Wide character in uncompress/, " wide characters in uncompress"); + + my $lex = new LexFile my $name ; + ok my $fil = gzopen($name, "wb"), " gzopen for write ok" ; + + eval { $fil->gzwrite($a); } ; + like($@, qr/Wide character in gzwrite/, " wide characters in gzwrite"); + + ok ! $fil->gzclose, " gzclose ok" ; +} |