Open p5pRT opened 15 years ago
When using :encoding\, read() returns undef at eof rather than zero.
----- BEGIN code ----- #!/usr/bin/perl
use strict; use warnings;
sub test { my ($fh) = @_; my $buf = ''; for (1..3) { my $rv = read($fh\, $buf\, 1\, length($buf)); if (defined($rv)) { print("read = $rv\n"); } else { print("read = undef\, \$!=$!\n"); } } }
{ open(my $fh\, '\<'\, \'ab') or die; test($fh); } { open(my $fh\, '\<:encoding(iso-8859-1)'\, \'ab') or die; test($fh); } ----- END code -----
----- BEGIN output ----- read = 1 read = 1 read = 0
read = 1 read = 1 read = undef\, $!= ----- END output -----
(newline added for readability)
I haven't managed to track down the cause.
Replicated on 5.10.0\, vanilla 5.10.1 and 5.11.0
@obra - Status changed from 'new' to 'open'
On Sat Oct 10 12:33:53 2009\, jesse wrote:
Replicated on 5.10.0\, vanilla 5.10.1 and 5.11.0
Also\, 5.8.8
When using :encoding\, read() returns undef at eof rather than zero.
Thanks very much for your report\, Eric. As it turns out\, this is a somewhat longstanding bug and pertains to all PerlIO layers\, not just :encoding().
I've added a TODO test based on your report to blead as of commit 86cb0d3.
Best\, Jesse
16:21 \<@Nicholas> also\, as to PerIO behaviour 16:21 \<@Nicholas> I think that the answer is "whatever 5.005 does without PerlIO is more likely to be the 'right' answer"
Migrated from rt.perl.org#69332 (status was 'open')
Searchable as RT69332$