From: Paul Marquess Date: Sun, 1 Jul 2007 00:50:01 +0000 (+0100) Subject: compression modules update to version 2.005 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=93d092e27236bf0069d60659d00503bf5d187b7b;p=p5sagit%2Fp5-mst-13.2.git compression modules update to version 2.005 From: "Paul Marquess" Message-ID: <000c01c7bb71$6189ae20$6601a8c0@myopwv.com> p4raw-id: //depot/perl@31520 --- diff --git a/MANIFEST b/MANIFEST index 330ab54..a9bdfa4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -795,6 +795,10 @@ ext/IO_Compress_Zlib/t/109merge-deflate.t IO::Compress::Zlib ext/IO_Compress_Zlib/t/109merge-gzip.t IO::Compress::Zlib ext/IO_Compress_Zlib/t/109merge-rawdeflate.t IO::Compress::Zlib ext/IO_Compress_Zlib/t/109merge-zip.t IO::Compress::Zlib +ext/IO_Compress_Zlib/t/110encode-deflate.t IO::Compress::Zlib +ext/IO_Compress_Zlib/t/110encode-gzip.t IO::Compress::Zlib +ext/IO_Compress_Zlib/t/110encode-rawdeflate.t IO::Compress::Zlib +ext/IO_Compress_Zlib/t/110encode-zip.t IO::Compress::Zlib ext/IO/hints/sco.pl Hint for IO for named architecture ext/IO/IO.pm Top-level interface to IO::* classes ext/IO/IO.xs IO extension external subroutines @@ -3425,6 +3429,7 @@ t/lib/compress/any.pl Compress::Zlib t/lib/compress/anyunc.pl Compress::Zlib t/lib/compress/CompTestUtils.pm Compress::Zlib t/lib/compress/destroy.pl Compress::Zlib +t/lib/compress/encode.pl Compress::Zlib t/lib/compress/generic.pl Compress::Zlib t/lib/compress/merge.pl Compress::Zlib t/lib/compress/multi.pl Compress::Zlib diff --git a/ext/Compress/Raw/Zlib/Changes b/ext/Compress/Raw/Zlib/Changes index ef8ddab..ffd51a3 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 e151ac9..3eb4006 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 35bd1c2..523f3b3 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 02ff3d1..5a0098b 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 8c02d4b..eff627b 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 a7e3a6a..f09008e 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 <[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 3ebbfbb..f377609 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" ; +} diff --git a/ext/IO_Compress_Base/Changes b/ext/IO_Compress_Base/Changes index 24e88f0..4d0068b 100644 --- a/ext/IO_Compress_Base/Changes +++ b/ext/IO_Compress_Base/Changes @@ -1,6 +1,20 @@ CHANGES ------- + 2.005 18 June 2007 + + * Stephen Turner reported a problem when using IO::Uncompress::Gunzip + with XML::Parser. Turns out there were two issues. + + Firstly an IO::Uncompress object isn't an IO::Handle. It is now. + + Secondly the implementation of "read" wasn't honouring this + + SCALAR will be grown or shrunk to the length actually read. + + In particular it didn't do the right thing on EOF. + This has been fixed. + 2.004 3 March 2007 * Made seek less wasteful of memory. diff --git a/ext/IO_Compress_Base/README b/ext/IO_Compress_Base/README index 1e557c9..c499ea2 100644 --- a/ext/IO_Compress_Base/README +++ b/ext/IO_Compress_Base/README @@ -1,9 +1,9 @@ IO::Compress::Base - 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/IO_Compress_Base/lib/IO/Compress/Base.pm b/ext/IO_Compress_Base/lib/IO/Compress/Base.pm index 8617b56..901d351 100644 --- a/ext/IO_Compress_Base/lib/IO/Compress/Base.pm +++ b/ext/IO_Compress_Base/lib/IO/Compress/Base.pm @@ -6,7 +6,7 @@ require 5.004 ; use strict ; use warnings; -use IO::Compress::Base::Common 2.004 ; +use IO::Compress::Base::Common 2.005 ; use IO::File ; use Scalar::Util qw(blessed readonly); @@ -18,9 +18,9 @@ use Symbol; use bytes; our (@ISA, $VERSION); -#@ISA = qw(Exporter IO::File); +@ISA = qw(Exporter IO::File); -$VERSION = '2.004'; +$VERSION = '2.005'; #Can't locate object method "SWASHNEW" via package "utf8" (perhaps you forgot to load "utf8"?) at .../ext/Compress-Zlib/Gzip/blib/lib/Compress/Zlib/Common.pm line 16. @@ -574,6 +574,9 @@ sub syswrite $buffer = \$_[0] ; } + $] >= 5.008 and ( utf8::downgrade($$buffer, 1) + or croak "Wide character in " . *$self->{ClassName} . "::write:"); + if (@_ > 1) { my $slen = defined $$buffer ? length($$buffer) : 0; @@ -985,3 +988,4 @@ This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + diff --git a/ext/IO_Compress_Base/lib/IO/Compress/Base/Common.pm b/ext/IO_Compress_Base/lib/IO/Compress/Base/Common.pm index 9c0b6fd..faef2ab 100644 --- a/ext/IO_Compress_Base/lib/IO/Compress/Base/Common.pm +++ b/ext/IO_Compress_Base/lib/IO/Compress/Base/Common.pm @@ -11,7 +11,7 @@ use File::GlobMapper; require Exporter; our ($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $HAS_ENCODE); @ISA = qw(Exporter); -$VERSION = '2.004'; +$VERSION = '2.005'; @EXPORT = qw( isaFilehandle isaFilename whatIsInput whatIsOutput isaFileGlobString cleanFileGlobString oneTarget diff --git a/ext/IO_Compress_Base/lib/IO/Uncompress/AnyUncompress.pm b/ext/IO_Compress_Base/lib/IO/Uncompress/AnyUncompress.pm index 923aa83..f129224 100644 --- a/ext/IO_Compress_Base/lib/IO/Uncompress/AnyUncompress.pm +++ b/ext/IO_Compress_Base/lib/IO/Uncompress/AnyUncompress.pm @@ -4,16 +4,16 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.005 qw(createSelfTiedObject); -use IO::Uncompress::Base 2.004 ; +use IO::Uncompress::Base 2.005 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError); -$VERSION = '2.004'; +$VERSION = '2.005'; $AnyUncompressError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -27,18 +27,18 @@ Exporter::export_ok_tags('all'); BEGIN { - eval ' use IO::Uncompress::Adapter::Inflate 2.004 ;'; - eval ' use IO::Uncompress::Adapter::Bunzip2 2.004 ;'; - eval ' use IO::Uncompress::Adapter::LZO 2.004 ;'; - eval ' use IO::Uncompress::Adapter::Lzf 2.004 ;'; - - eval ' use IO::Uncompress::Bunzip2 2.004 ;'; - eval ' use IO::Uncompress::UnLzop 2.004 ;'; - eval ' use IO::Uncompress::Gunzip 2.004 ;'; - eval ' use IO::Uncompress::Inflate 2.004 ;'; - eval ' use IO::Uncompress::RawInflate 2.004 ;'; - eval ' use IO::Uncompress::Unzip 2.004 ;'; - eval ' use IO::Uncompress::UnLzf 2.004 ;'; + eval ' use IO::Uncompress::Adapter::Inflate 2.005 ;'; + eval ' use IO::Uncompress::Adapter::Bunzip2 2.005 ;'; + eval ' use IO::Uncompress::Adapter::LZO 2.005 ;'; + eval ' use IO::Uncompress::Adapter::Lzf 2.005 ;'; + + eval ' use IO::Uncompress::Bunzip2 2.005 ;'; + eval ' use IO::Uncompress::UnLzop 2.005 ;'; + eval ' use IO::Uncompress::Gunzip 2.005 ;'; + eval ' use IO::Uncompress::Inflate 2.005 ;'; + eval ' use IO::Uncompress::RawInflate 2.005 ;'; + eval ' use IO::Uncompress::Unzip 2.005 ;'; + eval ' use IO::Uncompress::UnLzf 2.005 ;'; } sub new @@ -56,7 +56,7 @@ sub anyuncompress sub getExtraParams { - use IO::Compress::Base::Common 2.004 qw(:Parse); + use IO::Compress::Base::Common 2.005 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm b/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm index 1563dba..71321e0 100644 --- a/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm +++ b/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm @@ -6,16 +6,15 @@ use warnings; use bytes; our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS); -#@ISA = qw(Exporter IO::File); -@ISA = qw(Exporter ); +@ISA = qw(Exporter IO::File); -$VERSION = '2.004'; +$VERSION = '2.005'; use constant G_EOF => 0 ; use constant G_ERR => -1 ; -use IO::Compress::Base::Common 2.004 ; +use IO::Compress::Base::Common 2.005 ; #use Parse::Parameters ; use IO::File ; @@ -974,14 +973,9 @@ sub read my $self = shift ; return G_EOF if *$self->{Closed} ; - return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ; my $buffer ; - #$self->croakError(*$self->{ClassName} . - # "::read: buffer parameter is read-only") - # if Compress::Raw::Zlib::_readonly_ref($_[0]); - if (ref $_[0] ) { $self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only") if readonly(${ $_[0] }); @@ -1000,6 +994,22 @@ sub read my $length = $_[1] ; my $offset = $_[2] || 0; + if (! *$self->{AppendOutput}) { + if (! $offset) { + $$buffer = '' ; + } + else { + if ($offset > length($$buffer)) { + $$buffer .= "\x00" x ($offset - length($$buffer)); + } + else { + substr($$buffer, $offset) = ''; + } + } + } + + return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ; + # the core read will return 0 if asked for 0 bytes return 0 if defined $length && $length == 0 ; @@ -1008,8 +1018,6 @@ sub read $self->croakError(*$self->{ClassName} . "::read: length parameter is negative") if $length < 0 ; - $$buffer = '' unless *$self->{AppendOutput} || $offset ; - # Short-circuit if this is a simple read, with no length # or offset specified. unless ( $length || $offset) { @@ -1031,6 +1039,7 @@ sub read # or both are specified. my $out_buffer = *$self->{Pending} ; + while (! *$self->{EndStream} && length($out_buffer) < $length) { my $buf_len = $self->_raw_read(\$out_buffer); @@ -1044,21 +1053,18 @@ sub read return 0 if $length == 0 ; + $$buffer = '' + if ! defined $$buffer; + + $offset = length $$buffer + if *$self->{AppendOutput} ; + *$self->{Pending} = $out_buffer; $out_buffer = \*$self->{Pending} ; - if ($offset) { - $$buffer .= "\x00" x ($offset - length($$buffer)) - if $offset > length($$buffer) ; - #substr($$buffer, $offset) = substr($$out_buffer, 0, $length, '') ; - substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ; - substr($$out_buffer, 0, $length) = '' ; - } - else { - #$$buffer .= substr($$out_buffer, 0, $length, '') ; - $$buffer .= substr($$out_buffer, 0, $length) ; - substr($$out_buffer, 0, $length) = '' ; - } + #substr($$buffer, $offset) = substr($$out_buffer, 0, $length, '') ; + substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ; + substr($$out_buffer, 0, $length) = '' ; return $length ; } diff --git a/ext/IO_Compress_Zlib/Changes b/ext/IO_Compress_Zlib/Changes index e5c95f8..bf3d78e 100644 --- a/ext/IO_Compress_Zlib/Changes +++ b/ext/IO_Compress_Zlib/Changes @@ -1,6 +1,19 @@ CHANGES ------- + 2.005 18 June 2007 + + * IO::Compress::Gzip & IO::Uncompress::Gunzip + + - RFC1952 says that the FNAME & FCOMMENT header fields must be ISO + 8859-1 (LATIN-1) characters. The code can optionally police this. + Added a fix for this logic when running on EBCDIC. + + * Makefile.PL + + - Check if IO::Compress::Bzip2 is already installed. If it is, add + to the PREREQ_PM list. + 2.004 3 March 2007 * IO::Compress::Zip diff --git a/ext/IO_Compress_Zlib/Makefile.PL b/ext/IO_Compress_Zlib/Makefile.PL index 4d38fc7..9bffb07 100644 --- a/ext/IO_Compress_Zlib/Makefile.PL +++ b/ext/IO_Compress_Zlib/Makefile.PL @@ -3,7 +3,7 @@ use strict ; require 5.004 ; -$::VERSION = '2.004' ; +$::VERSION = '2.005' ; use private::MakeUtil; use ExtUtils::MakeMaker 5.16 ; @@ -11,6 +11,18 @@ use ExtUtils::MakeMaker 5.16 ; UpDowngrade(getPerlFiles('MANIFEST')) unless $ENV{PERL_CORE}; +my @MainPREREQ = qw(Compress::Raw::Zlib + IO::Compress::Base + IO::Uncompress::Base + ); + +# Bzip2 is an option prereq. +push @MainPREREQ, qw(IO::Compress::Bzip2 IO::Uncompress::Bunzip2) + if eval { require IO::Compress::Bzip2; }; + +my %MainPREREQ = map { $_ => $::VERSION } @MainPREREQ; + + WriteMakefile( NAME => 'IO::Compress::Zlib', VERSION_FROM => 'lib/IO/Compress/Gzip.pm', @@ -23,9 +35,7 @@ WriteMakefile( ( $ENV{SKIP_FOR_CORE} ? (MAN3PODS => {}) - : (PREREQ_PM => { 'Compress::Raw::Zlib' => $::VERSION, - 'IO::Compress::Base' => $::VERSION, - 'IO::Uncompress::Base' => $::VERSION, + : (PREREQ_PM => { %MainPREREQ, $] >= 5.005 && $] < 5.006 ? ('File::BSDGlob' => 0) : () } diff --git a/ext/IO_Compress_Zlib/README b/ext/IO_Compress_Zlib/README index d0e48d4..2622fa0 100644 --- a/ext/IO_Compress_Zlib/README +++ b/ext/IO_Compress_Zlib/README @@ -1,9 +1,9 @@ IO::Compress::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/IO_Compress_Zlib/examples/unzip b/ext/IO_Compress_Zlib/examples/unzip index 417a9d2..0623253 100644 --- a/ext/IO_Compress_Zlib/examples/unzip +++ b/ext/IO_Compress_Zlib/examples/unzip @@ -2,10 +2,13 @@ use strict; use warnings; +use File::Path; +use File::Basename; use IO::File; -use IO::Uncompress::RawInflate qw(rawinflate $RawInflateError); +use IO::Uncompress::RawInflate qw(:all); -die "Usage: zipcat file" + +die "Usage: zipcat file\n" if @ARGV != 1 ; my $file = $ARGV[0] ; @@ -53,9 +56,10 @@ while () warn "Writing file '$filename' $compressedMethod\n"; - mkpath basename $filename; + #mkpath dirname $filename; - rawinflate $fh => $filename, + #rawinflate $fh => $filename, + rawinflate $fh => '-', Transparent => 1, InputLength => $compressedLength or die "Error uncompressing $file [$filename]: $RawInflateError\n" ; diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Deflate.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Deflate.pm index 1937c7c..dfeb20b 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Deflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Deflate.pm @@ -4,12 +4,12 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(:Status); +use IO::Compress::Base::Common 2.005 qw(:Status); -use Compress::Raw::Zlib 2.004 qw(Z_OK Z_FINISH MAX_WBITS) ; +use Compress::Raw::Zlib 2.005 qw(Z_OK Z_FINISH MAX_WBITS) ; our ($VERSION); -$VERSION = '2.004'; +$VERSION = '2.005'; sub mkCompObject { diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Identity.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Identity.pm index 596b670..cb52223 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Identity.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Adapter/Identity.pm @@ -4,10 +4,10 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(:Status); +use IO::Compress::Base::Common 2.005 qw(:Status); our ($VERSION); -$VERSION = '2.004'; +$VERSION = '2.005'; sub mkCompObject { diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Deflate.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Deflate.pm index 0015505..8ec541b 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Deflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Deflate.pm @@ -6,16 +6,16 @@ use bytes; require Exporter ; -use IO::Compress::RawDeflate 2.004 ; +use IO::Compress::RawDeflate 2.005 ; -use Compress::Raw::Zlib 2.004 ; -use IO::Compress::Zlib::Constants 2.004 ; -use IO::Compress::Base::Common 2.004 qw(createSelfTiedObject); +use Compress::Raw::Zlib 2.005 ; +use IO::Compress::Zlib::Constants 2.005 ; +use IO::Compress::Base::Common 2.005 qw(createSelfTiedObject); our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $DeflateError); -$VERSION = '2.004'; +$VERSION = '2.005'; $DeflateError = ''; @ISA = qw(Exporter IO::Compress::RawDeflate); diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip.pm index 5d16564..f1b801b 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip.pm @@ -8,12 +8,12 @@ use warnings; use bytes; -use IO::Compress::RawDeflate 2.004 ; +use IO::Compress::RawDeflate 2.005 ; -use Compress::Raw::Zlib 2.004 ; -use IO::Compress::Base::Common 2.004 qw(:Status :Parse createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.004 ; -use IO::Compress::Zlib::Extra 2.004 ; +use Compress::Raw::Zlib 2.005 ; +use IO::Compress::Base::Common 2.005 qw(:Status :Parse createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.005 ; +use IO::Compress::Zlib::Extra 2.005 ; BEGIN { @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $GzipError); -$VERSION = '2.004'; +$VERSION = '2.005'; $GzipError = '' ; @ISA = qw(Exporter IO::Compress::RawDeflate); diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip/Constants.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip/Constants.pm index c1e4e57..6992357 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip/Constants.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Gzip/Constants.pm @@ -9,7 +9,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT, %GZIP_OS_Names); our ($GZIP_FNAME_INVALID_CHAR_RE, $GZIP_FCOMMENT_INVALID_CHAR_RE); -$VERSION = '2.004'; +$VERSION = '2.005'; @ISA = qw(Exporter); diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/RawDeflate.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/RawDeflate.pm index 11a2ae3..d3900db 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/RawDeflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/RawDeflate.pm @@ -7,16 +7,16 @@ use warnings; use bytes; -use IO::Compress::Base 2.004 ; -use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); -use IO::Compress::Adapter::Deflate 2.004 ; +use IO::Compress::Base 2.005 ; +use IO::Compress::Base::Common 2.005 qw(:Status createSelfTiedObject); +use IO::Compress::Adapter::Deflate 2.005 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %DEFLATE_CONSTANTS, %EXPORT_TAGS, $RawDeflateError); -$VERSION = '2.004'; +$VERSION = '2.005'; $RawDeflateError = ''; @ISA = qw(Exporter IO::Compress::Base); @@ -141,8 +141,8 @@ sub getZlibParams { my $self = shift ; - use IO::Compress::Base::Common 2.004 qw(:Parse); - use Compress::Raw::Zlib 2.004 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); + use IO::Compress::Base::Common 2.005 qw(:Parse); + use Compress::Raw::Zlib 2.005 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); return ( diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Zip.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Zip.pm index 143760e..4ba7e6f 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Zip.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Zip.pm @@ -4,21 +4,21 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); -use IO::Compress::RawDeflate 2.004 ; -use IO::Compress::Adapter::Deflate 2.004 ; -use IO::Compress::Adapter::Identity 2.004 ; -use IO::Compress::Zlib::Extra 2.004 ; -use IO::Compress::Zip::Constants 2.004 ; +use IO::Compress::Base::Common 2.005 qw(:Status createSelfTiedObject); +use IO::Compress::RawDeflate 2.005 ; +use IO::Compress::Adapter::Deflate 2.005 ; +use IO::Compress::Adapter::Identity 2.005 ; +use IO::Compress::Zlib::Extra 2.005 ; +use IO::Compress::Zip::Constants 2.005 ; -use Compress::Raw::Zlib 2.004 qw(crc32) ; +use Compress::Raw::Zlib 2.005 qw(crc32) ; BEGIN { eval { require IO::Compress::Adapter::Bzip2 ; - import IO::Compress::Adapter::Bzip2 2.004 ; + import IO::Compress::Adapter::Bzip2 2.005 ; require IO::Compress::Bzip2 ; - import IO::Compress::Bzip2 2.004 ; + import IO::Compress::Bzip2 2.005 ; } ; } @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $ZipError); -$VERSION = '2.004'; +$VERSION = '2.005'; $ZipError = ''; @ISA = qw(Exporter IO::Compress::RawDeflate); @@ -441,8 +441,8 @@ sub getExtraParams { my $self = shift ; - use IO::Compress::Base::Common 2.004 qw(:Parse); - use Compress::Raw::Zlib 2.004 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); + use IO::Compress::Base::Common 2.005 qw(:Parse); + use Compress::Raw::Zlib 2.005 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); my @Bzip2 = (); diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Zip/Constants.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Zip/Constants.pm index b0505d6..f1338a6 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Zip/Constants.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Zip/Constants.pm @@ -7,7 +7,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT, %ZIP_CM_MIN_VERSIONS); -$VERSION = '2.004'; +$VERSION = '2.005'; @ISA = qw(Exporter); diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Constants.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Constants.pm index 492b2e3..980d126 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Constants.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Constants.pm @@ -9,7 +9,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT); -$VERSION = '2.004'; +$VERSION = '2.005'; @ISA = qw(Exporter); diff --git a/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Extra.pm b/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Extra.pm index 4034e3a..bd7ac2e 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Extra.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Compress/Zlib/Extra.pm @@ -8,9 +8,9 @@ use bytes; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS); -$VERSION = '2.004'; +$VERSION = '2.005'; -use IO::Compress::Gzip::Constants 2.004 ; +use IO::Compress::Gzip::Constants 2.005 ; sub ExtraFieldError { diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Identity.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Identity.pm index 36b9fbb..1e50612 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Identity.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Identity.pm @@ -4,13 +4,13 @@ use warnings; use strict; use bytes; -use IO::Compress::Base::Common 2.004 qw(:Status); +use IO::Compress::Base::Common 2.005 qw(:Status); our ($VERSION); -$VERSION = '2.004'; +$VERSION = '2.005'; -use Compress::Raw::Zlib 2.004 (); +use Compress::Raw::Zlib 2.005 (); sub mkUncompObject { diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Inflate.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Inflate.pm index 6131c14..2a7125d 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Inflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Adapter/Inflate.pm @@ -4,11 +4,11 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(:Status); -use Compress::Raw::Zlib 2.004 qw(Z_OK Z_DATA_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); +use IO::Compress::Base::Common 2.005 qw(:Status); +use Compress::Raw::Zlib 2.005 qw(Z_OK Z_DATA_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); our ($VERSION); -$VERSION = '2.004'; +$VERSION = '2.005'; diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/AnyInflate.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/AnyInflate.pm index 04c53ba..8e5544e 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/AnyInflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/AnyInflate.pm @@ -6,22 +6,22 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.005 qw(createSelfTiedObject); -use IO::Uncompress::Adapter::Inflate 2.004 (); +use IO::Uncompress::Adapter::Inflate 2.005 (); -use IO::Uncompress::Base 2.004 ; -use IO::Uncompress::Gunzip 2.004 ; -use IO::Uncompress::Inflate 2.004 ; -use IO::Uncompress::RawInflate 2.004 ; -use IO::Uncompress::Unzip 2.004 ; +use IO::Uncompress::Base 2.005 ; +use IO::Uncompress::Gunzip 2.005 ; +use IO::Uncompress::Inflate 2.005 ; +use IO::Uncompress::RawInflate 2.005 ; +use IO::Uncompress::Unzip 2.005 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyInflateError); -$VERSION = '2.004'; +$VERSION = '2.005'; $AnyInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -48,7 +48,7 @@ sub anyinflate sub getExtraParams { - use IO::Compress::Base::Common 2.004 qw(:Parse); + use IO::Compress::Base::Common 2.005 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Gunzip.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Gunzip.pm index 75dcf4b..383470a 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Gunzip.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Gunzip.pm @@ -9,12 +9,12 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.004 ; +use IO::Uncompress::RawInflate 2.005 ; -use Compress::Raw::Zlib 2.004 qw( crc32 ) ; -use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.004 ; -use IO::Compress::Zlib::Extra 2.004 ; +use Compress::Raw::Zlib 2.005 qw( crc32 ) ; +use IO::Compress::Base::Common 2.005 qw(:Status createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.005 ; +use IO::Compress::Zlib::Extra 2.005 ; require Exporter ; @@ -28,7 +28,7 @@ Exporter::export_ok_tags('all'); $GunzipError = ''; -$VERSION = '2.004'; +$VERSION = '2.005'; sub new { @@ -47,7 +47,7 @@ sub gunzip sub getExtraParams { - use IO::Compress::Base::Common 2.004 qw(:Parse); + use IO::Compress::Base::Common 2.005 qw(:Parse); return ( 'ParseExtra' => [1, 1, Parse_boolean, 0] ) ; } diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Inflate.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Inflate.pm index c39170d..bd9452b 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Inflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Inflate.pm @@ -5,15 +5,15 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); -use IO::Compress::Zlib::Constants 2.004 ; +use IO::Compress::Base::Common 2.005 qw(:Status createSelfTiedObject); +use IO::Compress::Zlib::Constants 2.005 ; -use IO::Uncompress::RawInflate 2.004 ; +use IO::Uncompress::RawInflate 2.005 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $InflateError); -$VERSION = '2.004'; +$VERSION = '2.005'; $InflateError = ''; @ISA = qw( Exporter IO::Uncompress::RawInflate ); diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/RawInflate.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/RawInflate.pm index a811e65..a1b438f 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/RawInflate.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/RawInflate.pm @@ -5,11 +5,11 @@ use strict ; use warnings; use bytes; -use Compress::Raw::Zlib 2.004 ; -use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); +use Compress::Raw::Zlib 2.005 ; +use IO::Compress::Base::Common 2.005 qw(:Status createSelfTiedObject); -use IO::Uncompress::Base 2.004 ; -use IO::Uncompress::Adapter::Inflate 2.004 ; +use IO::Uncompress::Base 2.005 ; +use IO::Uncompress::Adapter::Inflate 2.005 ; @@ -17,7 +17,7 @@ use IO::Uncompress::Adapter::Inflate 2.004 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError); -$VERSION = '2.004'; +$VERSION = '2.005'; $RawInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); diff --git a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Unzip.pm b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Unzip.pm index cab4d07..3721fba 100644 --- a/ext/IO_Compress_Zlib/lib/IO/Uncompress/Unzip.pm +++ b/ext/IO_Compress_Zlib/lib/IO/Uncompress/Unzip.pm @@ -8,13 +8,13 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.004 ; -use IO::Compress::Base::Common 2.004 qw(:Status createSelfTiedObject); -use IO::Uncompress::Adapter::Identity 2.004 ; -use IO::Compress::Zlib::Extra 2.004 ; -use IO::Compress::Zip::Constants 2.004 ; +use IO::Uncompress::RawInflate 2.005 ; +use IO::Compress::Base::Common 2.005 qw(:Status createSelfTiedObject); +use IO::Uncompress::Adapter::Identity 2.005 ; +use IO::Compress::Zlib::Extra 2.005 ; +use IO::Compress::Zip::Constants 2.005 ; -use Compress::Raw::Zlib 2.004 qw(crc32) ; +use Compress::Raw::Zlib 2.005 qw(crc32) ; BEGIN { @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup); -$VERSION = '2.004'; +$VERSION = '2.005'; $UnzipError = ''; @ISA = qw(Exporter IO::Uncompress::RawInflate); @@ -60,7 +60,7 @@ sub unzip sub getExtraParams { - use IO::Compress::Base::Common 2.004 qw(:Parse); + use IO::Compress::Base::Common 2.005 qw(:Parse); return ( diff --git a/ext/IO_Compress_Zlib/t/004gziphdr.t b/ext/IO_Compress_Zlib/t/004gziphdr.t index 4b78b3a..210d499 100644 --- a/ext/IO_Compress_Zlib/t/004gziphdr.t +++ b/ext/IO_Compress_Zlib/t/004gziphdr.t @@ -189,7 +189,6 @@ for my $value ( "0D", "0A", "0A0D", "0D0A", "0A0A", "0D0D") ok $hdr->{TextFlag} ; ok ! defined $hdr->{HeaderCRC} ; is $hdr->{OsID}, $ThisOS_code ; - } { @@ -823,6 +822,7 @@ EOM writeFile($name, $good) ; ok my $gunz = new IO::Uncompress::Gunzip $name, + -Append => 1, -Strict => 1; my $uncomp ; 1 while $gunz->read($uncomp) > 0 ; diff --git a/ext/IO_Compress_Zlib/t/005defhdr.t b/ext/IO_Compress_Zlib/t/005defhdr.t index 6cdc175..990b79b 100644 --- a/ext/IO_Compress_Zlib/t/005defhdr.t +++ b/ext/IO_Compress_Zlib/t/005defhdr.t @@ -42,7 +42,7 @@ sub ReadHeaderInfo ok $def->close ; #print "ReadHeaderInfo\n"; hexDump(\$buffer); - ok my $inf = new IO::Uncompress::Inflate \$buffer ; + ok my $inf = new IO::Uncompress::Inflate \$buffer, Append => 1 ; my $uncomp ; #ok $inf->read($uncomp) ; my $actual = 0 ; @@ -72,7 +72,7 @@ sub ReadHeaderInfoZlib cmp_ok $def->flush($buffer), '==', Z_OK; #print "ReadHeaderInfoZlib\n"; hexDump(\$buffer); - ok my $inf = new IO::Uncompress::Inflate \$buffer ; + ok my $inf = new IO::Uncompress::Inflate \$buffer, Append => 1 ; my $uncomp ; #ok $inf->read($uncomp) ; my $actual = 0 ; diff --git a/ext/IO_Compress_Zlib/t/110encode-deflate.t b/ext/IO_Compress_Zlib/t/110encode-deflate.t new file mode 100644 index 0000000..a1f93a9 --- /dev/null +++ b/ext/IO_Compress_Zlib/t/110encode-deflate.t @@ -0,0 +1,21 @@ +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); +use strict; +use warnings; + +use IO::Compress::Deflate qw($DeflateError) ; +use IO::Uncompress::Inflate qw($InflateError) ; + +sub identify +{ + 'IO::Compress::Deflate'; +} + +require "encode.pl" ; +run(); diff --git a/ext/IO_Compress_Zlib/t/110encode-gzip.t b/ext/IO_Compress_Zlib/t/110encode-gzip.t new file mode 100644 index 0000000..d40c36e --- /dev/null +++ b/ext/IO_Compress_Zlib/t/110encode-gzip.t @@ -0,0 +1,21 @@ +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); +use strict; +use warnings; + +use IO::Compress::Gzip qw($GzipError) ; +use IO::Uncompress::Gunzip qw($GunzipError) ; + +sub identify +{ + 'IO::Compress::Gzip'; +} + +require "encode.pl" ; +run(); diff --git a/ext/IO_Compress_Zlib/t/110encode-rawdeflate.t b/ext/IO_Compress_Zlib/t/110encode-rawdeflate.t new file mode 100644 index 0000000..58fa741 --- /dev/null +++ b/ext/IO_Compress_Zlib/t/110encode-rawdeflate.t @@ -0,0 +1,21 @@ +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); +use strict; +use warnings; + +use IO::Compress::RawDeflate qw($RawDeflateError) ; +use IO::Uncompress::RawInflate qw($RawInflateError) ; + +sub identify +{ + 'IO::Compress::RawDeflate'; +} + +require "encode.pl" ; +run(); diff --git a/ext/IO_Compress_Zlib/t/110encode-zip.t b/ext/IO_Compress_Zlib/t/110encode-zip.t new file mode 100644 index 0000000..80e99ee --- /dev/null +++ b/ext/IO_Compress_Zlib/t/110encode-zip.t @@ -0,0 +1,21 @@ +BEGIN { + if ($ENV{PERL_CORE}) { + chdir 't' if -d 't'; + @INC = ("../lib", "lib/compress"); + } +} + +use lib qw(t t/compress); +use strict; +use warnings; + +use IO::Compress::Zip qw($ZipError) ; +use IO::Uncompress::Unzip qw($UnzipError) ; + +sub identify +{ + 'IO::Compress::Zip'; +} + +require "encode.pl" ; +run(); diff --git a/t/lib/compress/encode.pl b/t/lib/compress/encode.pl new file mode 100644 index 0000000..142bd08 --- /dev/null +++ b/t/lib/compress/encode.pl @@ -0,0 +1,123 @@ + +use strict; +use warnings; +use bytes; + +use Test::More ; +use CompTestUtils; + +BEGIN +{ + plan skip_all => "Encode is not available" + if $] < 5.006 ; + + eval { require Encode; Encode->import(); }; + + plan skip_all => "Encode is not available" + if $@ ; + + # use Test::NoWarnings, if available + my $extra = 0 ; + + my $st = eval { require Test::NoWarnings ; import Test::NoWarnings; 1; }; + $extra = 1 + if $st ; + + plan(tests => 7 + $extra) ; +} + +sub run +{ + my $CompressClass = identify(); + my $UncompressClass = getInverse($CompressClass); + my $Error = getErrorRef($CompressClass); + my $UnError = getErrorRef($UncompressClass); + + + my $string = "\x{df}\x{100}"; + my $encString = Encode::encode_utf8($string); + my $buffer = $encString; + + #for my $from ( qw(filename filehandle buffer) ) + { +# my $input ; +# my $lex = new LexFile my $name ; +# +# +# if ($from eq 'buffer') +# { $input = \$buffer } +# elsif ($from eq 'filename') +# { +# $input = $name ; +# writeFile($name, $buffer); +# } +# elsif ($from eq 'filehandle') +# { +# $input = new IO::File "<$name" ; +# } + + for my $to ( qw(filehandle buffer)) + { + title "OO Mode: To $to, Encode by hand"; + + my $lex2 = new LexFile my $name2 ; + my $output; + my $buffer; + + if ($to eq 'buffer') + { $output = \$buffer } + elsif ($to eq 'filename') + { + $output = $name2 ; + } + elsif ($to eq 'filehandle') + { + $output = new IO::File ">$name2" ; + } + + + my $out ; + my $cs = new $CompressClass($output, AutoClose =>1); + $cs->print($encString); + $cs->close(); + + my $input; + if ($to eq 'buffer') + { $input = \$buffer } + else + { + $input = $name2 ; + } + + my $ucs = new $UncompressClass($input, Append => 1); + my $got; + 1 while $ucs->read($got) > 0 ; + my $decode = Encode::decode_utf8($got); + + + is $string, $decode, " Expected output"; + + + } + } + + { + title "Catch wide characters"; + + my $out; + my $cs = new $CompressClass(\$out); + my $a = "a\xFF\x{100}"; + eval { $cs->syswrite($a) }; + like($@, qr/Wide character in ${CompressClass}::write/, + " wide characters in ${CompressClass}::write"); + eval { syswrite($cs, $a) }; + like($@, qr/Wide character in ${CompressClass}::write/, + " wide characters in ${CompressClass}::write"); + } + +} + + + +1; + diff --git a/t/lib/compress/generic.pl b/t/lib/compress/generic.pl index 9e808ee..79e62c3 100644 --- a/t/lib/compress/generic.pl +++ b/t/lib/compress/generic.pl @@ -18,7 +18,7 @@ BEGIN $extra = 1 if $st ; - plan(tests => 641 + $extra) ; + plan(tests => 670 + $extra) ; } sub myGZreadFile @@ -781,7 +781,9 @@ EOT eval { $io->read(1) } ; like $@, mkErr("buffer parameter is read-only"); + $buf = "abcd"; is $io->read($buf, 0), 0, "Requested 0 bytes" ; + is $buf, "", "Buffer empty"; is $io->read($buf, 3), 3 ; is $buf, "Thi"; @@ -791,6 +793,30 @@ EOT or print "# [$buf]\n" ;; ok ! $io->eof; + $buf = "ab" ; + is $io->read($buf, 3, 4), 3 ; + is $buf, "ab" . "\x00" x 2 . "s a" + or print "# [$buf]\n" ;; + ok ! $io->eof; + + # read the rest of the file + $buf = ''; + my $remain = length($str) - 9; + is $io->read($buf, $remain+1), $remain ; + is $buf, substr($str, 9); + ok $io->eof; + + $buf = "hello"; + is $io->read($buf, 10), 0 ; + is $buf, "", "Buffer empty"; + ok $io->eof; + + ok $io->close(); + $buf = "hello"; + is $io->read($buf, 10), 0 ; + is $buf, "hello", "Buffer not empty"; + ok $io->eof; + # $io->seek(-4, 2); # # ok ! $io->eof; @@ -930,11 +956,15 @@ EOT } - # Test read + # Test Read { my $io = $UncompressClass->new($name); + $buf = "abcd"; + is $io->read($buf, 0), 0, "Requested 0 bytes" ; + is $buf, "", "Buffer empty"; + ok $io->read($buf, 3) == 3 ; ok $buf eq "Thi"; @@ -942,6 +972,30 @@ EOT ok $buf eq "Ths i"; ok ! $io->eof; + $buf = "ab" ; + is $io->read($buf, 3, 4), 3 ; + is $buf, "ab" . "\x00" x 2 . "s a" + or print "# [$buf]\n" ;; + ok ! $io->eof; + + # read the rest of the file + $buf = ''; + my $remain = length($str) - 9; + is $io->read($buf, $remain), $remain ; + is $buf, substr($str, 9); + ok $io->eof; + + $buf = "hello"; + is $io->read($buf, 10), 0 ; + is $buf, "", "Buffer empty"; + ok $io->eof; + + ok $io->close(); + $buf = "hello"; + is $io->read($buf, 10), 0 ; + is $buf, "hello", "Buffer not empty"; + ok $io->eof; + # $io->seek(-4, 2); # # ok ! $io->eof; diff --git a/t/lib/compress/oneshot.pl b/t/lib/compress/oneshot.pl index 6fdd4c9..0646958 100644 --- a/t/lib/compress/oneshot.pl +++ b/t/lib/compress/oneshot.pl @@ -51,7 +51,7 @@ sub run like $@, mkErr("^$TopType: unknown key value\\(s\\) Fred"), ' Illegal Parameters'; eval { $a = $Func->() ;} ; - like $@, mkErr("^$TopType: expected at least 1 parameters"), ' No Parameters'; + like $@, "/^$TopType: expected at least 1 parameters/", ' No Parameters'; eval { $a = $Func->(\$x, \1) ;} ; like $$Error, "/^$TopType: output buffer is read-only/", ' Output is read-only' ; diff --git a/t/lib/compress/tied.pl b/t/lib/compress/tied.pl index 52f51c7..7833b9a 100644 --- a/t/lib/compress/tied.pl +++ b/t/lib/compress/tied.pl @@ -199,10 +199,10 @@ EOT { my $io = new $UncompressClass $name ; - ok ! $io->eof; - is $io->tell(), 0 ; + ok ! $io->eof, " Not EOF"; + is $io->tell(), 0, " Tell is 0" ; my @lines = <$io>; - is @lines, 6 + is @lines, 6, " Line is 6" or print "# Got " . scalar(@lines) . " lines, expected 6\n" ; is $lines[1], "of a paragraph\n" ; is join('', @lines), $str ;