diff options
author | Paul Marquess <paul.marquess@btinternet.com> | 2006-06-28 15:22:46 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2006-06-28 14:37:03 +0000 |
commit | 6ecef415672954d64bc0df6bdb809cebe10f89d4 (patch) | |
tree | a6a0c4b65df7ccf2dc0167b1b985c7745ad40aee /ext | |
parent | 84b74420ec29626056f47c562bc5572638f87383 (diff) | |
download | perl-6ecef415672954d64bc0df6bdb809cebe10f89d4.tar.gz |
Update for IO::Uncompress::Base
From: "Paul Marquess" <paul.marquess@ntlworld.com>
Message-ID: <001701c69ab5$f4d5d3d0$2405140a@myopwv.com>
p4raw-id: //depot/perl@28445
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Compress/IO/Base/lib/IO/Uncompress/AnyUncompress.pm | 17 | ||||
-rw-r--r-- | ext/Compress/IO/Base/lib/IO/Uncompress/Base.pm | 38 | ||||
-rw-r--r-- | ext/Compress/IO/Zlib/lib/IO/Uncompress/AnyInflate.pm | 9 |
3 files changed, 42 insertions, 22 deletions
diff --git a/ext/Compress/IO/Base/lib/IO/Uncompress/AnyUncompress.pm b/ext/Compress/IO/Base/lib/IO/Uncompress/AnyUncompress.pm index c7c71d7edc..3c30c520f8 100644 --- a/ext/Compress/IO/Base/lib/IO/Uncompress/AnyUncompress.pm +++ b/ext/Compress/IO/Base/lib/IO/Uncompress/AnyUncompress.pm @@ -53,7 +53,8 @@ sub anyuncompress sub getExtraParams { - return (); + use IO::Compress::Base::Common qw(:Parse); + return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } sub ckParams @@ -86,17 +87,20 @@ sub mkUncomp *$self->{Uncomp} = $obj; - $magic = $self->ckMagic( qw( RawInflate Inflate Gunzip Unzip ) ); + my @possible = qw( Inflate Gunzip Unzip ); + unshift @possible, 'RawInflate' + if $got->value('RawInflate'); - if ($magic) { + $magic = $self->ckMagic( @possible ); + + if ($magic) { *$self->{Info} = $self->readHeader($magic) or return undef ; return 1; - } + } } - #foreach my $type ( qw( Bunzip2 UnLzop ) ) { if (defined $IO::Uncompress::Bunzip2::VERSION and $magic = $self->ckMagic('Bunzip2')) { *$self->{Info} = $self->readHeader($magic) @@ -111,7 +115,8 @@ sub mkUncomp return 1; } - elsif (defined $IO::Uncompress::UnLzop::VERSION and + + if (defined $IO::Uncompress::UnLzop::VERSION and $magic = $self->ckMagic('UnLzop')) { *$self->{Info} = $self->readHeader($magic) diff --git a/ext/Compress/IO/Base/lib/IO/Uncompress/Base.pm b/ext/Compress/IO/Base/lib/IO/Uncompress/Base.pm index 8b64879233..038feb2c8c 100644 --- a/ext/Compress/IO/Base/lib/IO/Uncompress/Base.pm +++ b/ext/Compress/IO/Base/lib/IO/Uncompress/Base.pm @@ -39,17 +39,20 @@ sub smartRead my $offset = 0 ; - if (defined *$self->{InputLength} && - *$self->{InputLengthRemaining} <= 0) { - return 0 ; + if (defined *$self->{InputLength}) { + return 0 + if *$self->{InputLengthRemaining} <= 0 ; + $size = min($size, *$self->{InputLengthRemaining}); } if ( length *$self->{Prime} ) { #$$out = substr(*$self->{Prime}, 0, $size, '') ; $$out = substr(*$self->{Prime}, 0, $size) ; substr(*$self->{Prime}, 0, $size) = '' ; - if (length $$out == $size || defined *$self->{InputLength}) { - *$self->{InputLengthRemaining} -= length $$out; + if (length $$out == $size) { + *$self->{InputLengthRemaining} -= length $$out + if defined *$self->{InputLength}; + return length $$out ; } $offset = length $$out ; @@ -57,9 +60,9 @@ sub smartRead my $get_size = $size - $offset ; - if ( defined *$self->{InputLength} ) { - $get_size = min($get_size, *$self->{InputLengthRemaining}); - } + #if ( defined *$self->{InputLength} ) { + # $get_size = min($get_size, *$self->{InputLengthRemaining}); + #} if (defined *$self->{FH}) { *$self->{FH}->read($$out, $get_size, $offset) } @@ -90,7 +93,8 @@ sub smartRead { *$self->{BufferOffset} += length($$out) - $offset } } - *$self->{InputLengthRemaining} -= length $$out; + *$self->{InputLengthRemaining} -= length($$out) #- $offset + if defined *$self->{InputLength}; $self->saveStatus(length $$out < 0 ? STATUS_ERROR : STATUS_OK) ; @@ -892,13 +896,19 @@ sub gotoNextStream *$self->{UnCompSize}->reset(); *$self->{CompSize}->reset(); - return 0 - unless my $magic = $self->ckMagic(); - *$self->{Info} = $self->readHeader($magic); + my $magic = $self->ckMagic(); - return -1 - unless defined *$self->{Info} ; + if ( ! $magic) { + *$self->{EndStream} = 1 ; + return 0; + } + *$self->{Info} = $self->readHeader($magic); + + if ( ! defined *$self->{Info} ) { + *$self->{EndStream} = 1 ; + return -1; + } push @{ *$self->{InfoList} }, *$self->{Info} ; diff --git a/ext/Compress/IO/Zlib/lib/IO/Uncompress/AnyInflate.pm b/ext/Compress/IO/Zlib/lib/IO/Uncompress/AnyInflate.pm index 8c6be98f22..d4a08825cb 100644 --- a/ext/Compress/IO/Zlib/lib/IO/Uncompress/AnyInflate.pm +++ b/ext/Compress/IO/Zlib/lib/IO/Uncompress/AnyInflate.pm @@ -48,7 +48,8 @@ sub anyinflate sub getExtraParams { - return (); + use IO::Compress::Base::Common qw(:Parse); + return ( 'RawInflate' => [1, 1, Parse_boolean, 0] ) ; } sub ckParams @@ -76,7 +77,11 @@ sub mkUncomp *$self->{Uncomp} = $obj; - my $magic = $self->ckMagic( qw( RawInflate Inflate Gunzip Unzip ) ); + my @possible = qw( Inflate Gunzip Unzip ); + unshift @possible, 'RawInflate' + if 1 || $got->value('RawInflate'); + + my $magic = $self->ckMagic( @possible ); if ($magic) { *$self->{Info} = $self->readHeader($magic) |