* [PATCH] Fix git-remote for ActiveState Perl
@ 2007-08-22 16:13 Alex Riesen
2007-08-22 20:19 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Alex Riesen @ 2007-08-22 16:13 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
For reason unknown a package in ActiveState Perl 5.8.7 must implement
READLINE method differently for scalar and array context. The code
tested to work for more sane and recent version of perl (5.8.8 shipped
with Ubuntu), so maybe it was always a requirement.
Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
---
Without this only the first remote can be used if you are unlucky
enough to use that perl. There are probably more breakages, as only
first line of a file/stream can be read. Not many use Git.pm on
Windows and ActiveState Perl, so it went unnoticed for long time.
perl/Git.pm | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 8fd3611..3f4080c 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -860,7 +860,13 @@ sub READLINE {
if ($self->{i} >= scalar @{$self->{data}}) {
return undef;
}
- return $self->{'data'}->[ $self->{i}++ ];
+ my $i = $self->{i};
+ if (wantarray) {
+ $self->{i} = $#{$self->{'data'}} + 1;
+ return splice(@{$self->{'data'}}, $i);
+ }
+ $self->{i} = $i + 1;
+ return $self->{'data'}->[ $i ];
}
sub CLOSE {
--
1.5.3.rc6.19.g4d600f
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix git-remote for ActiveState Perl
2007-08-22 16:13 [PATCH] Fix git-remote for ActiveState Perl Alex Riesen
@ 2007-08-22 20:19 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2007-08-22 20:19 UTC (permalink / raw)
To: Alex Riesen; +Cc: git
Alex Riesen <raa.lkml@gmail.com> writes:
> For reason unknown a package in ActiveState Perl 5.8.7 must implement
> READLINE method differently for scalar and array context. The code
> tested to work for more sane and recent version of perl (5.8.8 shipped
> with Ubuntu), so maybe it was always a requirement.
Well spotted.
Unfortunately, the manual perltie.pod is very sketchy on this
issue, and only says:
This method will be called when the handle is read from via <HANDLE>.
The method should return undef when there is no more data.
The default implementation in Tie::StdHandle (Tie/Handle.pm)
does agree with you by doing this:
sub READLINE { my $fh = $_[0]; <$fh> }
So I am fairly confident that your patch is the right fix.
Interestingly, CPAN::Tarzip::READLINE (CPAN.pm) gets it wrong ;-)
and caters only to calls in scalar context if I am reading the
code correctly.
Thanks. Will apply.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-08-22 20:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-22 16:13 [PATCH] Fix git-remote for ActiveState Perl Alex Riesen
2007-08-22 20:19 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).