From: Torsten Foertsch Date: Sat, 22 Nov 2003 13:15:53 +0000 (+0100) Subject: Re: bug or a feature? X-Git-Tag: perl-5.9.1~478 X-Git-Url: https://perl5.git.perl.org/perl5.git/commitdiff_plain/2d7268923bcf822410c0286f060732300ab91ea7 Re: bug or a feature? Date: Sat, 22 Nov 2003 13:15:53 +0100 Message-Id: <200311221315.58539.torsten.foertsch@gmx.net> and Date: Sat, 22 Nov 2003 14:21:45 +0100 Message-Id: <200311221421.48940.torsten.foertsch@gmx.net> (test moved to t/op/readline.t) p4raw-id: //depot/perl@21787 --- diff --git a/pp_hot.c b/pp_hot.c index 5f23bb3..0bcb7bd 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1567,7 +1567,9 @@ Perl_do_readline(pTHX) for (;;) { PUTBACK; if (!sv_gets(sv, fp, offset) - && (type == OP_GLOB || SNARF_EOF(gimme, PL_rs, io, sv))) + && (type == OP_GLOB + || SNARF_EOF(gimme, PL_rs, io, sv) + || PerlIO_error(fp))) { PerlIO_clearerr(fp); if (IoFLAGS(io) & IOf_ARGV) { diff --git a/t/op/readline.t b/t/op/readline.t index 46375da..dec3e50 100644 --- a/t/op/readline.t +++ b/t/op/readline.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 11; +plan tests => 13; eval { for (\2) { $_ = } }; like($@, 'Modification of a read-only value attempted', '[perl #19566]'); @@ -55,6 +55,30 @@ foreach my $l (1, 21) { $k .= ; is ($k, "$perl rules\n", 'rcatline to COW sv for length ' . length $perl); } + +use strict; +use File::Spec; + +open F, File::Spec->curdir and sysread F, $_, 1; +my $err = $! + 0; +close F; + +SKIP: { + skip 2 => "you can read directories as plain files" unless( $err ); + + $!=0; + open F, File::Spec->curdir and $_=; + ok( $!==$err && !defined($_) => 'readline( DIRECTORY )' ); + close F; + + $!=0; + { local $/; + open F, File::Spec->curdir and $_=; + ok( $!==$err && !defined($_) => 'readline( DIRECTORY ) slurp mode' ); + close F; + } +} + __DATA__ moo moo