summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2013-03-25 20:06:16 +0000
committersthen <sthen@openbsd.org>2013-03-25 20:06:16 +0000
commit898184e3e61f9129feb5978fad5a8c6865f00b92 (patch)
tree56f32aefc1eed60b534611007c7856f82697a205 /gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter
parentPGSHIFT -> PAGE_SHIFT (diff)
downloadwireguard-openbsd-898184e3e61f9129feb5978fad5a8c6865f00b92.tar.xz
wireguard-openbsd-898184e3e61f9129feb5978fad5a8c6865f00b92.zip
import perl 5.16.3 from CPAN - worked on by Andrew Fresh and myself
Diffstat (limited to 'gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter')
-rw-r--r--gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm6
-rw-r--r--gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm121
-rw-r--r--gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm6
3 files changed, 108 insertions, 25 deletions
diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm
index 98677e3c09f..516c5dda4f0 100644
--- a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm
+++ b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Bunzip2.pm
@@ -4,12 +4,12 @@ use strict;
use warnings;
use bytes;
-use IO::Compress::Base::Common 2.024 qw(:Status);
+use IO::Compress::Base::Common 2.048 qw(:Status);
-use Compress::Raw::Bzip2 2.024 ;
+use Compress::Raw::Bzip2 2.048 ;
our ($VERSION, @ISA);
-$VERSION = '2.024';
+$VERSION = '2.048';
sub mkUncompObject
{
diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm
index 27de6e0f36b..5d74d042124 100644
--- a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm
+++ b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Identity.pm
@@ -4,47 +4,131 @@ use warnings;
use strict;
use bytes;
-use IO::Compress::Base::Common 2.024 qw(:Status);
+use IO::Compress::Base::Common 2.048 qw(:Status);
+use IO::Compress::Zip::Constants ;
our ($VERSION);
-$VERSION = '2.024';
+$VERSION = '2.048';
-use Compress::Raw::Zlib 2.024 ();
+use Compress::Raw::Zlib 2.048 ();
sub mkUncompObject
{
+ my $streaming = shift;
+ my $zip64 = shift;
+
my $crc32 = 1; #shift ;
my $adler32 = shift;
- bless { 'CompSize' => 0,
+ bless { 'CompSize' => new U64 , # 0,
'UnCompSize' => 0,
'wantCRC32' => $crc32,
'CRC32' => Compress::Raw::Zlib::crc32(''),
'wantADLER32'=> $adler32,
'ADLER32' => Compress::Raw::Zlib::adler32(''),
'ConsumesInput' => 1,
+ 'Streaming' => $streaming,
+ 'Zip64' => $zip64,
+ 'DataHdrSize' => $zip64 ? 24 : 16,
+ 'Pending' => '',
} ;
}
+
sub uncompr
{
my $self = shift;
+ my $in = $_[0];
my $eof = $_[2];
- if (defined ${ $_[0] } && length ${ $_[0] }) {
- $self->{CompSize} += length ${ $_[0] } ;
- $self->{UnCompSize} = $self->{CompSize} ;
-
- $self->{CRC32} = Compress::Raw::Zlib::crc32($_[0], $self->{CRC32})
- if $self->{wantCRC32};
-
- $self->{ADLER32} = Compress::Zlib::adler32($_[0], $self->{ADLER32})
- if $self->{wantADLER32};
-
- ${ $_[1] } .= ${ $_[0] };
- ${ $_[0] } = "";
+ my $len = length $$in;
+ my $remainder = '';
+
+ if (defined $$in && $len) {
+
+ if ($self->{Streaming}) {
+
+ if (length $self->{Pending}) {
+ $$in = $self->{Pending} . $$in ;
+ $len = length $$in;
+ $self->{Pending} = '';
+ }
+
+ my $ind = index($$in, "\x50\x4b\x07\x08");
+
+ if ($ind < 0) {
+ $len = length $$in;
+ if ($len >= 3 && substr($$in, -3) eq "\x50\x4b\x07") {
+ $ind = $len - 3 ;
+ }
+ elsif ($len >= 2 && substr($$in, -2) eq "\x50\x4b") {
+ $ind = $len - 2 ;
+ }
+ elsif ($len >= 1 && substr($$in, -1) eq "\x50") {
+ $ind = $len - 1 ;
+ }
+ }
+
+ if ($ind >= 0) {
+ $remainder = substr($$in, $ind) ;
+ substr($$in, $ind) = '' ;
+ }
+ }
+
+ if (length $remainder && length $remainder < $self->{DataHdrSize}) {
+ $self->{Pending} = $remainder ;
+ $remainder = '';
+ }
+ elsif (length $remainder >= $self->{DataHdrSize}) {
+ my $crc = unpack "V", substr($remainder, 4);
+ if ($crc == Compress::Raw::Zlib::crc32($$in, $self->{CRC32})) {
+ my ($l1, $l2) ;
+
+ if ($self->{Zip64}) {
+ $l1 = U64::newUnpack_V64(substr($remainder, 8));
+ $l2 = U64::newUnpack_V64(substr($remainder, 16));
+ }
+ else {
+ $l1 = U64::newUnpack_V32(substr($remainder, 8));
+ $l2 = U64::newUnpack_V32(substr($remainder, 12));
+ }
+
+ my $newLen = $self->{CompSize}->clone();
+ $newLen->add(length $$in);
+ if ($l1->equal($l2) && $l1->equal($newLen) ) {
+ $eof = 1;
+ }
+ else {
+ $$in .= substr($remainder, 0, 4) ;
+ $remainder = substr($remainder, 4);
+ #$self->{Pending} = substr($remainder, 4);
+ #$remainder = '';
+ $eof = 0;
+ }
+ }
+ else {
+ $$in .= substr($remainder, 0, 4) ;
+ $remainder = substr($remainder, 4);
+ #$self->{Pending} = substr($remainder, 4);
+ #$remainder = '';
+ $eof = 0;
+ }
+ }
+
+ if (length $$in) {
+ $self->{CompSize}->add(length $$in) ;
+
+ $self->{CRC32} = Compress::Raw::Zlib::crc32($$in, $self->{CRC32})
+ if $self->{wantCRC32};
+
+ $self->{ADLER32} = Compress::Zlib::adler32($$in, $self->{ADLER32})
+ if $self->{wantADLER32};
+ }
+
+ ${ $_[1] } .= $$in;
+ $$in = $remainder;
}
return STATUS_ENDSTREAM if $eof;
@@ -63,7 +147,6 @@ sub reset
return STATUS_OK ;
}
-
#sub count
#{
# my $self = shift ;
@@ -73,13 +156,13 @@ sub reset
sub compressedBytes
{
my $self = shift ;
- return $self->{UnCompSize} ;
+ return $self->{CompSize} ;
}
sub uncompressedBytes
{
my $self = shift ;
- return $self->{UnCompSize} ;
+ return $self->{CompSize} ;
}
sub sync
diff --git a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm
index aac1e413ffe..c0f3542a98a 100644
--- a/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm
+++ b/gnu/usr.bin/perl/cpan/IO-Compress/lib/IO/Uncompress/Adapter/Inflate.pm
@@ -4,11 +4,11 @@ use strict;
use warnings;
use bytes;
-use IO::Compress::Base::Common 2.024 qw(:Status);
-use Compress::Raw::Zlib 2.024 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS);
+use IO::Compress::Base::Common 2.048 qw(:Status);
+use Compress::Raw::Zlib 2.048 qw(Z_OK Z_BUF_ERROR Z_STREAM_END Z_FINISH MAX_WBITS);
our ($VERSION);
-$VERSION = '2.024';
+$VERSION = '2.048';