summaryrefslogtreecommitdiff
path: root/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm
diff options
context:
space:
mode:
Diffstat (limited to 'ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm')
-rw-r--r--ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm52
1 files changed, 29 insertions, 23 deletions
diff --git a/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm b/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm
index 1563dbab2c..71321e0d80 100644
--- a/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm
+++ b/ext/IO_Compress_Base/lib/IO/Uncompress/Base.pm
@@ -6,16 +6,15 @@ use warnings;
use bytes;
our (@ISA, $VERSION, @EXPORT_OK, %EXPORT_TAGS);
-#@ISA = qw(Exporter IO::File);
-@ISA = qw(Exporter );
+@ISA = qw(Exporter IO::File);
-$VERSION = '2.004';
+$VERSION = '2.005';
use constant G_EOF => 0 ;
use constant G_ERR => -1 ;
-use IO::Compress::Base::Common 2.004 ;
+use IO::Compress::Base::Common 2.005 ;
#use Parse::Parameters ;
use IO::File ;
@@ -974,14 +973,9 @@ sub read
my $self = shift ;
return G_EOF if *$self->{Closed} ;
- return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ;
my $buffer ;
- #$self->croakError(*$self->{ClassName} .
- # "::read: buffer parameter is read-only")
- # if Compress::Raw::Zlib::_readonly_ref($_[0]);
-
if (ref $_[0] ) {
$self->croakError(*$self->{ClassName} . "::read: buffer parameter is read-only")
if readonly(${ $_[0] });
@@ -1000,6 +994,22 @@ sub read
my $length = $_[1] ;
my $offset = $_[2] || 0;
+ if (! *$self->{AppendOutput}) {
+ if (! $offset) {
+ $$buffer = '' ;
+ }
+ else {
+ if ($offset > length($$buffer)) {
+ $$buffer .= "\x00" x ($offset - length($$buffer));
+ }
+ else {
+ substr($$buffer, $offset) = '';
+ }
+ }
+ }
+
+ return G_EOF if !length *$self->{Pending} && *$self->{EndStream} ;
+
# the core read will return 0 if asked for 0 bytes
return 0 if defined $length && $length == 0 ;
@@ -1008,8 +1018,6 @@ sub read
$self->croakError(*$self->{ClassName} . "::read: length parameter is negative")
if $length < 0 ;
- $$buffer = '' unless *$self->{AppendOutput} || $offset ;
-
# Short-circuit if this is a simple read, with no length
# or offset specified.
unless ( $length || $offset) {
@@ -1031,6 +1039,7 @@ sub read
# or both are specified.
my $out_buffer = *$self->{Pending} ;
+
while (! *$self->{EndStream} && length($out_buffer) < $length)
{
my $buf_len = $self->_raw_read(\$out_buffer);
@@ -1044,21 +1053,18 @@ sub read
return 0
if $length == 0 ;
+ $$buffer = ''
+ if ! defined $$buffer;
+
+ $offset = length $$buffer
+ if *$self->{AppendOutput} ;
+
*$self->{Pending} = $out_buffer;
$out_buffer = \*$self->{Pending} ;
- if ($offset) {
- $$buffer .= "\x00" x ($offset - length($$buffer))
- if $offset > length($$buffer) ;
- #substr($$buffer, $offset) = substr($$out_buffer, 0, $length, '') ;
- substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ;
- substr($$out_buffer, 0, $length) = '' ;
- }
- else {
- #$$buffer .= substr($$out_buffer, 0, $length, '') ;
- $$buffer .= substr($$out_buffer, 0, $length) ;
- substr($$out_buffer, 0, $length) = '' ;
- }
+ #substr($$buffer, $offset) = substr($$out_buffer, 0, $length, '') ;
+ substr($$buffer, $offset) = substr($$out_buffer, 0, $length) ;
+ substr($$out_buffer, 0, $length) = '' ;
return $length ;
}