Skip Menu |

This queue is for tickets about the Git-PurePerl CPAN distribution.

Report information
The Basics
Id: 52677
Status: resolved
Priority: 0/
Queue: Git-PurePerl

People
Owner: Nobody in particular
Requestors: kmx [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Win32 fix (setting binmode on filehandles)
Hi, please consider the enclosed Win32 compatibility patch. It mostly sets binary mode on filehandles used for writing binary data. Generally is not the best idea to use print() call for writting binary data (perhaps syswrite would be better) but did not want to make big changes. -- kmx
Subject: Git-PurePerl-0.43.patch
diff -r -u Git-PurePerl-0.43/lib/Git/PurePerl/Loose.pm Git-PurePerl-0.43.patched/lib/Git/PurePerl/Loose.pm --- Git-PurePerl-0.43/lib/Git/PurePerl/Loose.pm 2009-11-02 21:51:22.000000000 +0100 +++ Git-PurePerl-0.43.patched/lib/Git/PurePerl/Loose.pm 2009-12-11 00:43:45.937500000 +0100 @@ -38,6 +38,7 @@ $filename->parent->mkpath; my $compressed = compress( $object->raw ); my $fh = $filename->openw; + binmode($fh); #important for Win32 $fh->print($compressed) || die "Error writing to $filename: $!"; } diff -r -u Git-PurePerl-0.43/lib/Git/PurePerl/Pack/WithIndex.pm Git-PurePerl-0.43.patched/lib/Git/PurePerl/Pack/WithIndex.pm --- Git-PurePerl-0.43/lib/Git/PurePerl/Pack/WithIndex.pm 2009-11-02 21:51:22.000000000 +0100 +++ Git-PurePerl-0.43.patched/lib/Git/PurePerl/Pack/WithIndex.pm 2009-12-06 22:08:29.910321300 +0100 @@ -17,6 +17,7 @@ $self->index_filename($index_filename); my $index_fh = IO::File->new($index_filename) || confess($!); + $index_fh->binmode(); $index_fh->read( my $signature, 4 ); $index_fh->read( my $version, 4 ); $version = unpack( 'N', $version ); diff -r -u Git-PurePerl-0.43/lib/Git/PurePerl/Pack.pm Git-PurePerl-0.43.patched/lib/Git/PurePerl/Pack.pm --- Git-PurePerl-0.43/lib/Git/PurePerl/Pack.pm 2009-11-02 21:51:22.000000000 +0100 +++ Git-PurePerl-0.43.patched/lib/Git/PurePerl/Pack.pm 2009-12-11 00:34:57.250000000 +0100 @@ -26,6 +26,7 @@ sub BUILD { my $self = shift; my $fh = IO::File->new( $self->filename ) || confess($!); + $fh->binmode(); $self->fh($fh); } @@ -91,7 +92,7 @@ $fh->read( my $block, 4096 ) || die $!; my $status = $deflate->inflate( $block, $out ); } - confess "$out is not $size" unless length($out) == $size; + confess length($out)." is not $size" unless length($out) == $size; $fh->seek( $offset + $deflate->total_in, 0 ) || die $!; return $out; diff -r -u Git-PurePerl-0.43/lib/Git/PurePerl.pm Git-PurePerl-0.43.patched/lib/Git/PurePerl.pm --- Git-PurePerl-0.43/lib/Git/PurePerl.pm 2009-11-25 20:47:50.000000000 +0100 +++ Git-PurePerl-0.43.patched/lib/Git/PurePerl.pm 2009-12-11 00:36:58.546875000 +0100 @@ -427,6 +427,7 @@ sub _add_file { my ( $class, $filename, $contents ) = @_; my $fh = $filename->openw || confess "Error opening to $filename: $!"; + binmode($fh); #important for Win32 $fh->print($contents) || confess "Error writing to $filename: $!"; $fh->close || confess "Error closing $filename: $!"; }
Fixed in 0.45, sorry for dropping this on the floor.