From 10c2b2bb1bed28f54450876b0419c34d91d8586f Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 30 Aug 2009 21:01:11 +0100 Subject: compress 2.021 --- ext/Compress-Raw-Bzip2/Changes | 5 + ext/Compress-Raw-Bzip2/README | 6 +- ext/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm | 2 +- ext/Compress-Raw-Bzip2/private/MakeUtil.pm | 6 +- ext/Compress-Raw-Bzip2/t/000prereq.t | 2 +- ext/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm | 321 +++++++++++---------- ext/Compress-Raw-Zlib/Changes | 5 + ext/Compress-Raw-Zlib/README | 6 +- ext/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm | 2 +- ext/Compress-Raw-Zlib/private/MakeUtil.pm | 6 +- ext/Compress-Raw-Zlib/t/compress/CompTestUtils.pm | 321 +++++++++++---------- ext/IO-Compress/Changes | 42 +++ ext/IO-Compress/Makefile.PL | 3 +- ext/IO-Compress/README | 6 +- ext/IO-Compress/lib/Compress/Zlib.pm | 17 +- ext/IO-Compress/lib/IO/Compress/Adapter/Bzip2.pm | 6 +- ext/IO-Compress/lib/IO/Compress/Adapter/Deflate.pm | 6 +- .../lib/IO/Compress/Adapter/Identity.pm | 4 +- ext/IO-Compress/lib/IO/Compress/Base.pm | 8 +- ext/IO-Compress/lib/IO/Compress/Base/Common.pm | 20 +- ext/IO-Compress/lib/IO/Compress/Bzip2.pm | 10 +- ext/IO-Compress/lib/IO/Compress/Deflate.pm | 10 +- ext/IO-Compress/lib/IO/Compress/Gzip.pm | 12 +- ext/IO-Compress/lib/IO/Compress/Gzip/Constants.pm | 4 +- ext/IO-Compress/lib/IO/Compress/RawDeflate.pm | 12 +- ext/IO-Compress/lib/IO/Compress/Zip.pm | 166 +++++++---- ext/IO-Compress/lib/IO/Compress/Zip/Constants.pm | 2 +- ext/IO-Compress/lib/IO/Compress/Zlib/Constants.pm | 2 +- ext/IO-Compress/lib/IO/Compress/Zlib/Extra.pm | 4 +- .../lib/IO/Uncompress/Adapter/Bunzip2.pm | 6 +- .../lib/IO/Uncompress/Adapter/Identity.pm | 6 +- .../lib/IO/Uncompress/Adapter/Inflate.pm | 6 +- ext/IO-Compress/lib/IO/Uncompress/AnyInflate.pm | 20 +- ext/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm | 55 ++-- ext/IO-Compress/lib/IO/Uncompress/Base.pm | 18 +- ext/IO-Compress/lib/IO/Uncompress/Bunzip2.pm | 10 +- ext/IO-Compress/lib/IO/Uncompress/Gunzip.pm | 16 +- ext/IO-Compress/lib/IO/Uncompress/Inflate.pm | 10 +- ext/IO-Compress/lib/IO/Uncompress/RawInflate.pm | 12 +- ext/IO-Compress/lib/IO/Uncompress/Unzip.pm | 159 ++++++---- ext/IO-Compress/private/MakeUtil.pm | 6 +- ext/IO-Compress/t/000prereq.t | 48 ++- ext/IO-Compress/t/006zip.t | 3 +- ext/IO-Compress/t/01misc.t | 47 ++- ext/IO-Compress/t/105oneshot-zip-bzip2-only.t | 4 +- ext/IO-Compress/t/105oneshot-zip-only.t | 4 +- ext/IO-Compress/t/compress/CompTestUtils.pm | 321 +++++++++++---------- ext/IO-Compress/t/compress/oneshot.pl | 18 +- 48 files changed, 1048 insertions(+), 737 deletions(-) diff --git a/ext/Compress-Raw-Bzip2/Changes b/ext/Compress-Raw-Bzip2/Changes index 798e1ac3cd..a8e2fbf73e 100644 --- a/ext/Compress-Raw-Bzip2/Changes +++ b/ext/Compress-Raw-Bzip2/Changes @@ -1,6 +1,11 @@ CHANGES ------- + 2.021 30 August 2009 + + * Changed test harness so that it can cope with PERL5OPT=-MCarp=verbose + [RT# 47225] + 2.020 4 June 2009 * No Changes diff --git a/ext/Compress-Raw-Bzip2/README b/ext/Compress-Raw-Bzip2/README index c96ce469b8..21ff6bc90c 100644 --- a/ext/Compress-Raw-Bzip2/README +++ b/ext/Compress-Raw-Bzip2/README @@ -1,9 +1,9 @@ Compress-Raw-Bzip2 - Version 2.020 + Version 2.021 - 3rd June 2009 + 30th August 2009 Copyright (c) 2005-2009 Paul Marquess. All rights reserved. This program is free software; you can redistribute it @@ -164,7 +164,7 @@ To help me help you, I need all of the following information: If you haven't installed Compress-Raw-Bzip2 then search Compress::Raw::Bzip2.pm for a line like this: - $VERSION = "2.020" ; + $VERSION = "2.021" ; c. The version of bzip2 you have used. If you have successfully installed Compress-Raw-Bzip2, this one-liner diff --git a/ext/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm b/ext/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm index 6b725325d8..c80eae31b9 100644 --- a/ext/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm +++ b/ext/Compress-Raw-Bzip2/lib/Compress/Raw/Bzip2.pm @@ -12,7 +12,7 @@ use Carp ; use bytes ; our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD); -$VERSION = '2.020'; +$VERSION = '2.021'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/ext/Compress-Raw-Bzip2/private/MakeUtil.pm b/ext/Compress-Raw-Bzip2/private/MakeUtil.pm index e595910654..47aebd6074 100644 --- a/ext/Compress-Raw-Bzip2/private/MakeUtil.pm +++ b/ext/Compress-Raw-Bzip2/private/MakeUtil.pm @@ -58,9 +58,9 @@ sub MY::postamble MyTrebleCheck: @echo Checking for $$^W in files: '. "@files" . ' - @perl -ne \' \ - exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \ - \' ' . " @files || " . ' \ + perl -ne \' \ + exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \' \ + ' . " @files || " . ' \ (echo found unexpected $$^W ; exit 1) @echo All is ok. diff --git a/ext/Compress-Raw-Bzip2/t/000prereq.t b/ext/Compress-Raw-Bzip2/t/000prereq.t index 2fb29f3035..6f3872b2d5 100644 --- a/ext/Compress-Raw-Bzip2/t/000prereq.t +++ b/ext/Compress-Raw-Bzip2/t/000prereq.t @@ -19,7 +19,7 @@ BEGIN if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - my $VERSION = '2.020'; + my $VERSION = '2.021'; my @NAMES = qw( ); diff --git a/ext/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm b/ext/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm index 22b6d5646c..cb63d6274c 100644 --- a/ext/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm +++ b/ext/Compress-Raw-Bzip2/t/compress/CompTestUtils.pm @@ -203,12 +203,164 @@ sub cmpFile return readFile($filename) eq unpack("u", $uue) ; } -sub isRawFormat +#sub isRawFormat +#{ +# my $class = shift; +# # TODO -- add Lzma here? +# my %raw = map { $_ => 1 } qw( RawDeflate ); +# +# return defined $raw{$class}; +#} + + + +my %TOP = ( + 'IO::Uncompress::AnyInflate' => { Inverse => 'IO::Compress::Gzip', + Error => 'AnyInflateError', + TopLevel => 'anyinflate', + Raw => 0, + }, + + 'IO::Uncompress::AnyUncompress' => { Inverse => 'IO::Compress::Gzip', + Error => 'AnyUncompressError', + TopLevel => 'anyuncompress', + Raw => 0, + }, + + 'IO::Compress::Gzip' => { Inverse => 'IO::Uncompress::Gunzip', + Error => 'GzipError', + TopLevel => 'gzip', + Raw => 0, + }, + 'IO::Uncompress::Gunzip' => { Inverse => 'IO::Compress::Gzip', + Error => 'GunzipError', + TopLevel => 'gunzip', + Raw => 0, + }, + + 'IO::Compress::Deflate' => { Inverse => 'IO::Uncompress::Inflate', + Error => 'DeflateError', + TopLevel => 'deflate', + Raw => 0, + }, + 'IO::Uncompress::Inflate' => { Inverse => 'IO::Compress::Deflate', + Error => 'InflateError', + TopLevel => 'inflate', + Raw => 0, + }, + + 'IO::Compress::RawDeflate' => { Inverse => 'IO::Uncompress::RawInflate', + Error => 'RawDeflateError', + TopLevel => 'rawdeflate', + Raw => 1, + }, + 'IO::Uncompress::RawInflate' => { Inverse => 'IO::Compress::RawDeflate', + Error => 'RawInflateError', + TopLevel => 'rawinflate', + Raw => 1, + }, + + 'IO::Compress::Zip' => { Inverse => 'IO::Uncompress::Unzip', + Error => 'ZipError', + TopLevel => 'zip', + Raw => 0, + }, + 'IO::Uncompress::Unzip' => { Inverse => 'IO::Compress::Zip', + Error => 'UnzipError', + TopLevel => 'unzip', + Raw => 0, + }, + + 'IO::Compress::Bzip2' => { Inverse => 'IO::Uncompress::Bunzip2', + Error => 'Bzip2Error', + TopLevel => 'bzip2', + Raw => 0, + }, + 'IO::Uncompress::Bunzip2' => { Inverse => 'IO::Compress::Bzip2', + Error => 'Bunzip2Error', + TopLevel => 'bunzip2', + Raw => 0, + }, + + 'IO::Compress::Lzop' => { Inverse => 'IO::Uncompress::UnLzop', + Error => 'LzopError', + TopLevel => 'lzop', + Raw => 0, + }, + 'IO::Uncompress::UnLzop' => { Inverse => 'IO::Compress::Lzop', + Error => 'UnLzopError', + TopLevel => 'unlzop', + Raw => 0, + }, + + 'IO::Compress::Lzf' => { Inverse => 'IO::Uncompress::UnLzf', + Error => 'LzfError', + TopLevel => 'lzf', + Raw => 0, + }, + 'IO::Uncompress::UnLzf' => { Inverse => 'IO::Compress::Lzf', + Error => 'UnLzfError', + TopLevel => 'unlzf', + Raw => 0, + }, + + 'IO::Compress::Lzma' => { Inverse => 'IO::Uncompress::UnLzma', + Error => 'LzmaError', + TopLevel => 'lzma', + Raw => 1, + }, + 'IO::Uncompress::UnLzma' => { Inverse => 'IO::Compress::Lzma', + Error => 'UnLzmaError', + TopLevel => 'unlzma', + Raw => 1, + }, + + 'IO::Compress::Xz' => { Inverse => 'IO::Uncompress::UnXz', + Error => 'XzError', + TopLevel => 'xz', + Raw => 0, + }, + 'IO::Uncompress::UnXz' => { Inverse => 'IO::Compress::Xz', + Error => 'UnXzError', + TopLevel => 'unxz', + Raw => 0, + }, + + 'IO::Compress::PPMd' => { Inverse => 'IO::Uncompress::UnPPMd', + Error => 'PPMdError', + TopLevel => 'ppmd', + Raw => 0, + }, + 'IO::Uncompress::UnPPMd' => { Inverse => 'IO::Compress::PPMd', + Error => 'UnPPMdError', + TopLevel => 'unppmd', + Raw => 0, + }, + + 'IO::Compress::DummyComp' => { Inverse => 'IO::Uncompress::DummyUnComp', + Error => 'DummyCompError', + TopLevel => 'dummycomp', + Raw => 0, + }, + 'IO::Uncompress::DummyUnComp' => { Inverse => 'IO::Compress::DummyComp', + Error => 'DummyUnCompError', + TopLevel => 'dummyunComp', + Raw => 0, + }, +); + + +for my $key (keys %TOP) { - my $class = shift; - my %raw = map { $_ => 1 } qw( RawDeflate ); + no strict; + no warnings; + $TOP{$key}{Error} = \${ $key . '::' . $TOP{$key}{Error} }; + $TOP{$key}{TopLevel} = $key . '::' . $TOP{$key}{TopLevel} ; - return defined $raw{$class}; + # Silence used once warning in really old perl + my $dummy = \${ $key . '::' . $TOP{$key}{Error} }; + + #$TOP{$key . "::" . $TOP{$key}{TopLevel} } = $TOP{$key}; } sub uncompressBuffer @@ -216,159 +368,43 @@ sub uncompressBuffer my $compWith = shift ; my $buffer = shift ; - my %mapping = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Gzip::gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::Deflate::deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::RawDeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::RawDeflate::rawdeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::Bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Bzip2::bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Zip::zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf' , - 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf', - 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd' , - 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd', - 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', - 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp', - ); my $out ; - my $obj = $mapping{$compWith}->new( \$buffer, -Append => 1); + my $obj = $TOP{$compWith}{Inverse}->new( \$buffer, -Append => 1); 1 while $obj->read($out) > 0 ; return $out ; } -my %ErrorMap = ( 'IO::Compress::Gzip' => \$IO::Compress::Gzip::GzipError, - 'IO::Compress::Gzip::gzip' => \$IO::Compress::Gzip::GzipError, - 'IO::Uncompress::Gunzip' => \$IO::Uncompress::Gunzip::GunzipError, - 'IO::Uncompress::Gunzip::gunzip' => \$IO::Uncompress::Gunzip::GunzipError, - 'IO::Uncompress::Inflate' => \$IO::Uncompress::Inflate::InflateError, - 'IO::Uncompress::Inflate::inflate' => \$IO::Uncompress::Inflate::InflateError, - 'IO::Compress::Deflate' => \$IO::Compress::Deflate::DeflateError, - 'IO::Compress::Deflate::deflate' => \$IO::Compress::Deflate::DeflateError, - 'IO::Uncompress::RawInflate' => \$IO::Uncompress::RawInflate::RawInflateError, - 'IO::Uncompress::RawInflate::rawinflate' => \$IO::Uncompress::RawInflate::RawInflateError, - 'IO::Uncompress::AnyInflate' => \$IO::Uncompress::AnyInflate::AnyInflateError, - 'IO::Uncompress::AnyInflate::anyinflate' => \$IO::Uncompress::AnyInflate::AnyInflateError, - 'IO::Uncompress::AnyUncompress' => \$IO::Uncompress::AnyUncompress::AnyUncompressError, - 'IO::Uncompress::AnyUncompress::anyUncompress' => \$IO::Uncompress::AnyUncompress::AnyUncompressError, - 'IO::Compress::RawDeflate' => \$IO::Compress::RawDeflate::RawDeflateError, - 'IO::Compress::RawDeflate::rawdeflate' => \$IO::Compress::RawDeflate::RawDeflateError, - 'IO::Compress::Bzip2' => \$IO::Compress::Bzip2::Bzip2Error, - 'IO::Compress::Bzip2::bzip2' => \$IO::Compress::Bzip2::Bzip2Error, - 'IO::Uncompress::Bunzip2' => \$IO::Uncompress::Bunzip2::Bunzip2Error, - 'IO::Uncompress::Bunzip2::bunzip2' => \$IO::Uncompress::Bunzip2::Bunzip2Error, - 'IO::Compress::Zip' => \$IO::Compress::Zip::ZipError, - 'IO::Compress::Zip::zip' => \$IO::Compress::Zip::ZipError, - 'IO::Uncompress::Unzip' => \$IO::Uncompress::Unzip::UnzipError, - 'IO::Uncompress::Unzip::unzip' => \$IO::Uncompress::Unzip::UnzipError, - 'IO::Compress::Lzop' => \$IO::Compress::Lzop::LzopError, - 'IO::Compress::Lzop::lzop' => \$IO::Compress::Lzop::LzopError, - 'IO::Uncompress::UnLzop' => \$IO::Uncompress::UnLzop::UnLzopError, - 'IO::Uncompress::UnLzop::unlzop' => \$IO::Uncompress::UnLzop::UnLzopError, - 'IO::Compress::Lzf' => \$IO::Compress::Lzf::LzfError, - 'IO::Compress::Lzf::lzf' => \$IO::Compress::Lzf::LzfError, - 'IO::Uncompress::UnLzf' => \$IO::Uncompress::UnLzf::UnLzfError, - 'IO::Uncompress::UnLzf::unlzf' => \$IO::Uncompress::UnLzf::UnLzfError, - 'IO::Compress::PPMd' => \$IO::Compress::PPMd::PPMdError, - 'IO::Compress::PPMd::ppmd' => \$IO::Compress::PPMd::PPMdError, - 'IO::Uncompress::UnPPMd' => \$IO::Uncompress::UnPPMd::UnPPMdError, - 'IO::Uncompress::UnPPMd::unppmd' => \$IO::Uncompress::UnPPMd::UnPPMdError, - - 'IO::Compress::DummyComp' => \$IO::Compress::DummyComp::DummyCompError, - 'IO::Compress::DummyComp::dummycomp'=> \$IO::Compress::DummyComp::DummyCompError, - 'IO::Uncompress::DummyUncomp' => \$IO::Uncompress::DummyUncomp::DummyUncompError, - 'IO::Uncompress::DummyUncomp::dummyuncomp' => \$IO::Uncompress::DummyUncomp::DummyUncompError, - ); - -my %TopFuncMap = ( 'IO::Compress::Gzip' => 'IO::Compress::Gzip::gzip', - 'IO::Uncompress::Gunzip' => 'IO::Uncompress::Gunzip::gunzip', - - 'IO::Compress::Deflate' => 'IO::Compress::Deflate::deflate', - 'IO::Uncompress::Inflate' => 'IO::Uncompress::Inflate::inflate', - - 'IO::Compress::RawDeflate' => 'IO::Compress::RawDeflate::rawdeflate', - 'IO::Uncompress::RawInflate' => 'IO::Uncompress::RawInflate::rawinflate', - - 'IO::Uncompress::AnyInflate' => 'IO::Uncompress::AnyInflate::anyinflate', - 'IO::Uncompress::AnyUncompress' => 'IO::Uncompress::AnyUncompress::anyuncompress', - - 'IO::Compress::Bzip2' => 'IO::Compress::Bzip2::bzip2', - 'IO::Uncompress::Bunzip2' => 'IO::Uncompress::Bunzip2::bunzip2', - - 'IO::Compress::Zip' => 'IO::Compress::Zip::zip', - 'IO::Uncompress::Unzip' => 'IO::Uncompress::Unzip::unzip', - 'IO::Compress::Lzop' => 'IO::Compress::Lzop::lzop', - 'IO::Uncompress::UnLzop' => 'IO::Uncompress::UnLzop::unlzop', - 'IO::Compress::Lzf' => 'IO::Compress::Lzf::lzf', - 'IO::Uncompress::UnLzf' => 'IO::Uncompress::UnLzf::unlzf', - 'IO::Compress::PPMd' => 'IO::Compress::PPMd::ppmd', - 'IO::Uncompress::UnPPMd' => 'IO::Uncompress::UnPPMd::unppmd', - 'IO::Compress::DummyComp' => 'IO::Compress::DummyComp::dummyuncomp', - 'IO::Uncompress::DummyUncomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', - ); - - %TopFuncMap = map { ($_ => $TopFuncMap{$_}, - $TopFuncMap{$_} => $TopFuncMap{$_}) } - keys %TopFuncMap ; - - #%TopFuncMap = map { ($_ => \&{ $TopFuncMap{$_} ) } - #keys %TopFuncMap ; - - -my %inverse = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Gzip::gzip' => 'IO::Uncompress::Gunzip::gunzip', - 'IO::Compress::Deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::Deflate::deflate' => 'IO::Uncompress::Inflate::inflate', - 'IO::Compress::RawDeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::RawDeflate::rawdeflate' => 'IO::Uncompress::RawInflate::rawinflate', - 'IO::Compress::Bzip2::bzip2' => 'IO::Uncompress::Bunzip2::bunzip2', - 'IO::Compress::Bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Zip::zip' => 'IO::Uncompress::Unzip::unzip', - 'IO::Compress::Zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop::unlzop', - 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf::unlzf', - 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf', - 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd::unppmd', - 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd', - 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', - 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', - ); - -%inverse = map { ($_ => $inverse{$_}, $inverse{$_} => $_) } keys %inverse; sub getInverse { my $class = shift ; - return $inverse{$class} ; + return $TOP{$class}{Inverse}; } sub getErrorRef { my $class = shift ; - return $ErrorMap{$class} ; + return $TOP{$class}{Error}; } sub getTopFuncRef { my $class = shift ; - return \&{ $TopFuncMap{$class} } ; + die "Cannot find $class" + if ! defined $TOP{$class}{TopLevel}; + return \&{ $TOP{$class}{TopLevel} } ; } sub getTopFuncName { my $class = shift ; - return $TopFuncMap{$class} ; + return $TOP{$class}{TopLevel} ; } sub compressBuffer @@ -376,32 +412,11 @@ sub compressBuffer my $compWith = shift ; my $buffer = shift ; - my %mapping = ( 'IO::Uncompress::Gunzip' => 'IO::Compress::Gzip', - 'IO::Uncompress::Gunzip::gunzip' => 'IO::Compress::Gzip', - 'IO::Uncompress::Inflate' => 'IO::Compress::Deflate', - 'IO::Uncompress::Inflate::inflate' => 'IO::Compress::Deflate', - 'IO::Uncompress::RawInflate' => 'IO::Compress::RawDeflate', - 'IO::Uncompress::RawInflate::rawinflate' => 'IO::Compress::RawDeflate', - 'IO::Uncompress::Bunzip2' => 'IO::Compress::Bzip2', - 'IO::Uncompress::Bunzip2::bunzip2' => 'IO::Compress::Bzip2', - 'IO::Uncompress::Unzip' => 'IO::Compress::Zip', - 'IO::Uncompress::Unzip::unzip' => 'IO::Compress::Zip', - 'IO::Uncompress::UnLzop' => 'IO::Compress::Lzop', - 'IO::Uncompress::UnLzop::unlzop' => 'IO::Compress::Lzop', - 'IO::Uncompress::UnLzp' => 'IO::Compress::Lzf', - 'IO::Uncompress::UnLzf::unlzf' => 'IO::Compress::Lzf', - 'IO::Uncompress::UnPPMd' => 'IO::Compress::PPMd', - 'IO::Uncompress::UnPPMd::unppmd' => 'IO::Compress::PPMd', - 'IO::Uncompress::AnyInflate' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyInflate::anyinflate' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyUncompress' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyUncompress::anyuncompress' => 'IO::Compress::Gzip', - 'IO::Uncompress::DummyUncomp' => 'IO::Compress::DummyComp', - 'IO::Uncompress::DummyUncomp::dummyuncomp'=> 'IO::Compress::DummyComp', - ); my $out ; - my $obj = $mapping{$compWith}->new( \$out); + die "Cannot find $compWith" + if ! defined $TOP{$compWith}{Inverse}; + my $obj = $TOP{$compWith}{Inverse}->new( \$out); $obj->write($buffer) ; $obj->close(); return $out ; @@ -584,7 +599,7 @@ sub mkErr $file = quotemeta($file); - return "/$string\\s+at $file line $line/" if $] >= 5.006 ; + #return "/$string\\s+at $file line $line/" if $] >= 5.006 ; return "/$string\\s+at /" ; } @@ -592,7 +607,7 @@ sub mkEvalErr { my $string = shift ; - return "/$string\\s+at \\(eval /" if $] > 5.006 ; + #return "/$string\\s+at \\(eval /" if $] > 5.006 ; return "/$string\\s+at /" ; } diff --git a/ext/Compress-Raw-Zlib/Changes b/ext/Compress-Raw-Zlib/Changes index 3fabb3dfae..891a693e6d 100644 --- a/ext/Compress-Raw-Zlib/Changes +++ b/ext/Compress-Raw-Zlib/Changes @@ -1,6 +1,11 @@ CHANGES ------- + 2.021 30 August 2009 + + * Changed test harness so that it can cope with PERL5OPT=-MCarp=verbose + [RT# 47225] + 2.020 3 June 2009 * Minor documentation update. diff --git a/ext/Compress-Raw-Zlib/README b/ext/Compress-Raw-Zlib/README index 5568c5daca..f1387f3157 100644 --- a/ext/Compress-Raw-Zlib/README +++ b/ext/Compress-Raw-Zlib/README @@ -1,9 +1,9 @@ Compress-Raw-Zlib - Version 2.020 + Version 2.021 - 3rd June 2009 + 30th August 2009 Copyright (c) 2005-2009 Paul Marquess. All rights reserved. This program is free software; you can redistribute it @@ -355,7 +355,7 @@ To help me help you, I need all of the following information: If you haven't installed Compress-Raw-Zlib then search Compress::Raw::Zlib.pm for a line like this: - $VERSION = "2.020" ; + $VERSION = "2.021" ; c. The version of zlib you have used. If you have successfully installed Compress-Raw-Zlib, this one-liner diff --git a/ext/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm b/ext/Compress-Raw-Zlib/lib/Compress/Raw/Zlib.pm index 25394f162a..04bfb2e3fc 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.020'; +$VERSION = '2.021'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; diff --git a/ext/Compress-Raw-Zlib/private/MakeUtil.pm b/ext/Compress-Raw-Zlib/private/MakeUtil.pm index e595910654..47aebd6074 100644 --- a/ext/Compress-Raw-Zlib/private/MakeUtil.pm +++ b/ext/Compress-Raw-Zlib/private/MakeUtil.pm @@ -58,9 +58,9 @@ sub MY::postamble MyTrebleCheck: @echo Checking for $$^W in files: '. "@files" . ' - @perl -ne \' \ - exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \ - \' ' . " @files || " . ' \ + perl -ne \' \ + exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \' \ + ' . " @files || " . ' \ (echo found unexpected $$^W ; exit 1) @echo All is ok. diff --git a/ext/Compress-Raw-Zlib/t/compress/CompTestUtils.pm b/ext/Compress-Raw-Zlib/t/compress/CompTestUtils.pm index 22b6d5646c..cb63d6274c 100644 --- a/ext/Compress-Raw-Zlib/t/compress/CompTestUtils.pm +++ b/ext/Compress-Raw-Zlib/t/compress/CompTestUtils.pm @@ -203,12 +203,164 @@ sub cmpFile return readFile($filename) eq unpack("u", $uue) ; } -sub isRawFormat +#sub isRawFormat +#{ +# my $class = shift; +# # TODO -- add Lzma here? +# my %raw = map { $_ => 1 } qw( RawDeflate ); +# +# return defined $raw{$class}; +#} + + + +my %TOP = ( + 'IO::Uncompress::AnyInflate' => { Inverse => 'IO::Compress::Gzip', + Error => 'AnyInflateError', + TopLevel => 'anyinflate', + Raw => 0, + }, + + 'IO::Uncompress::AnyUncompress' => { Inverse => 'IO::Compress::Gzip', + Error => 'AnyUncompressError', + TopLevel => 'anyuncompress', + Raw => 0, + }, + + 'IO::Compress::Gzip' => { Inverse => 'IO::Uncompress::Gunzip', + Error => 'GzipError', + TopLevel => 'gzip', + Raw => 0, + }, + 'IO::Uncompress::Gunzip' => { Inverse => 'IO::Compress::Gzip', + Error => 'GunzipError', + TopLevel => 'gunzip', + Raw => 0, + }, + + 'IO::Compress::Deflate' => { Inverse => 'IO::Uncompress::Inflate', + Error => 'DeflateError', + TopLevel => 'deflate', + Raw => 0, + }, + 'IO::Uncompress::Inflate' => { Inverse => 'IO::Compress::Deflate', + Error => 'InflateError', + TopLevel => 'inflate', + Raw => 0, + }, + + 'IO::Compress::RawDeflate' => { Inverse => 'IO::Uncompress::RawInflate', + Error => 'RawDeflateError', + TopLevel => 'rawdeflate', + Raw => 1, + }, + 'IO::Uncompress::RawInflate' => { Inverse => 'IO::Compress::RawDeflate', + Error => 'RawInflateError', + TopLevel => 'rawinflate', + Raw => 1, + }, + + 'IO::Compress::Zip' => { Inverse => 'IO::Uncompress::Unzip', + Error => 'ZipError', + TopLevel => 'zip', + Raw => 0, + }, + 'IO::Uncompress::Unzip' => { Inverse => 'IO::Compress::Zip', + Error => 'UnzipError', + TopLevel => 'unzip', + Raw => 0, + }, + + 'IO::Compress::Bzip2' => { Inverse => 'IO::Uncompress::Bunzip2', + Error => 'Bzip2Error', + TopLevel => 'bzip2', + Raw => 0, + }, + 'IO::Uncompress::Bunzip2' => { Inverse => 'IO::Compress::Bzip2', + Error => 'Bunzip2Error', + TopLevel => 'bunzip2', + Raw => 0, + }, + + 'IO::Compress::Lzop' => { Inverse => 'IO::Uncompress::UnLzop', + Error => 'LzopError', + TopLevel => 'lzop', + Raw => 0, + }, + 'IO::Uncompress::UnLzop' => { Inverse => 'IO::Compress::Lzop', + Error => 'UnLzopError', + TopLevel => 'unlzop', + Raw => 0, + }, + + 'IO::Compress::Lzf' => { Inverse => 'IO::Uncompress::UnLzf', + Error => 'LzfError', + TopLevel => 'lzf', + Raw => 0, + }, + 'IO::Uncompress::UnLzf' => { Inverse => 'IO::Compress::Lzf', + Error => 'UnLzfError', + TopLevel => 'unlzf', + Raw => 0, + }, + + 'IO::Compress::Lzma' => { Inverse => 'IO::Uncompress::UnLzma', + Error => 'LzmaError', + TopLevel => 'lzma', + Raw => 1, + }, + 'IO::Uncompress::UnLzma' => { Inverse => 'IO::Compress::Lzma', + Error => 'UnLzmaError', + TopLevel => 'unlzma', + Raw => 1, + }, + + 'IO::Compress::Xz' => { Inverse => 'IO::Uncompress::UnXz', + Error => 'XzError', + TopLevel => 'xz', + Raw => 0, + }, + 'IO::Uncompress::UnXz' => { Inverse => 'IO::Compress::Xz', + Error => 'UnXzError', + TopLevel => 'unxz', + Raw => 0, + }, + + 'IO::Compress::PPMd' => { Inverse => 'IO::Uncompress::UnPPMd', + Error => 'PPMdError', + TopLevel => 'ppmd', + Raw => 0, + }, + 'IO::Uncompress::UnPPMd' => { Inverse => 'IO::Compress::PPMd', + Error => 'UnPPMdError', + TopLevel => 'unppmd', + Raw => 0, + }, + + 'IO::Compress::DummyComp' => { Inverse => 'IO::Uncompress::DummyUnComp', + Error => 'DummyCompError', + TopLevel => 'dummycomp', + Raw => 0, + }, + 'IO::Uncompress::DummyUnComp' => { Inverse => 'IO::Compress::DummyComp', + Error => 'DummyUnCompError', + TopLevel => 'dummyunComp', + Raw => 0, + }, +); + + +for my $key (keys %TOP) { - my $class = shift; - my %raw = map { $_ => 1 } qw( RawDeflate ); + no strict; + no warnings; + $TOP{$key}{Error} = \${ $key . '::' . $TOP{$key}{Error} }; + $TOP{$key}{TopLevel} = $key . '::' . $TOP{$key}{TopLevel} ; - return defined $raw{$class}; + # Silence used once warning in really old perl + my $dummy = \${ $key . '::' . $TOP{$key}{Error} }; + + #$TOP{$key . "::" . $TOP{$key}{TopLevel} } = $TOP{$key}; } sub uncompressBuffer @@ -216,159 +368,43 @@ sub uncompressBuffer my $compWith = shift ; my $buffer = shift ; - my %mapping = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Gzip::gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::Deflate::deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::RawDeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::RawDeflate::rawdeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::Bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Bzip2::bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Zip::zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf' , - 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf', - 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd' , - 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd', - 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', - 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp', - ); my $out ; - my $obj = $mapping{$compWith}->new( \$buffer, -Append => 1); + my $obj = $TOP{$compWith}{Inverse}->new( \$buffer, -Append => 1); 1 while $obj->read($out) > 0 ; return $out ; } -my %ErrorMap = ( 'IO::Compress::Gzip' => \$IO::Compress::Gzip::GzipError, - 'IO::Compress::Gzip::gzip' => \$IO::Compress::Gzip::GzipError, - 'IO::Uncompress::Gunzip' => \$IO::Uncompress::Gunzip::GunzipError, - 'IO::Uncompress::Gunzip::gunzip' => \$IO::Uncompress::Gunzip::GunzipError, - 'IO::Uncompress::Inflate' => \$IO::Uncompress::Inflate::InflateError, - 'IO::Uncompress::Inflate::inflate' => \$IO::Uncompress::Inflate::InflateError, - 'IO::Compress::Deflate' => \$IO::Compress::Deflate::DeflateError, - 'IO::Compress::Deflate::deflate' => \$IO::Compress::Deflate::DeflateError, - 'IO::Uncompress::RawInflate' => \$IO::Uncompress::RawInflate::RawInflateError, - 'IO::Uncompress::RawInflate::rawinflate' => \$IO::Uncompress::RawInflate::RawInflateError, - 'IO::Uncompress::AnyInflate' => \$IO::Uncompress::AnyInflate::AnyInflateError, - 'IO::Uncompress::AnyInflate::anyinflate' => \$IO::Uncompress::AnyInflate::AnyInflateError, - 'IO::Uncompress::AnyUncompress' => \$IO::Uncompress::AnyUncompress::AnyUncompressError, - 'IO::Uncompress::AnyUncompress::anyUncompress' => \$IO::Uncompress::AnyUncompress::AnyUncompressError, - 'IO::Compress::RawDeflate' => \$IO::Compress::RawDeflate::RawDeflateError, - 'IO::Compress::RawDeflate::rawdeflate' => \$IO::Compress::RawDeflate::RawDeflateError, - 'IO::Compress::Bzip2' => \$IO::Compress::Bzip2::Bzip2Error, - 'IO::Compress::Bzip2::bzip2' => \$IO::Compress::Bzip2::Bzip2Error, - 'IO::Uncompress::Bunzip2' => \$IO::Uncompress::Bunzip2::Bunzip2Error, - 'IO::Uncompress::Bunzip2::bunzip2' => \$IO::Uncompress::Bunzip2::Bunzip2Error, - 'IO::Compress::Zip' => \$IO::Compress::Zip::ZipError, - 'IO::Compress::Zip::zip' => \$IO::Compress::Zip::ZipError, - 'IO::Uncompress::Unzip' => \$IO::Uncompress::Unzip::UnzipError, - 'IO::Uncompress::Unzip::unzip' => \$IO::Uncompress::Unzip::UnzipError, - 'IO::Compress::Lzop' => \$IO::Compress::Lzop::LzopError, - 'IO::Compress::Lzop::lzop' => \$IO::Compress::Lzop::LzopError, - 'IO::Uncompress::UnLzop' => \$IO::Uncompress::UnLzop::UnLzopError, - 'IO::Uncompress::UnLzop::unlzop' => \$IO::Uncompress::UnLzop::UnLzopError, - 'IO::Compress::Lzf' => \$IO::Compress::Lzf::LzfError, - 'IO::Compress::Lzf::lzf' => \$IO::Compress::Lzf::LzfError, - 'IO::Uncompress::UnLzf' => \$IO::Uncompress::UnLzf::UnLzfError, - 'IO::Uncompress::UnLzf::unlzf' => \$IO::Uncompress::UnLzf::UnLzfError, - 'IO::Compress::PPMd' => \$IO::Compress::PPMd::PPMdError, - 'IO::Compress::PPMd::ppmd' => \$IO::Compress::PPMd::PPMdError, - 'IO::Uncompress::UnPPMd' => \$IO::Uncompress::UnPPMd::UnPPMdError, - 'IO::Uncompress::UnPPMd::unppmd' => \$IO::Uncompress::UnPPMd::UnPPMdError, - - 'IO::Compress::DummyComp' => \$IO::Compress::DummyComp::DummyCompError, - 'IO::Compress::DummyComp::dummycomp'=> \$IO::Compress::DummyComp::DummyCompError, - 'IO::Uncompress::DummyUncomp' => \$IO::Uncompress::DummyUncomp::DummyUncompError, - 'IO::Uncompress::DummyUncomp::dummyuncomp' => \$IO::Uncompress::DummyUncomp::DummyUncompError, - ); - -my %TopFuncMap = ( 'IO::Compress::Gzip' => 'IO::Compress::Gzip::gzip', - 'IO::Uncompress::Gunzip' => 'IO::Uncompress::Gunzip::gunzip', - - 'IO::Compress::Deflate' => 'IO::Compress::Deflate::deflate', - 'IO::Uncompress::Inflate' => 'IO::Uncompress::Inflate::inflate', - - 'IO::Compress::RawDeflate' => 'IO::Compress::RawDeflate::rawdeflate', - 'IO::Uncompress::RawInflate' => 'IO::Uncompress::RawInflate::rawinflate', - - 'IO::Uncompress::AnyInflate' => 'IO::Uncompress::AnyInflate::anyinflate', - 'IO::Uncompress::AnyUncompress' => 'IO::Uncompress::AnyUncompress::anyuncompress', - - 'IO::Compress::Bzip2' => 'IO::Compress::Bzip2::bzip2', - 'IO::Uncompress::Bunzip2' => 'IO::Uncompress::Bunzip2::bunzip2', - - 'IO::Compress::Zip' => 'IO::Compress::Zip::zip', - 'IO::Uncompress::Unzip' => 'IO::Uncompress::Unzip::unzip', - 'IO::Compress::Lzop' => 'IO::Compress::Lzop::lzop', - 'IO::Uncompress::UnLzop' => 'IO::Uncompress::UnLzop::unlzop', - 'IO::Compress::Lzf' => 'IO::Compress::Lzf::lzf', - 'IO::Uncompress::UnLzf' => 'IO::Uncompress::UnLzf::unlzf', - 'IO::Compress::PPMd' => 'IO::Compress::PPMd::ppmd', - 'IO::Uncompress::UnPPMd' => 'IO::Uncompress::UnPPMd::unppmd', - 'IO::Compress::DummyComp' => 'IO::Compress::DummyComp::dummyuncomp', - 'IO::Uncompress::DummyUncomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', - ); - - %TopFuncMap = map { ($_ => $TopFuncMap{$_}, - $TopFuncMap{$_} => $TopFuncMap{$_}) } - keys %TopFuncMap ; - - #%TopFuncMap = map { ($_ => \&{ $TopFuncMap{$_} ) } - #keys %TopFuncMap ; - - -my %inverse = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Gzip::gzip' => 'IO::Uncompress::Gunzip::gunzip', - 'IO::Compress::Deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::Deflate::deflate' => 'IO::Uncompress::Inflate::inflate', - 'IO::Compress::RawDeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::RawDeflate::rawdeflate' => 'IO::Uncompress::RawInflate::rawinflate', - 'IO::Compress::Bzip2::bzip2' => 'IO::Uncompress::Bunzip2::bunzip2', - 'IO::Compress::Bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Zip::zip' => 'IO::Uncompress::Unzip::unzip', - 'IO::Compress::Zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop::unlzop', - 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf::unlzf', - 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf', - 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd::unppmd', - 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd', - 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', - 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', - ); - -%inverse = map { ($_ => $inverse{$_}, $inverse{$_} => $_) } keys %inverse; sub getInverse { my $class = shift ; - return $inverse{$class} ; + return $TOP{$class}{Inverse}; } sub getErrorRef { my $class = shift ; - return $ErrorMap{$class} ; + return $TOP{$class}{Error}; } sub getTopFuncRef { my $class = shift ; - return \&{ $TopFuncMap{$class} } ; + die "Cannot find $class" + if ! defined $TOP{$class}{TopLevel}; + return \&{ $TOP{$class}{TopLevel} } ; } sub getTopFuncName { my $class = shift ; - return $TopFuncMap{$class} ; + return $TOP{$class}{TopLevel} ; } sub compressBuffer @@ -376,32 +412,11 @@ sub compressBuffer my $compWith = shift ; my $buffer = shift ; - my %mapping = ( 'IO::Uncompress::Gunzip' => 'IO::Compress::Gzip', - 'IO::Uncompress::Gunzip::gunzip' => 'IO::Compress::Gzip', - 'IO::Uncompress::Inflate' => 'IO::Compress::Deflate', - 'IO::Uncompress::Inflate::inflate' => 'IO::Compress::Deflate', - 'IO::Uncompress::RawInflate' => 'IO::Compress::RawDeflate', - 'IO::Uncompress::RawInflate::rawinflate' => 'IO::Compress::RawDeflate', - 'IO::Uncompress::Bunzip2' => 'IO::Compress::Bzip2', - 'IO::Uncompress::Bunzip2::bunzip2' => 'IO::Compress::Bzip2', - 'IO::Uncompress::Unzip' => 'IO::Compress::Zip', - 'IO::Uncompress::Unzip::unzip' => 'IO::Compress::Zip', - 'IO::Uncompress::UnLzop' => 'IO::Compress::Lzop', - 'IO::Uncompress::UnLzop::unlzop' => 'IO::Compress::Lzop', - 'IO::Uncompress::UnLzp' => 'IO::Compress::Lzf', - 'IO::Uncompress::UnLzf::unlzf' => 'IO::Compress::Lzf', - 'IO::Uncompress::UnPPMd' => 'IO::Compress::PPMd', - 'IO::Uncompress::UnPPMd::unppmd' => 'IO::Compress::PPMd', - 'IO::Uncompress::AnyInflate' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyInflate::anyinflate' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyUncompress' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyUncompress::anyuncompress' => 'IO::Compress::Gzip', - 'IO::Uncompress::DummyUncomp' => 'IO::Compress::DummyComp', - 'IO::Uncompress::DummyUncomp::dummyuncomp'=> 'IO::Compress::DummyComp', - ); my $out ; - my $obj = $mapping{$compWith}->new( \$out); + die "Cannot find $compWith" + if ! defined $TOP{$compWith}{Inverse}; + my $obj = $TOP{$compWith}{Inverse}->new( \$out); $obj->write($buffer) ; $obj->close(); return $out ; @@ -584,7 +599,7 @@ sub mkErr $file = quotemeta($file); - return "/$string\\s+at $file line $line/" if $] >= 5.006 ; + #return "/$string\\s+at $file line $line/" if $] >= 5.006 ; return "/$string\\s+at /" ; } @@ -592,7 +607,7 @@ sub mkEvalErr { my $string = shift ; - return "/$string\\s+at \\(eval /" if $] > 5.006 ; + #return "/$string\\s+at \\(eval /" if $] > 5.006 ; return "/$string\\s+at /" ; } diff --git a/ext/IO-Compress/Changes b/ext/IO-Compress/Changes index 8464740a9c..6460a72849 100644 --- a/ext/IO-Compress/Changes +++ b/ext/IO-Compress/Changes @@ -1,6 +1,48 @@ CHANGES ------- + 2.021 30 August 2009 + + + * IO::Compress::Base.pm + - Less warnnings when reading from a closed filehandle. + [RT# 48350] + - Fixed minor typo in an error message. + [RT# 39719] + + * Makefile.PL + The PREREQ_PM dependency on Scalar::Util got dropped when + IO-Compress was created in 2.017. + [RT# 47509] + + * IO::Compress::Zip.pm + - Removed restriction that zip64 is only supported in streaming + mode. + - The "version made by" and "extract" fields in the zip64 end + central record were swapped. + - In the End Central Header record the "offset to the start of the + central directory" will now always be set to 0xFFFFFFFF when + zip64 is enabled. + - In the End Central Header record the "total entries in the + central directory" field will be set to 0xFFFF if zip64 is + enabled AND there are more than 0xFFFF entries present. + + * IO::Uncompress::Unzip.pm + - Don't consume lots of memory when walking a zip file. This makes + life more bearable when dealing with zip64. + + * Compress::Zlib.pm + - documented that memGunzip cannot cope with concatenated gzip data + streams. + + * Changed test harness so that it can cope with PERL5OPT=-MCarp=verbose + [RT# 47225] + + * IO::Compress::Gzip::Constants.pm + - GZIP_FEXTRA_MAX_SIZE was set to 0xFF. Should be 0xFFFF. This + issue came up when attempting to unzip a file created by MS + Office 2007. + 2.020 3 June 2009 * IO::Uncompress::Base.pm diff --git a/ext/IO-Compress/Makefile.PL b/ext/IO-Compress/Makefile.PL index bab8f395df..64cdd29dac 100644 --- a/ext/IO-Compress/Makefile.PL +++ b/ext/IO-Compress/Makefile.PL @@ -3,7 +3,7 @@ use strict ; require 5.004 ; -$::VERSION = '2.020' ; +$::VERSION = '2.021' ; use private::MakeUtil; use ExtUtils::MakeMaker 5.16 ; @@ -25,6 +25,7 @@ WriteMakefile( ? () : (PREREQ_PM => { 'Compress::Raw::Bzip2' => $::VERSION, 'Compress::Raw::Zlib' => $::VERSION, + 'Scalar::Util' => 0, $] >= 5.005 && $] < 5.006 ? ('File::BSDGlob' => 0) : () } diff --git a/ext/IO-Compress/README b/ext/IO-Compress/README index 4436fdf7a3..67cc0c6ed4 100644 --- a/ext/IO-Compress/README +++ b/ext/IO-Compress/README @@ -1,9 +1,9 @@ IO-Compress - Version 2.020 + Version 2.021 - 3rd June 2009 + 30th August 2009 Copyright (c) 1995-2009 Paul Marquess. All rights reserved. This program is free software; you can redistribute it @@ -89,7 +89,7 @@ To help me help you, I need all of the following information: If you haven't installed IO-Compress then search IO::Compress::Gzip.pm for a line like this: - $VERSION = "2.020" ; + $VERSION = "2.021" ; 2. If you are having problems building IO-Compress, send me a complete log of what happened. Start by unpacking the IO-Compress diff --git a/ext/IO-Compress/lib/Compress/Zlib.pm b/ext/IO-Compress/lib/Compress/Zlib.pm index c4137c49ff..0a611039b8 100644 --- a/ext/IO-Compress/lib/Compress/Zlib.pm +++ b/ext/IO-Compress/lib/Compress/Zlib.pm @@ -8,17 +8,17 @@ use Carp ; use IO::Handle ; use Scalar::Util qw(dualvar); -use IO::Compress::Base::Common 2.020 ; -use Compress::Raw::Zlib 2.020 ; -use IO::Compress::Gzip 2.020 ; -use IO::Uncompress::Gunzip 2.020 ; +use IO::Compress::Base::Common 2.021 ; +use Compress::Raw::Zlib 2.021 ; +use IO::Compress::Gzip 2.021 ; +use IO::Uncompress::Gunzip 2.021 ; use strict ; use warnings ; use bytes ; our ($VERSION, $XS_VERSION, @ISA, @EXPORT, $AUTOLOAD); -$VERSION = '2.020'; +$VERSION = '2.021'; $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -452,7 +452,7 @@ sub inflate package Compress::Zlib ; -use IO::Compress::Gzip::Constants 2.020 ; +use IO::Compress::Gzip::Constants 2.021 ; sub memGzip($) { @@ -994,6 +994,11 @@ returns undef. The C<$buffer> parameter can either be a scalar or a scalar reference. The contents of the C<$buffer> parameter are destroyed after calling this function. +If C<$buffer> consists of multiple concatenated gzip data streams only the +first will be uncompressed. Use C with the C option in +the C module if you need to deal with concatenated +data streams. + See L for an alternative way to carry out in-memory gzip uncompression. diff --git a/ext/IO-Compress/lib/IO/Compress/Adapter/Bzip2.pm b/ext/IO-Compress/lib/IO/Compress/Adapter/Bzip2.pm index 65c18bd2bb..a56331d2cb 100644 --- a/ext/IO-Compress/lib/IO/Compress/Adapter/Bzip2.pm +++ b/ext/IO-Compress/lib/IO/Compress/Adapter/Bzip2.pm @@ -4,13 +4,13 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status); +use IO::Compress::Base::Common 2.021 qw(:Status); #use Compress::Bzip2 ; -use Compress::Raw::Bzip2 2.020 ; +use Compress::Raw::Bzip2 2.021 ; our ($VERSION); -$VERSION = '2.020'; +$VERSION = '2.021'; sub mkCompObject { diff --git a/ext/IO-Compress/lib/IO/Compress/Adapter/Deflate.pm b/ext/IO-Compress/lib/IO/Compress/Adapter/Deflate.pm index db30dc20af..525868093c 100644 --- a/ext/IO-Compress/lib/IO/Compress/Adapter/Deflate.pm +++ b/ext/IO-Compress/lib/IO/Compress/Adapter/Deflate.pm @@ -4,12 +4,12 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status); +use IO::Compress::Base::Common 2.021 qw(:Status); -use Compress::Raw::Zlib 2.020 qw(Z_OK Z_FINISH MAX_WBITS) ; +use Compress::Raw::Zlib 2.021 qw(Z_OK Z_FINISH MAX_WBITS) ; our ($VERSION); -$VERSION = '2.020'; +$VERSION = '2.021'; sub mkCompObject { diff --git a/ext/IO-Compress/lib/IO/Compress/Adapter/Identity.pm b/ext/IO-Compress/lib/IO/Compress/Adapter/Identity.pm index 4314037601..c980e6c343 100644 --- a/ext/IO-Compress/lib/IO/Compress/Adapter/Identity.pm +++ b/ext/IO-Compress/lib/IO/Compress/Adapter/Identity.pm @@ -4,10 +4,10 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status); +use IO::Compress::Base::Common 2.021 qw(:Status); our ($VERSION); -$VERSION = '2.020'; +$VERSION = '2.021'; sub mkCompObject { diff --git a/ext/IO-Compress/lib/IO/Compress/Base.pm b/ext/IO-Compress/lib/IO/Compress/Base.pm index 98bf5b4eb7..7b558eafeb 100644 --- a/ext/IO-Compress/lib/IO/Compress/Base.pm +++ b/ext/IO-Compress/lib/IO/Compress/Base.pm @@ -6,7 +6,7 @@ require 5.004 ; use strict ; use warnings; -use IO::Compress::Base::Common 2.020 ; +use IO::Compress::Base::Common 2.021 ; use IO::File ; use Scalar::Util qw(blessed readonly); @@ -20,7 +20,7 @@ use bytes; our (@ISA, $VERSION); @ISA = qw(Exporter IO::File); -$VERSION = '2.020'; +$VERSION = '2.021'; #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. @@ -486,14 +486,14 @@ sub _wr2 my $status ; my $buff ; my $count = 0 ; - while (($status = read($fh, $buff, 16 * 1024)) > 0) { + while ($status = read($fh, $buff, 16 * 1024)) { $count += length $buff; defined $self->syswrite($buff, @_) or return undef ; } return $self->saveErrorString(undef, $!, $!) - if $status < 0 ; + if ! defined $status ; if ( (!$isFilehandle || *$self->{AutoClose}) && $input ne '-') { diff --git a/ext/IO-Compress/lib/IO/Compress/Base/Common.pm b/ext/IO-Compress/lib/IO/Compress/Base/Common.pm index 060921c7f9..7981585d49 100644 --- a/ext/IO-Compress/lib/IO/Compress/Base/Common.pm +++ b/ext/IO-Compress/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.020'; +$VERSION = '2.021'; @EXPORT = qw( isaFilehandle isaFilename whatIsInput whatIsOutput isaFileGlobString cleanFileGlobString oneTarget @@ -656,7 +656,7 @@ sub IO::Compress::Base::Parameters::parse if (@Bad) { my ($bad) = join(", ", @Bad) ; - return $self->setError("unknown key value(s) @Bad") ; + return $self->setError("unknown key value(s) $bad") ; } return 1; @@ -816,6 +816,7 @@ sub IO::Compress::Base::Parameters::clone package U64; use constant MAX32 => 0xFFFFFFFF ; +use constant HI_1 => MAX32 + 1 ; use constant LOW => 0 ; use constant HIGH => 1; @@ -883,6 +884,14 @@ sub get32bit return $self->[LOW]; } +sub get64bit +{ + my $self = shift; + # Not using << here because the result will still be + # a 32-bit value on systems where int size is 32-bits + return $self->[HIGH] * HI_1 + $self->[LOW]; +} + sub add { my $self = shift; @@ -902,6 +911,7 @@ sub add else { $self->[LOW] += $value ; } + } sub equal @@ -913,6 +923,12 @@ sub equal $self->[HIGH] == $other->[HIGH] ; } +sub is64bit +{ + my $self = shift; + return $self->[HIGH] > 0 ; +} + sub getPacked_V64 { my $self = shift; diff --git a/ext/IO-Compress/lib/IO/Compress/Bzip2.pm b/ext/IO-Compress/lib/IO/Compress/Bzip2.pm index dcf337f37d..e5f86b2f36 100644 --- a/ext/IO-Compress/lib/IO/Compress/Bzip2.pm +++ b/ext/IO-Compress/lib/IO/Compress/Bzip2.pm @@ -5,16 +5,16 @@ use warnings; use bytes; require Exporter ; -use IO::Compress::Base 2.020 ; +use IO::Compress::Base 2.021 ; -use IO::Compress::Base::Common 2.020 qw(createSelfTiedObject); -use IO::Compress::Adapter::Bzip2 2.020 ; +use IO::Compress::Base::Common 2.021 qw(createSelfTiedObject); +use IO::Compress::Adapter::Bzip2 2.021 ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $Bzip2Error); -$VERSION = '2.020'; +$VERSION = '2.021'; $Bzip2Error = ''; @ISA = qw(Exporter IO::Compress::Base); @@ -51,7 +51,7 @@ sub getExtraParams { my $self = shift ; - use IO::Compress::Base::Common 2.020 qw(:Parse); + use IO::Compress::Base::Common 2.021 qw(:Parse); return ( 'BlockSize100K' => [0, 1, Parse_unsigned, 1], diff --git a/ext/IO-Compress/lib/IO/Compress/Deflate.pm b/ext/IO-Compress/lib/IO/Compress/Deflate.pm index 821576bece..7ee0a53997 100644 --- a/ext/IO-Compress/lib/IO/Compress/Deflate.pm +++ b/ext/IO-Compress/lib/IO/Compress/Deflate.pm @@ -6,16 +6,16 @@ use bytes; require Exporter ; -use IO::Compress::RawDeflate 2.020 ; +use IO::Compress::RawDeflate 2.021 ; -use Compress::Raw::Zlib 2.020 ; -use IO::Compress::Zlib::Constants 2.020 ; -use IO::Compress::Base::Common 2.020 qw(createSelfTiedObject); +use Compress::Raw::Zlib 2.021 ; +use IO::Compress::Zlib::Constants 2.021 ; +use IO::Compress::Base::Common 2.021 qw(createSelfTiedObject); our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $DeflateError); -$VERSION = '2.020'; +$VERSION = '2.021'; $DeflateError = ''; @ISA = qw(Exporter IO::Compress::RawDeflate); diff --git a/ext/IO-Compress/lib/IO/Compress/Gzip.pm b/ext/IO-Compress/lib/IO/Compress/Gzip.pm index d3d38ea87f..5ddfad20b9 100644 --- a/ext/IO-Compress/lib/IO/Compress/Gzip.pm +++ b/ext/IO-Compress/lib/IO/Compress/Gzip.pm @@ -8,12 +8,12 @@ use warnings; use bytes; -use IO::Compress::RawDeflate 2.020 ; +use IO::Compress::RawDeflate 2.021 ; -use Compress::Raw::Zlib 2.020 ; -use IO::Compress::Base::Common 2.020 qw(:Status :Parse createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.020 ; -use IO::Compress::Zlib::Extra 2.020 ; +use Compress::Raw::Zlib 2.021 ; +use IO::Compress::Base::Common 2.021 qw(:Status :Parse createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.021 ; +use IO::Compress::Zlib::Extra 2.021 ; BEGIN { @@ -27,7 +27,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $GzipError); -$VERSION = '2.020'; +$VERSION = '2.021'; $GzipError = '' ; @ISA = qw(Exporter IO::Compress::RawDeflate); diff --git a/ext/IO-Compress/lib/IO/Compress/Gzip/Constants.pm b/ext/IO-Compress/lib/IO/Compress/Gzip/Constants.pm index 4e1ce4e60a..826183680e 100644 --- a/ext/IO-Compress/lib/IO/Compress/Gzip/Constants.pm +++ b/ext/IO-Compress/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.020'; +$VERSION = '2.021'; @ISA = qw(Exporter); @@ -84,7 +84,7 @@ use constant GZIP_XFL_DEFAULT => 0x00 ; use constant GZIP_MTIME_DEFAULT => 0x00 ; use constant GZIP_FEXTRA_HEADER_SIZE => 2 ; -use constant GZIP_FEXTRA_MAX_SIZE => 0xFF ; +use constant GZIP_FEXTRA_MAX_SIZE => 0xFFFF ; use constant GZIP_FEXTRA_SUBFIELD_ID_SIZE => 2 ; use constant GZIP_FEXTRA_SUBFIELD_LEN_SIZE => 2 ; use constant GZIP_FEXTRA_SUBFIELD_HEADER_SIZE => GZIP_FEXTRA_SUBFIELD_ID_SIZE + diff --git a/ext/IO-Compress/lib/IO/Compress/RawDeflate.pm b/ext/IO-Compress/lib/IO/Compress/RawDeflate.pm index 441ab4854e..ad642dbfa5 100644 --- a/ext/IO-Compress/lib/IO/Compress/RawDeflate.pm +++ b/ext/IO-Compress/lib/IO/Compress/RawDeflate.pm @@ -7,16 +7,16 @@ use warnings; use bytes; -use IO::Compress::Base 2.020 ; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); -use IO::Compress::Adapter::Deflate 2.020 ; +use IO::Compress::Base 2.021 ; +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); +use IO::Compress::Adapter::Deflate 2.021 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %DEFLATE_CONSTANTS, %EXPORT_TAGS, $RawDeflateError); -$VERSION = '2.020'; +$VERSION = '2.021'; $RawDeflateError = ''; @ISA = qw(Exporter IO::Compress::Base); @@ -142,8 +142,8 @@ sub getZlibParams { my $self = shift ; - use IO::Compress::Base::Common 2.020 qw(:Parse); - use Compress::Raw::Zlib 2.020 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); + use IO::Compress::Base::Common 2.021 qw(:Parse); + use Compress::Raw::Zlib 2.021 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); return ( diff --git a/ext/IO-Compress/lib/IO/Compress/Zip.pm b/ext/IO-Compress/lib/IO/Compress/Zip.pm index 2b176dce21..563b10d9bf 100644 --- a/ext/IO-Compress/lib/IO/Compress/Zip.pm +++ b/ext/IO-Compress/lib/IO/Compress/Zip.pm @@ -4,27 +4,27 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); -use IO::Compress::RawDeflate 2.020 ; -use IO::Compress::Adapter::Deflate 2.020 ; -use IO::Compress::Adapter::Identity 2.020 ; -use IO::Compress::Zlib::Extra 2.020 ; -use IO::Compress::Zip::Constants 2.020 ; +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); +use IO::Compress::RawDeflate 2.021 ; +use IO::Compress::Adapter::Deflate 2.021 ; +use IO::Compress::Adapter::Identity 2.021 ; +use IO::Compress::Zlib::Extra 2.021 ; +use IO::Compress::Zip::Constants 2.021 ; -use Compress::Raw::Zlib 2.020 qw(crc32) ; +use Compress::Raw::Zlib 2.021 qw(crc32) ; BEGIN { eval { require IO::Compress::Adapter::Bzip2 ; - import IO::Compress::Adapter::Bzip2 2.020 ; + import IO::Compress::Adapter::Bzip2 2.021 ; require IO::Compress::Bzip2 ; - import IO::Compress::Bzip2 2.020 ; + import IO::Compress::Bzip2 2.021 ; + } ; + eval { require IO::Compress::Adapter::Lzma ; + import IO::Compress::Adapter::Lzma 2.020 ; + require IO::Compress::Lzma ; + import IO::Compress::Lzma 2.020 ; } ; -# eval { require IO::Compress::Adapter::Lzma ; -# import IO::Compress::Adapter::Lzma 2.018 ; -# require IO::Compress::Lzma ; -# import IO::Compress::Lzma 2.018 ; -# } ; } @@ -32,7 +32,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $ZipError); -$VERSION = '2.020'; +$VERSION = '2.021'; $ZipError = ''; @ISA = qw(Exporter IO::Compress::RawDeflate); @@ -40,7 +40,7 @@ $ZipError = ''; %EXPORT_TAGS = %IO::Compress::RawDeflate::DEFLATE_CONSTANTS ; push @{ $EXPORT_TAGS{all} }, @EXPORT_OK ; -$EXPORT_TAGS{zip_method} = [qw( ZIP_CM_STORE ZIP_CM_DEFLATE ZIP_CM_BZIP2 )]; +$EXPORT_TAGS{zip_method} = [qw( ZIP_CM_STORE ZIP_CM_DEFLATE ZIP_CM_BZIP2 ZIP_CM_LZMA)]; push @{ $EXPORT_TAGS{all} }, @{ $EXPORT_TAGS{zip_method} }; Exporter::export_ok_tags('all'); @@ -89,20 +89,22 @@ sub mkComp ); *$self->{ZipData}{CRC32} = crc32(undef); } -# elsif (*$self->{ZipData}{Method} == ZIP_CM_LZMA) { -# ($obj, $errstr, $errno) = IO::Compress::Adapter::Lzma::mkCompObject( -# ); -# *$self->{ZipData}{CRC32} = crc32(undef); -# } + elsif (*$self->{ZipData}{Method} == ZIP_CM_LZMA) { + ($obj, $errstr, $errno) = IO::Compress::Adapter::Lzma::mkCompObject(); + *$self->{ZipData}{CRC32} = crc32(undef); + } return $self->saveErrorString(undef, $errstr, $errno) if ! defined $obj; - if (! defined *$self->{ZipData}{StartOffset}) { - *$self->{ZipData}{StartOffset} = 0; + if (! defined *$self->{ZipData}{SizesOffset}) { + *$self->{ZipData}{SizesOffset} = 0; *$self->{ZipData}{Offset} = new U64 ; } + *$self->{ZipData}{AnyZip64} = 0 + if ! defined *$self->{ZipData}{AnyZip64} ; + return $obj; } @@ -134,7 +136,8 @@ sub mkHeader my $self = shift; my $param = shift ; - *$self->{ZipData}{StartOffset} = *$self->{ZipData}{Offset}->get32bit() ; + + *$self->{ZipData}{LocalHdrOffset} = U64::clone(*$self->{ZipData}{Offset}); my $filename = ''; $filename = $param->value('Name') || ''; @@ -162,12 +165,7 @@ sub mkHeader my $x = ''; $x .= pack "V V", 0, 0 ; # uncompressedLength $x .= pack "V V", 0, 0 ; # compressedLength - $x .= *$self->{ZipData}{Offset}->getPacked_V64() ; # offset to local hdr - $x .= pack "V", 0 ; # disk no - - $x = IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_ZIP64, $x); - $extra .= $x; - $ctlExtra .= $x; + $extra .= IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_ZIP64, $x); } if (! $param->value('Minimal')) { @@ -227,6 +225,18 @@ sub mkHeader $hdr .= pack 'v', length $extra ; # extra length $hdr .= $filename ; + + # Remember the offset for the compressed & uncompressed lengths in the + # local header. + if (*$self->{ZipData}{Zip64}) { + *$self->{ZipData}{SizesOffset} = *$self->{ZipData}{Offset}->get64bit() + + length($hdr) + 4 ; + } + else { + *$self->{ZipData}{SizesOffset} = *$self->{ZipData}{Offset}->get64bit() + + 18; + } + $hdr .= $extra ; @@ -242,20 +252,25 @@ sub mkHeader $ctl .= pack 'V', $empty ; # compressed length $ctl .= pack 'V', $empty ; # uncompressed length $ctl .= pack 'v', length $filename ; # filename length + + *$self->{ZipData}{ExtraOffset} = length $ctl; + *$self->{ZipData}{ExtraSize} = length $ctlExtra ; + $ctl .= pack 'v', length $ctlExtra ; # extra length $ctl .= pack 'v', length $comment ; # file comment length $ctl .= pack 'v', 0 ; # disk number start $ctl .= pack 'v', $ifa ; # internal file attributes $ctl .= pack 'V', $extFileAttr ; # external file attributes - if (! *$self->{ZipData}{Zip64}) { - $ctl .= pack 'V', *$self->{ZipData}{Offset}->get32bit() ; # offset to local header + + # offset to local hdr + if (*$self->{ZipData}{LocalHdrOffset}->is64bit() ) { + $ctl .= pack 'V', 0xFFFFFFFF ; } else { - $ctl .= pack 'V', $empty ; # offset to local header + $ctl .= *$self->{ZipData}{LocalHdrOffset}->getPacked_V32() ; } $ctl .= $filename ; - *$self->{ZipData}{StartOffset64} = 4 + length $ctl; $ctl .= $ctlExtra ; $ctl .= $comment ; @@ -292,6 +307,8 @@ sub mkTrailer my $data = $crc32 . $sizes ; + my $xtrasize = *$self->{UnCompSize}->getPacked_V64() ; # Uncompressed size + $xtrasize .= *$self->{CompSize}->getPacked_V64() ; # Compressed size my $hdr = ''; @@ -300,17 +317,47 @@ sub mkTrailer $hdr .= $data ; } else { - $self->writeAt(*$self->{ZipData}{StartOffset} + 14, $data) + $self->writeAt(*$self->{ZipData}{LocalHdrOffset}->get64bit() + 14, $crc32) + or return undef; + $self->writeAt(*$self->{ZipData}{SizesOffset}, + *$self->{ZipData}{Zip64} ? $xtrasize : $sizes) or return undef; } - if (! *$self->{ZipData}{Zip64}) - { substr($ctl, 16, length $data) = $data } - else { - substr($ctl, 16, length $crc32) = $crc32 ; - my $s = *$self->{UnCompSize}->getPacked_V64() ; # Uncompressed size - $s .= *$self->{CompSize}->getPacked_V64() ; # Compressed size - substr($ctl, *$self->{ZipData}{StartOffset64}, length $s) = $s ; + # Central Header Record/Zip64 extended field + + substr($ctl, 16, length $crc32) = $crc32 ; + + my $x = ''; + + # uncompressed length + if (*$self->{UnCompSize}->is64bit() ) { + $x .= *$self->{UnCompSize}->getPacked_V64() ; + } else { + substr($ctl, 24, 4) = *$self->{UnCompSize}->getPacked_V32() ; + } + + # compressed length + if (*$self->{CompSize}->is64bit() ) { + $x .= *$self->{CompSize}->getPacked_V64() ; + } else { + substr($ctl, 20, 4) = *$self->{CompSize}->getPacked_V32() ; + } + + # Local Header offset + $x .= *$self->{ZipData}{LocalHdrOffset}->getPacked_V64() + if *$self->{ZipData}{LocalHdrOffset}->is64bit() ; + + # disk no - always zero, so don't need it + #$x .= pack "V", 0 ; + + if (length $x) { + my $xtra = IO::Compress::Zlib::Extra::mkSubField(ZIP_EXTRA_ID_ZIP64, $x); + $ctl .= $xtra ; + substr($ctl, *$self->{ZipData}{ExtraOffset}, 2) = + pack 'v', *$self->{ZipData}{ExtraSize} + length $xtra; + + *$self->{ZipData}{AnyZip64} = 1; } *$self->{ZipData}{Offset}->add(length($hdr)); @@ -335,12 +382,12 @@ sub mkFinalTrailer my $z64e = ''; - if ( *$self->{ZipData}{Zip64} ) { + if ( *$self->{ZipData}{AnyZip64} ) { my $v = *$self->{ZipData}{Version} ; my $mb = *$self->{ZipData}{MadeBy} ; - $z64e .= pack 'v', $v ; # Version made by - $z64e .= pack 'v', $mb ; # Version to extract + $z64e .= pack 'v', $mb ; # Version made by + $z64e .= pack 'v', $v ; # Version to extract $z64e .= pack 'V', 0 ; # number of disk $z64e .= pack 'V', 0 ; # number of disk with central dir $z64e .= U64::pack_V64 $entries ; # entries in central dir on this disk @@ -359,10 +406,9 @@ sub mkFinalTrailer $z64e .= *$self->{ZipData}{Offset}->getPacked_V64() ; # offset to end zip64 central dir $z64e .= pack 'V', 1 ; # Total number of disks - # TODO - fix these when info-zip 3 is fixed. - #$cd_len = - #$cd_offset = - $entries = 0xFFFF ; + $cd_offset = 0xFFFFFFFF ; + $cd_len = 0xFFFFFFFF if $cd_len >= 0xFFFFFFFF ; + $entries = 0xFFFF if $entries >= 0xFFFF ; } my $ecd = ''; @@ -415,12 +461,11 @@ sub ckParams $got->value("GID", $timeRef->[1]); } + *$self->{ZipData}{AnyZip64} = 1 + if $got->value('Zip64'); *$self->{ZipData}{Zip64} = $got->value('Zip64'); *$self->{ZipData}{Stream} = $got->value('Stream'); - return $self->saveErrorString(undef, "Zip64 only supported if Stream enabled") - if *$self->{ZipData}{Zip64} && ! *$self->{ZipData}{Stream} ; - my $method = $got->value('Method'); return $self->saveErrorString(undef, "Unknown Method '$method'") if ! defined $ZIP_CM_MIN_VERSIONS{$method}; @@ -429,9 +474,9 @@ sub ckParams if $method == ZIP_CM_BZIP2 and ! defined $IO::Compress::Adapter::Bzip2::VERSION; -# return $self->saveErrorString(undef, "Lzma not available") -# if $method == ZIP_CM_LZMA and -# ! defined $IO::Compress::Adapter::Lzma::VERSION; + return $self->saveErrorString(undef, "Lzma not available") + if $method == ZIP_CM_LZMA and + ! defined $IO::Compress::Adapter::Lzma::VERSION; *$self->{ZipData}{Method} = $method; @@ -467,8 +512,8 @@ sub getExtraParams { my $self = shift ; - use IO::Compress::Base::Common 2.020 qw(:Parse); - use Compress::Raw::Zlib 2.020 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); + use IO::Compress::Base::Common 2.021 qw(:Parse); + use Compress::Raw::Zlib 2.021 qw(Z_DEFLATED Z_DEFAULT_COMPRESSION Z_DEFAULT_STRATEGY); my @Bzip2 = (); @@ -1074,14 +1119,11 @@ Create a Zip64 zip file/buffer. This option should only be used if you want to store files larger than 4 Gig. If you intend to manipulate the Zip64 zip files created with this module -using an external zip/unzip make sure that it supports streaming Zip64. +using an external zip/unzip make sure that it supports Zip64. In particular, if you are using Info-Zip you need to have zip version 3.x or better to update a Zip64 archive and unzip version 6.x to read a zip64 -archive. At the time of writing both are beta status. - -When the C option is enabled, the C option I be -enabled as well. +archive. The default is 0. diff --git a/ext/IO-Compress/lib/IO/Compress/Zip/Constants.pm b/ext/IO-Compress/lib/IO/Compress/Zip/Constants.pm index 882e5afc8e..d16eb238ef 100644 --- a/ext/IO-Compress/lib/IO/Compress/Zip/Constants.pm +++ b/ext/IO-Compress/lib/IO/Compress/Zip/Constants.pm @@ -7,7 +7,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT, %ZIP_CM_MIN_VERSIONS); -$VERSION = '2.020'; +$VERSION = '2.021'; @ISA = qw(Exporter); diff --git a/ext/IO-Compress/lib/IO/Compress/Zlib/Constants.pm b/ext/IO-Compress/lib/IO/Compress/Zlib/Constants.pm index 8cf1cdc91a..d65fedc580 100644 --- a/ext/IO-Compress/lib/IO/Compress/Zlib/Constants.pm +++ b/ext/IO-Compress/lib/IO/Compress/Zlib/Constants.pm @@ -9,7 +9,7 @@ require Exporter; our ($VERSION, @ISA, @EXPORT); -$VERSION = '2.020'; +$VERSION = '2.021'; @ISA = qw(Exporter); diff --git a/ext/IO-Compress/lib/IO/Compress/Zlib/Extra.pm b/ext/IO-Compress/lib/IO/Compress/Zlib/Extra.pm index ded6c4fb08..72b4ddd370 100644 --- a/ext/IO-Compress/lib/IO/Compress/Zlib/Extra.pm +++ b/ext/IO-Compress/lib/IO/Compress/Zlib/Extra.pm @@ -8,9 +8,9 @@ use bytes; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS); -$VERSION = '2.020'; +$VERSION = '2.021'; -use IO::Compress::Gzip::Constants 2.020 ; +use IO::Compress::Gzip::Constants 2.021 ; sub ExtraFieldError { diff --git a/ext/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm b/ext/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm index 87459a2336..b2053aff10 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm @@ -4,12 +4,12 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status); +use IO::Compress::Base::Common 2.021 qw(:Status); -use Compress::Raw::Bzip2 2.020 ; +use Compress::Raw::Bzip2 2.021 ; our ($VERSION, @ISA); -$VERSION = '2.020'; +$VERSION = '2.021'; sub mkUncompObject { diff --git a/ext/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm b/ext/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm index 146b4c9564..0df174320a 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm @@ -4,13 +4,13 @@ use warnings; use strict; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status); +use IO::Compress::Base::Common 2.021 qw(:Status); our ($VERSION); -$VERSION = '2.020'; +$VERSION = '2.021'; -use Compress::Raw::Zlib 2.020 (); +use Compress::Raw::Zlib 2.021 (); sub mkUncompObject { diff --git a/ext/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm b/ext/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm index c8e9e17836..d03148c0b4 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm @@ -4,11 +4,11 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status); -use Compress::Raw::Zlib 2.020 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); +use IO::Compress::Base::Common 2.021 qw(:Status); +use Compress::Raw::Zlib 2.021 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS); our ($VERSION); -$VERSION = '2.020'; +$VERSION = '2.021'; diff --git a/ext/IO-Compress/lib/IO/Uncompress/AnyInflate.pm b/ext/IO-Compress/lib/IO/Uncompress/AnyInflate.pm index 2ae8876467..e8ffc5c15b 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/AnyInflate.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/AnyInflate.pm @@ -6,22 +6,22 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.021 qw(createSelfTiedObject); -use IO::Uncompress::Adapter::Inflate 2.020 (); +use IO::Uncompress::Adapter::Inflate 2.021 (); -use IO::Uncompress::Base 2.020 ; -use IO::Uncompress::Gunzip 2.020 ; -use IO::Uncompress::Inflate 2.020 ; -use IO::Uncompress::RawInflate 2.020 ; -use IO::Uncompress::Unzip 2.020 ; +use IO::Uncompress::Base 2.021 ; +use IO::Uncompress::Gunzip 2.021 ; +use IO::Uncompress::Inflate 2.021 ; +use IO::Uncompress::RawInflate 2.021 ; +use IO::Uncompress::Unzip 2.021 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyInflateError); -$VERSION = '2.020'; +$VERSION = '2.021'; $AnyInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -48,7 +48,7 @@ sub anyinflate sub getExtraParams { - use IO::Compress::Base::Common 2.020 qw(:Parse); + use IO::Compress::Base::Common 2.021 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } @@ -378,7 +378,7 @@ C option. =head2 Examples To read the contents of the file C and write the -compressed data to the file C. +uncompressed data to the file C. use strict ; use warnings ; diff --git a/ext/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm b/ext/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm index 4600d7ce61..cc1ba24b47 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/AnyUncompress.pm @@ -4,16 +4,16 @@ use strict; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(createSelfTiedObject); +use IO::Compress::Base::Common 2.021 qw(createSelfTiedObject); -use IO::Uncompress::Base 2.020 ; +use IO::Uncompress::Base 2.021 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $AnyUncompressError); -$VERSION = '2.020'; +$VERSION = '2.021'; $AnyUncompressError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -27,20 +27,22 @@ Exporter::export_ok_tags('all'); BEGIN { - eval ' use IO::Uncompress::Adapter::Inflate 2.020 ;'; - eval ' use IO::Uncompress::Adapter::Bunzip2 2.020 ;'; - eval ' use IO::Uncompress::Adapter::LZO 2.020 ;'; - eval ' use IO::Uncompress::Adapter::Lzf 2.020 ;'; - #eval ' use IO::Uncompress::Adapter::UnLzma 2.018 ;'; - - eval ' use IO::Uncompress::Bunzip2 2.020 ;'; - eval ' use IO::Uncompress::UnLzop 2.020 ;'; - eval ' use IO::Uncompress::Gunzip 2.020 ;'; - eval ' use IO::Uncompress::Inflate 2.020 ;'; - eval ' use IO::Uncompress::RawInflate 2.020 ;'; - eval ' use IO::Uncompress::Unzip 2.020 ;'; - eval ' use IO::Uncompress::UnLzf 2.020 ;'; - #eval ' use IO::Uncompress::UnLzma 2.018 ;'; + eval ' use IO::Uncompress::Adapter::Inflate 2.021 ;'; + eval ' use IO::Uncompress::Adapter::Bunzip2 2.021 ;'; + eval ' use IO::Uncompress::Adapter::LZO 2.021 ;'; + eval ' use IO::Uncompress::Adapter::Lzf 2.021 ;'; + eval ' use IO::Uncompress::Adapter::UnLzma 2.020 ;'; + eval ' use IO::Uncompress::Adapter::UnXz 2.020 ;'; + + eval ' use IO::Uncompress::Bunzip2 2.021 ;'; + eval ' use IO::Uncompress::UnLzop 2.021 ;'; + eval ' use IO::Uncompress::Gunzip 2.021 ;'; + eval ' use IO::Uncompress::Inflate 2.021 ;'; + eval ' use IO::Uncompress::RawInflate 2.021 ;'; + eval ' use IO::Uncompress::Unzip 2.021 ;'; + eval ' use IO::Uncompress::UnLzf 2.021 ;'; + eval ' use IO::Uncompress::UnLzma 2.018 ;'; + eval ' use IO::Uncompress::UnXz 2.018 ;'; } sub new @@ -58,7 +60,7 @@ sub anyuncompress sub getExtraParams { - use IO::Compress::Base::Common 2.020 qw(:Parse); + use IO::Compress::Base::Common 2.021 qw(:Parse); return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } @@ -124,6 +126,21 @@ sub mkUncomp # } # } + if (defined $IO::Uncompress::UnXz::VERSION and + $magic = $self->ckMagic('UnXz')) { + *$self->{Info} = $self->readHeader($magic) + or return undef ; + + my ($obj, $errstr, $errno) = IO::Uncompress::Adapter::UnXz::mkUncompObject(); + + return $self->saveErrorString(undef, $errstr, $errno) + if ! defined $obj; + + *$self->{Uncomp} = $obj; + + return 1; + } + if (defined $IO::Uncompress::Bunzip2::VERSION and $magic = $self->ckMagic('Bunzip2')) { *$self->{Info} = $self->readHeader($magic) @@ -464,7 +481,7 @@ C option. =head2 Examples To read the contents of the file C and write the -compressed data to the file C. +uncompressed data to the file C. use strict ; use warnings ; diff --git a/ext/IO-Compress/lib/IO/Uncompress/Base.pm b/ext/IO-Compress/lib/IO/Uncompress/Base.pm index 45072199dc..8459ce0e05 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Base.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Base.pm @@ -9,12 +9,12 @@ our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS); @ISA = qw(Exporter IO::File); -$VERSION = '2.020'; +$VERSION = '2.021'; use constant G_EOF => 0 ; use constant G_ERR => -1 ; -use IO::Compress::Base::Common 2.020 ; +use IO::Compress::Base::Common 2.021 ; #use Parse::Parameters ; use IO::File ; @@ -69,7 +69,7 @@ sub smartRead # because the filehandle may not support the offset parameter # An example is Net::FTP my $tmp = ''; - *$self->{FH}->read($tmp, $get_size) > 0 && + *$self->{FH}->read($tmp, $get_size) && (substr($$out, $offset) = $tmp); } else @@ -1328,7 +1328,17 @@ sub seek } # short circuit if seeking to current offset - return 1 if $target == $here ; + if ($target == $here) { + # On ordinary filehandles, seeking to the current + # position also clears the EOF condition, so we + # emulate this behavior locally while simultaneously + # cascading it to the underlying filehandle + if (*$self->{Plain}) { + *$self->{EndStream} = 0; + seek(*$self->{FH},0,1) if *$self->{FH}; + } + return 1; + } # Outlaw any attempt to seek backwards $self->croakError( *$self->{ClassName} ."::seek: cannot seek backwards") diff --git a/ext/IO-Compress/lib/IO/Uncompress/Bunzip2.pm b/ext/IO-Compress/lib/IO/Uncompress/Bunzip2.pm index b16890abe1..ce483ea738 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Bunzip2.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Bunzip2.pm @@ -4,15 +4,15 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); -use IO::Uncompress::Base 2.020 ; -use IO::Uncompress::Adapter::Bunzip2 2.020 ; +use IO::Uncompress::Base 2.021 ; +use IO::Uncompress::Adapter::Bunzip2 2.021 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $Bunzip2Error); -$VERSION = '2.020'; +$VERSION = '2.021'; $Bunzip2Error = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -40,7 +40,7 @@ sub getExtraParams { my $self = shift ; - use IO::Compress::Base::Common 2.020 qw(:Parse); + use IO::Compress::Base::Common 2.021 qw(:Parse); return ( 'Verbosity' => [1, 1, Parse_boolean, 0], diff --git a/ext/IO-Compress/lib/IO/Uncompress/Gunzip.pm b/ext/IO-Compress/lib/IO/Uncompress/Gunzip.pm index bc19262e1d..8922865d43 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Gunzip.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Gunzip.pm @@ -9,12 +9,12 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.020 ; +use IO::Uncompress::RawInflate 2.021 ; -use Compress::Raw::Zlib 2.020 qw( crc32 ) ; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); -use IO::Compress::Gzip::Constants 2.020 ; -use IO::Compress::Zlib::Extra 2.020 ; +use Compress::Raw::Zlib 2.021 qw( crc32 ) ; +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); +use IO::Compress::Gzip::Constants 2.021 ; +use IO::Compress::Zlib::Extra 2.021 ; require Exporter ; @@ -28,7 +28,7 @@ Exporter::export_ok_tags('all'); $GunzipError = ''; -$VERSION = '2.020'; +$VERSION = '2.021'; sub new { @@ -47,7 +47,7 @@ sub gunzip sub getExtraParams { - use IO::Compress::Base::Common 2.020 qw(:Parse); + use IO::Compress::Base::Common 2.021 qw(:Parse); return ( 'ParseExtra' => [1, 1, Parse_boolean, 0] ) ; } @@ -514,7 +514,7 @@ C option. =head2 Examples To read the contents of the file C and write the -compressed data to the file C. +uncompressed data to the file C. use strict ; use warnings ; diff --git a/ext/IO-Compress/lib/IO/Uncompress/Inflate.pm b/ext/IO-Compress/lib/IO/Uncompress/Inflate.pm index 3f28b45a0c..20aecc7864 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Inflate.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Inflate.pm @@ -5,15 +5,15 @@ use strict ; use warnings; use bytes; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); -use IO::Compress::Zlib::Constants 2.020 ; +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); +use IO::Compress::Zlib::Constants 2.021 ; -use IO::Uncompress::RawInflate 2.020 ; +use IO::Uncompress::RawInflate 2.021 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $InflateError); -$VERSION = '2.020'; +$VERSION = '2.021'; $InflateError = ''; @ISA = qw( Exporter IO::Uncompress::RawInflate ); @@ -435,7 +435,7 @@ C option. =head2 Examples To read the contents of the file C and write the -compressed data to the file C. +uncompressed data to the file C. use strict ; use warnings ; diff --git a/ext/IO-Compress/lib/IO/Uncompress/RawInflate.pm b/ext/IO-Compress/lib/IO/Uncompress/RawInflate.pm index 49c2f5755e..5727192e7c 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/RawInflate.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/RawInflate.pm @@ -5,16 +5,16 @@ use strict ; use warnings; use bytes; -use Compress::Raw::Zlib 2.020 ; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); +use Compress::Raw::Zlib 2.021 ; +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); -use IO::Uncompress::Base 2.020 ; -use IO::Uncompress::Adapter::Inflate 2.020 ; +use IO::Uncompress::Base 2.021 ; +use IO::Uncompress::Adapter::Inflate 2.021 ; require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, %DEFLATE_CONSTANTS, $RawInflateError); -$VERSION = '2.020'; +$VERSION = '2.021'; $RawInflateError = ''; @ISA = qw( Exporter IO::Uncompress::Base ); @@ -580,7 +580,7 @@ C option. =head2 Examples To read the contents of the file C and write the -compressed data to the file C. +uncompressed data to the file C. use strict ; use warnings ; diff --git a/ext/IO-Compress/lib/IO/Uncompress/Unzip.pm b/ext/IO-Compress/lib/IO/Uncompress/Unzip.pm index 1fee950fff..7d08c84edc 100644 --- a/ext/IO-Compress/lib/IO/Uncompress/Unzip.pm +++ b/ext/IO-Compress/lib/IO/Uncompress/Unzip.pm @@ -8,21 +8,21 @@ use strict ; use warnings; use bytes; -use IO::Uncompress::RawInflate 2.020 ; -use IO::Compress::Base::Common 2.020 qw(:Status createSelfTiedObject); -use IO::Uncompress::Adapter::Inflate 2.020 ; -use IO::Uncompress::Adapter::Identity 2.020 ; -use IO::Compress::Zlib::Extra 2.020 ; -use IO::Compress::Zip::Constants 2.020 ; +use IO::Uncompress::RawInflate 2.021 ; +use IO::Compress::Base::Common 2.021 qw(:Status createSelfTiedObject); +use IO::Uncompress::Adapter::Inflate 2.021 ; +use IO::Uncompress::Adapter::Identity 2.021 ; +use IO::Compress::Zlib::Extra 2.021 ; +use IO::Compress::Zip::Constants 2.021 ; -use Compress::Raw::Zlib 2.020 qw(crc32) ; +use Compress::Raw::Zlib 2.021 qw(crc32) ; BEGIN { eval { require IO::Uncompress::Adapter::Bunzip2 ; import IO::Uncompress::Adapter::Bunzip2 } ; - #eval { require IO::Uncompress::Adapter::UnLzma ; - # import IO::Uncompress::Adapter::UnLzma } ; + eval { require IO::Uncompress::Adapter::UnLzma ; + import IO::Uncompress::Adapter::UnLzma } ; } @@ -30,7 +30,7 @@ require Exporter ; our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup); -$VERSION = '2.020'; +$VERSION = '2.021'; $UnzipError = ''; @ISA = qw(Exporter IO::Uncompress::RawInflate); @@ -63,14 +63,17 @@ sub unzip sub getExtraParams { - use IO::Compress::Base::Common 2.020 qw(:Parse); + use IO::Compress::Base::Common 2.021 qw(:Parse); return ( # # Zip header fields - 'Name' => [1, 1, Parse_any, undef], + 'Name' => [1, 1, Parse_any, undef], -# 'Streaming' => [1, 1, Parse_boolean, 1], +# 'Stream' => [1, 1, Parse_boolean, 1], + # This means reading the central directory to get + # 1. the local header offsets + # 2. The compressed data length ); } @@ -124,6 +127,30 @@ sub ckMagic } +sub fastForward +{ + my $self = shift; + my $offset = shift; + + # TODO - if Stream isn't enabled & reading from file, use seek + + my $buffer = ''; + my $c = 1024 * 16; + + while ($offset > 0) + { + $c = length $offset + if length $offset < $c ; + + $offset -= $c; + + $self->smartReadExact(\$buffer, $c) + or return 0; + } + + return 1; +} + sub readHeader { @@ -141,6 +168,7 @@ sub readHeader } # skip the data + # TODO - when Stream is off, use seek my $buffer; if (*$self->{ZipData}{Streaming}) { @@ -171,8 +199,8 @@ sub readHeader or return $self->saveErrorString(undef, "Truncated file"); } else { - my $c = $hdr->{CompressedLength}->get32bit(); - $self->smartReadExact(\$buffer, $c) + my $c = $hdr->{CompressedLength}->get64bit(); + $self->fastForward($c) or return $self->saveErrorString(undef, "Truncated file"); $buffer = ''; } @@ -219,6 +247,10 @@ sub chkTrailer *$self->{ZipData}{UnCompressedLen}); } + *$self->{Info}{CRC32} = *$self->{ZipData}{CRC32} ; + *$self->{Info}{CompressedLength} = $cSize->get64bit(); + *$self->{Info}{UncompressedLength} = $uSize->get64bit(); + if (*$self->{Strict}) { return $self->TrailerError("CRC mismatch") if $CRC32 != *$self->{ZipData}{CRC32} ; @@ -383,14 +415,14 @@ sub skipCentralDirectory64Rec my $keep = $magic . $buffer ; my ($sizeLo, $sizeHi) = unpack ("V V", $buffer); + my $size = $sizeHi * 0xFFFFFFFF + $sizeLo; - # TODO - take SizeHi into account - $self->smartReadExact(\$buffer, $sizeLo) + $self->fastForward($size) or return $self->TrailerError("Minimum header size is " . - $sizeLo . " bytes") ; + $size . " bytes") ; - $keep .= $buffer ; - *$self->{HeaderPending} = $keep ; + #$keep .= $buffer ; + #*$self->{HeaderPending} = $keep ; #my $versionMadeBy = unpack ("v", substr($buffer, 0, 2)); #my $extractVersion = unpack ("v", substr($buffer, 2, 2)); @@ -507,8 +539,8 @@ sub _readZipHeader($) my $compressedMethod = unpack ("v", substr($buffer, 8-4, 2)); my $lastModTime = unpack ("V", substr($buffer, 10-4, 4)); my $crc32 = unpack ("V", substr($buffer, 14-4, 4)); - my $compressedLength = new U64 unpack ("V", substr($buffer, 18-4, 4)); - my $uncompressedLength = new U64 unpack ("V", substr($buffer, 22-4, 4)); + my $compressedLength = U64::newUnpack_V32 substr($buffer, 18-4, 4); + my $uncompressedLength = U64::newUnpack_V32 substr($buffer, 22-4, 4); my $filename_length = unpack ("v", substr($buffer, 26-4, 2)); my $extra_length = unpack ("v", substr($buffer, 28-4, 2)); @@ -562,27 +594,27 @@ sub _readZipHeader($) my $buff = ${ $Extra{ZIP_EXTRA_ID_ZIP64()} }; - # TODO - This code assumes that all the fields in the Zip64 + # This code assumes that all the fields in the Zip64 # extra field aren't necessarily present. The spec says that # they only exist if the equivalent local headers are -1. - # Need to check that info-zip fills out -1 in the local header - # correctly. if (! $streamingMode) { my $offset = 0 ; - $uncompressedLength = U64::newUnpack_V64 substr($buff, 0, 8) - if $uncompressedLength == 0xFFFF ; + if ($uncompressedLength->get32bit() == 0xFFFFFFFF ) { + $uncompressedLength + = U64::newUnpack_V64 substr($buff, 0, 8); - $offset += 8 ; + $offset += 8 ; + } - $compressedLength = U64::newUnpack_V64 substr($buff, $offset, 8) - if $compressedLength == 0xFFFF ; + if ($compressedLength->get32bit() == 0xFFFFFFFF) { - $offset += 8 ; + $compressedLength + = U64::newUnpack_V64 substr($buff, $offset, 8); - #my $cheaderOffset = U64::newUnpack_V64 substr($buff, 16, 8); - #my $diskNumber = unpack ("V", substr($buff, 24, 4)); + $offset += 8 ; + } } } } @@ -595,9 +627,10 @@ sub _readZipHeader($) *$self->{ZipData}{CompressedLen} = $compressedLength; *$self->{ZipData}{UnCompressedLen} = $uncompressedLength; *$self->{CompressedInputLengthRemaining} = - *$self->{CompressedInputLength} = $compressedLength->get32bit(); + *$self->{CompressedInputLength} = $compressedLength->get64bit(); } + *$self->{ZipData}{CRC32} = crc32(undef); *$self->{ZipData}{Method} = $compressedMethod; if ($compressedMethod == ZIP_CM_DEFLATE) { @@ -605,7 +638,6 @@ sub _readZipHeader($) my $obj = IO::Uncompress::Adapter::Inflate::mkUncompObject(1,0,0); *$self->{Uncomp} = $obj; - *$self->{ZipData}{CRC32} = crc32(undef); } elsif ($compressedMethod == ZIP_CM_BZIP2) { @@ -617,20 +649,35 @@ sub _readZipHeader($) my $obj = IO::Uncompress::Adapter::Bunzip2::mkUncompObject(); *$self->{Uncomp} = $obj; - *$self->{ZipData}{CRC32} = crc32(undef); } -# elsif ($compressedMethod == ZIP_CM_LZMA) -# { -# return $self->HeaderError("Unsupported Compression format $compressedMethod") -# if ! defined $IO::Uncompress::Adapter::UnLzma::VERSION ; -# -# *$self->{Type} = 'zip-lzma'; -# -# my $obj = IO::Uncompress::Adapter::UnLzma::mkUncompObject(); -# -# *$self->{Uncomp} = $obj; -# *$self->{ZipData}{CRC32} = crc32(undef); -# } + elsif ($compressedMethod == ZIP_CM_LZMA) + { + return $self->HeaderError("Unsupported Compression format $compressedMethod") + if ! defined $IO::Uncompress::Adapter::UnLzma::VERSION ; + + *$self->{Type} = 'zip-lzma'; + my $LzmaHeader; + $self->smartReadExact(\$LzmaHeader, 4) + or return $self->saveErrorString(undef, "Truncated file"); + my ($verHi, $verLo) = unpack ("CC", substr($LzmaHeader, 0, 2)); + my $LzmaPropertiesSize = unpack ("v", substr($LzmaHeader, 2, 2)); + + + my $LzmaPropertyData; + $self->smartReadExact(\$LzmaPropertyData, $LzmaPropertiesSize) + or return $self->saveErrorString(undef, "Truncated file"); + #my $LzmaInfo = unpack ("C", substr($LzmaPropertyData, 0, 1)); + #my $LzmaDictSize = unpack ("V", substr($LzmaPropertyData, 1, 4)); + + # Create an LZMA_Alone header + $self->pushBack($LzmaPropertyData . + $uncompressedLength->getPacked_V64()); + + my $obj = + IO::Uncompress::Adapter::UnLzma::mkUncompObject(); + + *$self->{Uncomp} = $obj; + } elsif ($compressedMethod == ZIP_CM_STORE) { # TODO -- add support for reading uncompressed @@ -666,9 +713,11 @@ sub _readZipHeader($) ? "Deflated" : $compressedMethod == ZIP_CM_BZIP2 ? "Bzip2" - : $compressedMethod == ZIP_CM_STORE - ? "Stored" - : "Unknown" , + : $compressedMethod == ZIP_CM_LZMA + ? "Lzma" + : $compressedMethod == ZIP_CM_STORE + ? "Stored" + : "Unknown" , # 'TextFlag' => $flag & GZIP_FLG_FTEXT ? 1 : 0, # 'HeaderCRCFlag' => $flag & GZIP_FLG_FHCRC ? 1 : 0, @@ -693,11 +742,11 @@ sub filterUncompressed { my $self = shift ; - if (*$self->{ZipData}{Method} == 12) { - *$self->{ZipData}{CRC32} = crc32(${$_[0]}, *$self->{ZipData}{CRC32}); + if (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) { + *$self->{ZipData}{CRC32} = *$self->{Uncomp}->crc32() ; } else { - *$self->{ZipData}{CRC32} = *$self->{Uncomp}->crc32() ; + *$self->{ZipData}{CRC32} = crc32(${$_[0]}, *$self->{ZipData}{CRC32}); } } @@ -967,7 +1016,7 @@ C option. =head2 Examples To read the contents of the file C and write the -compressed data to the file C. +uncompressed data to the file C. use strict ; use warnings ; diff --git a/ext/IO-Compress/private/MakeUtil.pm b/ext/IO-Compress/private/MakeUtil.pm index e595910654..47aebd6074 100644 --- a/ext/IO-Compress/private/MakeUtil.pm +++ b/ext/IO-Compress/private/MakeUtil.pm @@ -58,9 +58,9 @@ sub MY::postamble MyTrebleCheck: @echo Checking for $$^W in files: '. "@files" . ' - @perl -ne \' \ - exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \ - \' ' . " @files || " . ' \ + perl -ne \' \ + exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \' \ + ' . " @files || " . ' \ (echo found unexpected $$^W ; exit 1) @echo All is ok. diff --git a/ext/IO-Compress/t/000prereq.t b/ext/IO-Compress/t/000prereq.t index 27463206f4..11b84fd85e 100644 --- a/ext/IO-Compress/t/000prereq.t +++ b/ext/IO-Compress/t/000prereq.t @@ -11,6 +11,12 @@ use warnings ; use Test::More ; +sub gotScalarUtilXS +{ + eval ' use Scalar::Util "dualvar" '; + return $@ ? 0 : 1 ; +} + BEGIN { # use Test::NoWarnings, if available @@ -19,17 +25,46 @@ BEGIN if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - my $VERSION = '2.020'; + my $VERSION = '2.021'; my @NAMES = qw( Compress::Raw::Bzip2 Compress::Raw::Zlib + + Compress::Zlib + + IO::Compress::Adapter::Bzip2 + IO::Compress::Adapter::Deflate + IO::Compress::Adapter::Identity + IO::Compress::Base::Common + IO::Compress::Base + IO::Compress::Bzip2 + IO::Compress::Deflate + IO::Compress::Gzip::Constants + IO::Compress::Gzip + IO::Compress::RawDeflate + IO::Compress::Zip::Constants + IO::Compress::Zip + IO::Compress::Zlib::Constants + IO::Compress::Zlib::Extra + IO::Uncompress::Adapter::Bunzip2 + IO::Uncompress::Adapter::Identity + IO::Uncompress::Adapter::Inflate + IO::Uncompress::AnyInflate + IO::Uncompress::AnyUncompress + IO::Uncompress::Base + IO::Uncompress::Bunzip2 + IO::Uncompress::Gunzip + IO::Uncompress::Inflate + IO::Uncompress::RawInflate + IO::Uncompress::Unzip + ); my @OPT = qw( ); - plan tests => @NAMES + @OPT + $extra ; + plan tests => 2 + @NAMES + @OPT + $extra ; foreach my $name (@NAMES) { @@ -51,6 +86,13 @@ BEGIN or diag "$name version is $ver, need $VERSION" ; } } - + + use_ok('Scalar::Util') ; + } +ok gotScalarUtilXS(), "Got XS Version of Scalar::Util" + or diag <eof(); $status = $u->nextStream()) { - my $name = $u->getHeaderInfo()->{Name}; #warn "Processing member $name\n" ; my $buff = ''; - 1 while ($status = $u->read($buff)) > 0; + 1 while ($status = $u->read($buff)) ; push @content, $buff; last unless $status == 0; diff --git a/ext/IO-Compress/t/01misc.t b/ext/IO-Compress/t/01misc.t index 27706f6cfa..a7a31fbe15 100644 --- a/ext/IO-Compress/t/01misc.t +++ b/ext/IO-Compress/t/01misc.t @@ -19,7 +19,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 88 + $extra ; + plan tests => 118 + $extra ; use_ok('Scalar::Util'); use_ok('IO::Compress::Base::Common'); @@ -209,49 +209,74 @@ My::testParseParameters(); my $x = new U64(); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 0, " getLow is 0"; + ok ! $x->is64bit(), " ! is64bit"; - $x = new U64(1,2); $x = new U64(1,2); is $x->getHigh, 1, " getHigh is 1"; is $x->getLow, 2, " getLow is 2"; + ok $x->is64bit(), " is64bit"; $x = new U64(0xFFFFFFFF,2); is $x->getHigh, 0xFFFFFFFF, " getHigh is 0xFFFFFFFF"; is $x->getLow, 2, " getLow is 2"; + ok $x->is64bit(), " is64bit"; $x = new U64(7, 0xFFFFFFFF); is $x->getHigh, 7, " getHigh is 7"; is $x->getLow, 0xFFFFFFFF, " getLow is 0xFFFFFFFF"; + ok $x->is64bit(), " is64bit"; $x = new U64(666); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 666, " getLow is 666"; + ok ! $x->is64bit(), " ! is64bit"; title "U64 - add" ; $x = new U64(0, 1); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 1, " getLow is 1"; + ok ! $x->is64bit(), " ! is64bit"; $x->add(1); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 2, " getLow is 2"; + ok ! $x->is64bit(), " ! is64bit"; $x = new U64(0, 0xFFFFFFFE); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 0xFFFFFFFE, " getLow is 0xFFFFFFFE"; + is $x->get32bit(), 0xFFFFFFFE, " get32bit is 0xFFFFFFFE"; + is $x->get64bit(), 0xFFFFFFFE, " get64bit is 0xFFFFFFFE"; + ok ! $x->is64bit(), " ! is64bit"; $x->add(1); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 0xFFFFFFFF, " getLow is 0xFFFFFFFF"; + is $x->get32bit(), 0xFFFFFFFF, " get32bit is 0xFFFFFFFF"; + is $x->get64bit(), 0xFFFFFFFF, " get64bit is 0xFFFFFFFF"; + ok ! $x->is64bit(), " ! is64bit"; $x->add(1); is $x->getHigh, 1, " getHigh is 1"; is $x->getLow, 0, " getLow is 0"; + is $x->get32bit(), 0x0, " get32bit is 0x0"; + is $x->get64bit(), 0xFFFFFFFF+1, " get64bit is 0x100000000"; + ok $x->is64bit(), " is64bit"; $x->add(1); is $x->getHigh, 1, " getHigh is 1"; is $x->getLow, 1, " getLow is 1"; + is $x->get32bit(), 0x1, " get32bit is 0x1"; + is $x->get64bit(), 0xFFFFFFFF+2, " get64bit is 0x100000001"; + ok $x->is64bit(), " is64bit"; + + $x->add(1); + is $x->getHigh, 1, " getHigh is 1"; + is $x->getLow, 2, " getLow is 1"; + is $x->get32bit(), 0x2, " get32bit is 0x2"; + is $x->get64bit(), 0xFFFFFFFF+3, " get64bit is 0x100000002"; + ok $x->is64bit(), " is64bit"; $x = new U64(1, 0xFFFFFFFE); my $y = new U64(2, 3); @@ -259,23 +284,31 @@ My::testParseParameters(); $x->add($y); is $x->getHigh, 4, " getHigh is 4"; is $x->getLow, 1, " getLow is 1"; + ok $x->is64bit(), " is64bit"; title "U64 - equal" ; $x = new U64(0, 1); is $x->getHigh, 0, " getHigh is 0"; is $x->getLow, 1, " getLow is 1"; + ok ! $x->is64bit(), " ! is64bit"; $y = new U64(0, 1); - is $x->getHigh, 0, " getHigh is 0"; - is $x->getLow, 1, " getLow is 1"; + is $y->getHigh, 0, " getHigh is 0"; + is $y->getLow, 1, " getLow is 1"; + ok ! $y->is64bit(), " ! is64bit"; my $z = new U64(0, 2); - is $x->getHigh, 0, " getHigh is 0"; - is $x->getLow, 1, " getLow is 1"; + is $z->getHigh, 0, " getHigh is 0"; + is $z->getLow, 2, " getLow is 2"; + ok ! $z->is64bit(), " ! is64bit"; ok $x->equal($y), " equal"; ok !$x->equal($z), " ! equal"; - title "U64 - pack_V" ; + title "U64 - clone" ; + $x = new U64(21, 77); + $z = U64::clone($x); + is $z->getHigh, 21, " getHigh is 21"; + is $z->getLow, 77, " getLow is 77"; } diff --git a/ext/IO-Compress/t/105oneshot-zip-bzip2-only.t b/ext/IO-Compress/t/105oneshot-zip-bzip2-only.t index 861eaef8fd..f21e918b87 100644 --- a/ext/IO-Compress/t/105oneshot-zip-bzip2-only.t +++ b/ext/IO-Compress/t/105oneshot-zip-bzip2-only.t @@ -28,7 +28,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 120 + $extra ; + plan tests => 144 + $extra ; #use_ok('IO::Compress::Zip', qw(zip $ZipError :zip_method)) ; use_ok('IO::Compress::Zip', qw(:all)) ; @@ -71,7 +71,7 @@ for my $stream (0, 1) { for my $zip64 (0, 1) { - next if $zip64 && ! $stream; + #next if $zip64 && ! $stream; for my $method (ZIP_CM_STORE, ZIP_CM_DEFLATE, ZIP_CM_BZIP2) { diff --git a/ext/IO-Compress/t/105oneshot-zip-only.t b/ext/IO-Compress/t/105oneshot-zip-only.t index 807c9e9d61..0906bf6e16 100644 --- a/ext/IO-Compress/t/105oneshot-zip-only.t +++ b/ext/IO-Compress/t/105oneshot-zip-only.t @@ -23,7 +23,7 @@ BEGIN { $extra = 1 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 }; - plan tests => 146 + $extra ; + plan tests => 162 + $extra ; #use_ok('IO::Compress::Zip', qw(zip $ZipError :zip_method)) ; use_ok('IO::Compress::Zip', qw(:all)) ; @@ -137,7 +137,7 @@ for my $stream (0, 1) { for my $zip64 (0, 1) { - next if $zip64 && ! $stream; + #next if $zip64 && ! $stream; for my $method (ZIP_CM_STORE, ZIP_CM_DEFLATE) { diff --git a/ext/IO-Compress/t/compress/CompTestUtils.pm b/ext/IO-Compress/t/compress/CompTestUtils.pm index 22b6d5646c..cb63d6274c 100644 --- a/ext/IO-Compress/t/compress/CompTestUtils.pm +++ b/ext/IO-Compress/t/compress/CompTestUtils.pm @@ -203,12 +203,164 @@ sub cmpFile return readFile($filename) eq unpack("u", $uue) ; } -sub isRawFormat +#sub isRawFormat +#{ +# my $class = shift; +# # TODO -- add Lzma here? +# my %raw = map { $_ => 1 } qw( RawDeflate ); +# +# return defined $raw{$class}; +#} + + + +my %TOP = ( + 'IO::Uncompress::AnyInflate' => { Inverse => 'IO::Compress::Gzip', + Error => 'AnyInflateError', + TopLevel => 'anyinflate', + Raw => 0, + }, + + 'IO::Uncompress::AnyUncompress' => { Inverse => 'IO::Compress::Gzip', + Error => 'AnyUncompressError', + TopLevel => 'anyuncompress', + Raw => 0, + }, + + 'IO::Compress::Gzip' => { Inverse => 'IO::Uncompress::Gunzip', + Error => 'GzipError', + TopLevel => 'gzip', + Raw => 0, + }, + 'IO::Uncompress::Gunzip' => { Inverse => 'IO::Compress::Gzip', + Error => 'GunzipError', + TopLevel => 'gunzip', + Raw => 0, + }, + + 'IO::Compress::Deflate' => { Inverse => 'IO::Uncompress::Inflate', + Error => 'DeflateError', + TopLevel => 'deflate', + Raw => 0, + }, + 'IO::Uncompress::Inflate' => { Inverse => 'IO::Compress::Deflate', + Error => 'InflateError', + TopLevel => 'inflate', + Raw => 0, + }, + + 'IO::Compress::RawDeflate' => { Inverse => 'IO::Uncompress::RawInflate', + Error => 'RawDeflateError', + TopLevel => 'rawdeflate', + Raw => 1, + }, + 'IO::Uncompress::RawInflate' => { Inverse => 'IO::Compress::RawDeflate', + Error => 'RawInflateError', + TopLevel => 'rawinflate', + Raw => 1, + }, + + 'IO::Compress::Zip' => { Inverse => 'IO::Uncompress::Unzip', + Error => 'ZipError', + TopLevel => 'zip', + Raw => 0, + }, + 'IO::Uncompress::Unzip' => { Inverse => 'IO::Compress::Zip', + Error => 'UnzipError', + TopLevel => 'unzip', + Raw => 0, + }, + + 'IO::Compress::Bzip2' => { Inverse => 'IO::Uncompress::Bunzip2', + Error => 'Bzip2Error', + TopLevel => 'bzip2', + Raw => 0, + }, + 'IO::Uncompress::Bunzip2' => { Inverse => 'IO::Compress::Bzip2', + Error => 'Bunzip2Error', + TopLevel => 'bunzip2', + Raw => 0, + }, + + 'IO::Compress::Lzop' => { Inverse => 'IO::Uncompress::UnLzop', + Error => 'LzopError', + TopLevel => 'lzop', + Raw => 0, + }, + 'IO::Uncompress::UnLzop' => { Inverse => 'IO::Compress::Lzop', + Error => 'UnLzopError', + TopLevel => 'unlzop', + Raw => 0, + }, + + 'IO::Compress::Lzf' => { Inverse => 'IO::Uncompress::UnLzf', + Error => 'LzfError', + TopLevel => 'lzf', + Raw => 0, + }, + 'IO::Uncompress::UnLzf' => { Inverse => 'IO::Compress::Lzf', + Error => 'UnLzfError', + TopLevel => 'unlzf', + Raw => 0, + }, + + 'IO::Compress::Lzma' => { Inverse => 'IO::Uncompress::UnLzma', + Error => 'LzmaError', + TopLevel => 'lzma', + Raw => 1, + }, + 'IO::Uncompress::UnLzma' => { Inverse => 'IO::Compress::Lzma', + Error => 'UnLzmaError', + TopLevel => 'unlzma', + Raw => 1, + }, + + 'IO::Compress::Xz' => { Inverse => 'IO::Uncompress::UnXz', + Error => 'XzError', + TopLevel => 'xz', + Raw => 0, + }, + 'IO::Uncompress::UnXz' => { Inverse => 'IO::Compress::Xz', + Error => 'UnXzError', + TopLevel => 'unxz', + Raw => 0, + }, + + 'IO::Compress::PPMd' => { Inverse => 'IO::Uncompress::UnPPMd', + Error => 'PPMdError', + TopLevel => 'ppmd', + Raw => 0, + }, + 'IO::Uncompress::UnPPMd' => { Inverse => 'IO::Compress::PPMd', + Error => 'UnPPMdError', + TopLevel => 'unppmd', + Raw => 0, + }, + + 'IO::Compress::DummyComp' => { Inverse => 'IO::Uncompress::DummyUnComp', + Error => 'DummyCompError', + TopLevel => 'dummycomp', + Raw => 0, + }, + 'IO::Uncompress::DummyUnComp' => { Inverse => 'IO::Compress::DummyComp', + Error => 'DummyUnCompError', + TopLevel => 'dummyunComp', + Raw => 0, + }, +); + + +for my $key (keys %TOP) { - my $class = shift; - my %raw = map { $_ => 1 } qw( RawDeflate ); + no strict; + no warnings; + $TOP{$key}{Error} = \${ $key . '::' . $TOP{$key}{Error} }; + $TOP{$key}{TopLevel} = $key . '::' . $TOP{$key}{TopLevel} ; - return defined $raw{$class}; + # Silence used once warning in really old perl + my $dummy = \${ $key . '::' . $TOP{$key}{Error} }; + + #$TOP{$key . "::" . $TOP{$key}{TopLevel} } = $TOP{$key}; } sub uncompressBuffer @@ -216,159 +368,43 @@ sub uncompressBuffer my $compWith = shift ; my $buffer = shift ; - my %mapping = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Gzip::gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::Deflate::deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::RawDeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::RawDeflate::rawdeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::Bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Bzip2::bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Zip::zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf' , - 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf', - 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd' , - 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd', - 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', - 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp', - ); my $out ; - my $obj = $mapping{$compWith}->new( \$buffer, -Append => 1); + my $obj = $TOP{$compWith}{Inverse}->new( \$buffer, -Append => 1); 1 while $obj->read($out) > 0 ; return $out ; } -my %ErrorMap = ( 'IO::Compress::Gzip' => \$IO::Compress::Gzip::GzipError, - 'IO::Compress::Gzip::gzip' => \$IO::Compress::Gzip::GzipError, - 'IO::Uncompress::Gunzip' => \$IO::Uncompress::Gunzip::GunzipError, - 'IO::Uncompress::Gunzip::gunzip' => \$IO::Uncompress::Gunzip::GunzipError, - 'IO::Uncompress::Inflate' => \$IO::Uncompress::Inflate::InflateError, - 'IO::Uncompress::Inflate::inflate' => \$IO::Uncompress::Inflate::InflateError, - 'IO::Compress::Deflate' => \$IO::Compress::Deflate::DeflateError, - 'IO::Compress::Deflate::deflate' => \$IO::Compress::Deflate::DeflateError, - 'IO::Uncompress::RawInflate' => \$IO::Uncompress::RawInflate::RawInflateError, - 'IO::Uncompress::RawInflate::rawinflate' => \$IO::Uncompress::RawInflate::RawInflateError, - 'IO::Uncompress::AnyInflate' => \$IO::Uncompress::AnyInflate::AnyInflateError, - 'IO::Uncompress::AnyInflate::anyinflate' => \$IO::Uncompress::AnyInflate::AnyInflateError, - 'IO::Uncompress::AnyUncompress' => \$IO::Uncompress::AnyUncompress::AnyUncompressError, - 'IO::Uncompress::AnyUncompress::anyUncompress' => \$IO::Uncompress::AnyUncompress::AnyUncompressError, - 'IO::Compress::RawDeflate' => \$IO::Compress::RawDeflate::RawDeflateError, - 'IO::Compress::RawDeflate::rawdeflate' => \$IO::Compress::RawDeflate::RawDeflateError, - 'IO::Compress::Bzip2' => \$IO::Compress::Bzip2::Bzip2Error, - 'IO::Compress::Bzip2::bzip2' => \$IO::Compress::Bzip2::Bzip2Error, - 'IO::Uncompress::Bunzip2' => \$IO::Uncompress::Bunzip2::Bunzip2Error, - 'IO::Uncompress::Bunzip2::bunzip2' => \$IO::Uncompress::Bunzip2::Bunzip2Error, - 'IO::Compress::Zip' => \$IO::Compress::Zip::ZipError, - 'IO::Compress::Zip::zip' => \$IO::Compress::Zip::ZipError, - 'IO::Uncompress::Unzip' => \$IO::Uncompress::Unzip::UnzipError, - 'IO::Uncompress::Unzip::unzip' => \$IO::Uncompress::Unzip::UnzipError, - 'IO::Compress::Lzop' => \$IO::Compress::Lzop::LzopError, - 'IO::Compress::Lzop::lzop' => \$IO::Compress::Lzop::LzopError, - 'IO::Uncompress::UnLzop' => \$IO::Uncompress::UnLzop::UnLzopError, - 'IO::Uncompress::UnLzop::unlzop' => \$IO::Uncompress::UnLzop::UnLzopError, - 'IO::Compress::Lzf' => \$IO::Compress::Lzf::LzfError, - 'IO::Compress::Lzf::lzf' => \$IO::Compress::Lzf::LzfError, - 'IO::Uncompress::UnLzf' => \$IO::Uncompress::UnLzf::UnLzfError, - 'IO::Uncompress::UnLzf::unlzf' => \$IO::Uncompress::UnLzf::UnLzfError, - 'IO::Compress::PPMd' => \$IO::Compress::PPMd::PPMdError, - 'IO::Compress::PPMd::ppmd' => \$IO::Compress::PPMd::PPMdError, - 'IO::Uncompress::UnPPMd' => \$IO::Uncompress::UnPPMd::UnPPMdError, - 'IO::Uncompress::UnPPMd::unppmd' => \$IO::Uncompress::UnPPMd::UnPPMdError, - - 'IO::Compress::DummyComp' => \$IO::Compress::DummyComp::DummyCompError, - 'IO::Compress::DummyComp::dummycomp'=> \$IO::Compress::DummyComp::DummyCompError, - 'IO::Uncompress::DummyUncomp' => \$IO::Uncompress::DummyUncomp::DummyUncompError, - 'IO::Uncompress::DummyUncomp::dummyuncomp' => \$IO::Uncompress::DummyUncomp::DummyUncompError, - ); - -my %TopFuncMap = ( 'IO::Compress::Gzip' => 'IO::Compress::Gzip::gzip', - 'IO::Uncompress::Gunzip' => 'IO::Uncompress::Gunzip::gunzip', - - 'IO::Compress::Deflate' => 'IO::Compress::Deflate::deflate', - 'IO::Uncompress::Inflate' => 'IO::Uncompress::Inflate::inflate', - - 'IO::Compress::RawDeflate' => 'IO::Compress::RawDeflate::rawdeflate', - 'IO::Uncompress::RawInflate' => 'IO::Uncompress::RawInflate::rawinflate', - - 'IO::Uncompress::AnyInflate' => 'IO::Uncompress::AnyInflate::anyinflate', - 'IO::Uncompress::AnyUncompress' => 'IO::Uncompress::AnyUncompress::anyuncompress', - - 'IO::Compress::Bzip2' => 'IO::Compress::Bzip2::bzip2', - 'IO::Uncompress::Bunzip2' => 'IO::Uncompress::Bunzip2::bunzip2', - - 'IO::Compress::Zip' => 'IO::Compress::Zip::zip', - 'IO::Uncompress::Unzip' => 'IO::Uncompress::Unzip::unzip', - 'IO::Compress::Lzop' => 'IO::Compress::Lzop::lzop', - 'IO::Uncompress::UnLzop' => 'IO::Uncompress::UnLzop::unlzop', - 'IO::Compress::Lzf' => 'IO::Compress::Lzf::lzf', - 'IO::Uncompress::UnLzf' => 'IO::Uncompress::UnLzf::unlzf', - 'IO::Compress::PPMd' => 'IO::Compress::PPMd::ppmd', - 'IO::Uncompress::UnPPMd' => 'IO::Uncompress::UnPPMd::unppmd', - 'IO::Compress::DummyComp' => 'IO::Compress::DummyComp::dummyuncomp', - 'IO::Uncompress::DummyUncomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', - ); - - %TopFuncMap = map { ($_ => $TopFuncMap{$_}, - $TopFuncMap{$_} => $TopFuncMap{$_}) } - keys %TopFuncMap ; - - #%TopFuncMap = map { ($_ => \&{ $TopFuncMap{$_} ) } - #keys %TopFuncMap ; - - -my %inverse = ( 'IO::Compress::Gzip' => 'IO::Uncompress::Gunzip', - 'IO::Compress::Gzip::gzip' => 'IO::Uncompress::Gunzip::gunzip', - 'IO::Compress::Deflate' => 'IO::Uncompress::Inflate', - 'IO::Compress::Deflate::deflate' => 'IO::Uncompress::Inflate::inflate', - 'IO::Compress::RawDeflate' => 'IO::Uncompress::RawInflate', - 'IO::Compress::RawDeflate::rawdeflate' => 'IO::Uncompress::RawInflate::rawinflate', - 'IO::Compress::Bzip2::bzip2' => 'IO::Uncompress::Bunzip2::bunzip2', - 'IO::Compress::Bzip2' => 'IO::Uncompress::Bunzip2', - 'IO::Compress::Zip::zip' => 'IO::Uncompress::Unzip::unzip', - 'IO::Compress::Zip' => 'IO::Uncompress::Unzip', - 'IO::Compress::Lzop::lzop' => 'IO::Uncompress::UnLzop::unlzop', - 'IO::Compress::Lzop' => 'IO::Uncompress::UnLzop', - 'IO::Compress::Lzf::lzf' => 'IO::Uncompress::UnLzf::unlzf', - 'IO::Compress::Lzf' => 'IO::Uncompress::UnLzf', - 'IO::Compress::PPMd::ppmd' => 'IO::Uncompress::UnPPMd::unppmd', - 'IO::Compress::PPMd' => 'IO::Uncompress::UnPPMd', - 'IO::Compress::DummyComp::dummycomp' => 'IO::Uncompress::DummyUncomp::dummyuncomp', - 'IO::Compress::DummyComp' => 'IO::Uncompress::DummyUncomp', - ); - -%inverse = map { ($_ => $inverse{$_}, $inverse{$_} => $_) } keys %inverse; sub getInverse { my $class = shift ; - return $inverse{$class} ; + return $TOP{$class}{Inverse}; } sub getErrorRef { my $class = shift ; - return $ErrorMap{$class} ; + return $TOP{$class}{Error}; } sub getTopFuncRef { my $class = shift ; - return \&{ $TopFuncMap{$class} } ; + die "Cannot find $class" + if ! defined $TOP{$class}{TopLevel}; + return \&{ $TOP{$class}{TopLevel} } ; } sub getTopFuncName { my $class = shift ; - return $TopFuncMap{$class} ; + return $TOP{$class}{TopLevel} ; } sub compressBuffer @@ -376,32 +412,11 @@ sub compressBuffer my $compWith = shift ; my $buffer = shift ; - my %mapping = ( 'IO::Uncompress::Gunzip' => 'IO::Compress::Gzip', - 'IO::Uncompress::Gunzip::gunzip' => 'IO::Compress::Gzip', - 'IO::Uncompress::Inflate' => 'IO::Compress::Deflate', - 'IO::Uncompress::Inflate::inflate' => 'IO::Compress::Deflate', - 'IO::Uncompress::RawInflate' => 'IO::Compress::RawDeflate', - 'IO::Uncompress::RawInflate::rawinflate' => 'IO::Compress::RawDeflate', - 'IO::Uncompress::Bunzip2' => 'IO::Compress::Bzip2', - 'IO::Uncompress::Bunzip2::bunzip2' => 'IO::Compress::Bzip2', - 'IO::Uncompress::Unzip' => 'IO::Compress::Zip', - 'IO::Uncompress::Unzip::unzip' => 'IO::Compress::Zip', - 'IO::Uncompress::UnLzop' => 'IO::Compress::Lzop', - 'IO::Uncompress::UnLzop::unlzop' => 'IO::Compress::Lzop', - 'IO::Uncompress::UnLzp' => 'IO::Compress::Lzf', - 'IO::Uncompress::UnLzf::unlzf' => 'IO::Compress::Lzf', - 'IO::Uncompress::UnPPMd' => 'IO::Compress::PPMd', - 'IO::Uncompress::UnPPMd::unppmd' => 'IO::Compress::PPMd', - 'IO::Uncompress::AnyInflate' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyInflate::anyinflate' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyUncompress' => 'IO::Compress::Gzip', - 'IO::Uncompress::AnyUncompress::anyuncompress' => 'IO::Compress::Gzip', - 'IO::Uncompress::DummyUncomp' => 'IO::Compress::DummyComp', - 'IO::Uncompress::DummyUncomp::dummyuncomp'=> 'IO::Compress::DummyComp', - ); my $out ; - my $obj = $mapping{$compWith}->new( \$out); + die "Cannot find $compWith" + if ! defined $TOP{$compWith}{Inverse}; + my $obj = $TOP{$compWith}{Inverse}->new( \$out); $obj->write($buffer) ; $obj->close(); return $out ; @@ -584,7 +599,7 @@ sub mkErr $file = quotemeta($file); - return "/$string\\s+at $file line $line/" if $] >= 5.006 ; + #return "/$string\\s+at $file line $line/" if $] >= 5.006 ; return "/$string\\s+at /" ; } @@ -592,7 +607,7 @@ sub mkEvalErr { my $string = shift ; - return "/$string\\s+at \\(eval /" if $] > 5.006 ; + #return "/$string\\s+at \\(eval /" if $] > 5.006 ; return "/$string\\s+at /" ; } diff --git a/ext/IO-Compress/t/compress/oneshot.pl b/ext/IO-Compress/t/compress/oneshot.pl index 4f8bb83ac6..9c76cefdb5 100644 --- a/ext/IO-Compress/t/compress/oneshot.pl +++ b/ext/IO-Compress/t/compress/oneshot.pl @@ -193,7 +193,7 @@ sub run eval { $a = $Func->(\$in, \$out, TrailingData => \@x) ;} ; like $@, mkErr("^$TopType: Parameter 'TrailingData' not a scalar reference"), - ' TrailingData output not scaral reference'; + ' TrailingData output not scalar reference'; } } @@ -1013,8 +1013,8 @@ sub run my $buffer2 = "ABCDE" ; my $keep_orig = $buffer; - my $comp = compressBuffer(getTopFuncName($UncompressClass), $buffer) ; - my $comp2 = compressBuffer(getTopFuncName($UncompressClass), $buffer2) ; + my $comp = compressBuffer($UncompressClass, $buffer) ; + my $comp2 = compressBuffer($UncompressClass, $buffer2) ; my $keep_comp = $comp; my $incumbent = "incumbent data" ; @@ -1315,9 +1315,9 @@ sub run my $buffer = "abcde" ; my $keep_orig = $buffer; - my $null = compressBuffer(getTopFuncName($UncompressClass), "") ; - my $undef = compressBuffer(getTopFuncName($UncompressClass), undef) ; - my $comp = compressBuffer(getTopFuncName($UncompressClass), $buffer) ; + my $null = compressBuffer($UncompressClass, "") ; + my $undef = compressBuffer($UncompressClass, undef) ; + my $comp = compressBuffer($UncompressClass, $buffer) ; my $keep_comp = $comp; my @opts = (); @@ -1328,8 +1328,8 @@ sub run my $lex = new LexFile(my $file1, my $file2) ; - writeFile($file1, compressBuffer(getTopFuncName($UncompressClass),"data1")); - writeFile($file2, compressBuffer(getTopFuncName($UncompressClass),"data2")); + writeFile($file1, compressBuffer($UncompressClass,"data1")); + writeFile($file2, compressBuffer($UncompressClass,"data2")); my $of = new IO::File "<$file1" ; ok $of, " Created output filehandle" ; @@ -1414,7 +1414,7 @@ sub run #ok ! -d $tmpDir2, " Temp Directory $tmpDir2 does not exist"; my @files = map { "$tmpDir1/$_.tmp" } qw( a1 a2 a3) ; - foreach (@files) { writeFile($_, compressBuffer(getTopFuncName($UncompressClass), "abc $_")) } + foreach (@files) { writeFile($_, compressBuffer($UncompressClass, "abc $_")) } my @expected = map { "abc $_" } @files ; my @outFiles = map { s/$tmpDir1/$tmpDir2/; $_ } @files ; -- cgit v1.2.1