if ($writing) {
$gz = new IO::Compress::Gzip($file, Minimal => 1, AutoClose => 1,
- BinModeOut => 1, %defOpts)
+ %defOpts)
or $Compress::Zlib::gzerrno = $IO::Compress::Gzip::GzipError;
}
else {
$gz = new IO::Uncompress::Gunzip($file,
Transparent => 1,
- BinModeIn => 1, Append => 0,
+ Append => 0,
AutoClose => 1, Strict => 0)
or $Compress::Zlib::gzerrno = $IO::Uncompress::Gunzip::GunzipError;
}
WANT_HASH
);
-our ($wantBinmode);
-$wantBinmode = ($] >= 5.006 && eval ' ${^UNICODE} || ${^UTF8LOCALE} ')
+our ($needBinmode);
+$needBinmode = ($^O eq 'MSWin32' ||
+ ($] >= 5.006 && eval ' ${^UNICODE} || ${^UTF8LOCALE} '))
? 1 : 0 ;
-sub setBinModeInput($$)
+sub setBinModeInput($)
{
my $handle = shift ;
- my $want = defined $_[0] ? shift : $wantBinmode ;
binmode $handle
- if $want;
+ if $needBinmode;
}
-sub setBinModeOutput($$)
+sub setBinModeOutput($)
{
my $handle = shift ;
- my $want = defined $_[0] ? shift : $wantBinmode ;
binmode $handle
- if $want;
+ if $needBinmode;
}
sub isaFilehandle($)
'Strict' => [Parse_boolean, 1],
'Append' => [Parse_boolean, 0],
'Merge' => [Parse_boolean, 0],
- 'BinModeIn' => [Parse_boolean, undef],
- 'BinModeOut'=> [Parse_boolean, undef],
+ 'BinModeIn' => [Parse_boolean, 0],
# zlib behaviour
#'Method' => [Parse_unsigned, Z_DEFLATED],
'Strict' => [Parse_boolean, 1],
'Append' => [Parse_boolean, 0],
'Merge' => [Parse_boolean, 0],
- 'BinModeIn' => [Parse_boolean, undef],
- 'BinModeOut'=> [Parse_boolean, undef],
+ 'BinModeIn' => [Parse_boolean, 0],
# zlib behaviour
#'Method' => [Parse_unsigned, Z_DEFLATED],
if ($outType eq 'handle') {
$outValue->flush() ;
*$obj->{FH} = $outValue ;
- setBinModeOutput(*$obj->{FH}, $got->valueOrDefault('BinModeOut')) ;
+ setBinModeOutput(*$obj->{FH}) ;
*$obj->{Handle} = 1 ;
if ($appendOutput)
{
*$obj->{FH} = new IO::File "$mode $outValue"
or return $obj->saveErrorString(undef, "cannot open file '$outValue': $!", $!) ;
*$obj->{StdIO} = ($outValue eq '-');
- setBinModeOutput(*$obj->{FH}, $got->valueOrDefault('BinModeOut')) ;
+ setBinModeOutput(*$obj->{FH}) ;
}
if (!$rfc1951) {
$fh = new IO::File "<$input"
or return $self->saveErrorString(undef, "cannot open file '$input': $!", $!) ;
}
- setBinModeInput($fh, *$self->{Got}->valueOrDefault('BinModeIn')) ;
+ binmode $fh if *$self->{Got}->valueOrDefault('BinModeIn') ;
my $status ;
my $buff ;
'Transparent' => [Parse_any, 1],
'Scan' => [Parse_boolean, 0],
'InputLength' => [Parse_unsigned, undef],
- 'BinModeIn' => [Parse_boolean, undef],
- 'BinModeOut' => [Parse_boolean, undef],
+ 'BinModeOut' => [Parse_boolean, 0],
#'Todo - Revert to ordinary file on end Z_STREAM_END'=> 0,
# ContinueAfterEof
} ;
*$obj->{LineNo} = 0;
}
- setBinModeInput(*$obj->{FH}, $got->valueOrDefault('BinModeIn')) ;
+ setBinModeInput(*$obj->{FH}) ;
my $buff = "" ;
*$obj->{Buffer} = \$buff ;
if $x->{Got}->value('Append') ;
$x->{fh} = new IO::File "$mode $output"
or return retErr($x, "cannot open file '$output': $!") ;
- setBinModeOutput($x->{fh}, $x->{Got}->valueOrDefault('BinModeOut'));
+ binmode $x->{fh} if $x->{Got}->valueOrDefault('BinModeOut');
}
elsif ($x->{outType} eq 'handle') {
$x->{fh} = $output;
- setBinModeOutput($x->{fh}, $x->{Got}->valueOrDefault('BinModeOut'));
+ binmode $x->{fh} if $x->{Got}->valueOrDefault('BinModeOut');
if ($x->{Got}->value('Append')) {
seek($x->{fh}, 0, SEEK_END)
or return retErr($x, "Cannot seek to end of output filehandle: $!") ;
if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
- plan tests => 788 + $extra ;
+ plan tests => 920 + $extra ;
use_ok('Compress::Zlib', 2) ;
use_ok('Compress::Gzip::Constants') ;
}
+for my $value ( "0D", "0A", "0A0D", "0D0A", "0A0A", "0D0D")
+{
+ title "Comment with $value" ;
+
+ my $v = pack "H*", $value;
+ my $comment = "my${v}comment$v";
+ my $hdr = readHeaderInfo $name,
+ Time => 0,
+ -TextFlag => 1,
+ -Name => "",
+ -Comment => $comment,
+ -ExtraField => "";
+ my $after = time ;
+
+ is $hdr->{Time}, 0 ;
+
+ ok defined $hdr->{Name} ;
+ ok $hdr->{Name} eq "";
+ ok defined $hdr->{Comment} ;
+ is $hdr->{Comment}, $comment;
+ ok defined $hdr->{ExtraFieldRaw} ;
+ ok $hdr->{ExtraFieldRaw} eq "";
+ is $hdr->{ExtraFlags}, 0;
+
+ ok ! $hdr->{isMinimalHeader} ;
+ ok $hdr->{TextFlag} ;
+ ok ! defined $hdr->{HeaderCRC} ;
+ is $hdr->{OsID}, $ThisOS_code ;
+
+}
+
{
title "Check crchdr" ;