In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/0f6f92e0b139f81313e47d8eb6d0c323dfd77b62?hp=2b5060aeb95612aea17de446e9d72793e28bf8a9>

- Log -----------------------------------------------------------------
commit 0f6f92e0b139f81313e47d8eb6d0c323dfd77b62
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Thu Mar 5 17:37:33 2015 +0100

    readline should behave as <>, not <<>>
    
    This fixes bug #123990. The cause was that one promotion to
    OP_READLINE was not cleaning the special flag on that op.
-----------------------------------------------------------------------

Summary of changes:
 op.c        |  2 +-
 t/io/argv.t | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/op.c b/op.c
index 9ddfb9b..bbf6a8d 100644
--- a/op.c
+++ b/op.c
@@ -10334,7 +10334,7 @@ Perl_ck_readline(pTHX_ OP *o)
     }
     else {
        OP * const newop
-           = newUNOP(OP_READLINE, o->op_flags | OPf_SPECIAL, newGVOP(OP_GV, 0, 
PL_argvgv));
+           = newUNOP(OP_READLINE, 0, newGVOP(OP_GV, 0, PL_argvgv));
        op_free(o);
        return newop;
     }
diff --git a/t/io/argv.t b/t/io/argv.t
index 03440a2..a9da09f 100644
--- a/t/io/argv.t
+++ b/t/io/argv.t
@@ -7,7 +7,7 @@ BEGIN {
 
 BEGIN { require "./test.pl"; }
 
-plan(tests => 36);
+plan(tests => 37);
 
 my ($devnull, $no_devnull);
 
@@ -39,6 +39,15 @@ is($x, "1a line\n2a line\n", '<> from two files');
     );
     is($x, "a line\nfoo\n", '<> from a file and STDIN');
 
+    # readline should behave as <>, not <<>>
+    $x = runperl(
+        prog   => 'while (readline) { print $_; }',
+        stdin  => "foo\n",
+        stderr         => 1,
+        args   => [ '-' ],
+    );
+    is($x, "foo\n", 'readline() from STDIN');
+
     $x = runperl(
        prog    => 'while (<>) { print $_; }',
        stdin   => "foo\n",
@@ -91,7 +100,7 @@ close TRY or die "Could not close: $!";
 @ARGV = ('Io_argv1.tmp', 'Io_argv2.tmp');
 $^I = '_bak';   # not .bak which confuses VMS
 $/ = undef;
-my $i = 10;
+my $i = 11;
 while (<>) {
     s/^/ok $i\n/;
     ++$i;
@@ -116,7 +125,7 @@ open STDIN, 'Io_argv1.tmp' or die $!;
 @ARGV = ();
 ok( !eof(),     'STDIN has something' );
 
-is( <>, "ok 10\n" );
+is( <>, "ok 11\n" );
 
 SKIP: {
     skip_if_miniperl($no_devnull, 4);
@@ -196,13 +205,13 @@ like($x, qr/^Can't open -: .* at -e line 1/, '<<>> does 
not treat - as STDIN');
         prog   => 'push @ARGV,q//;print while <>',
         stderr => 1,
     );
-    like($x, qr/^Can't open : .* at -e line 1/, '<<>> does not treat - as 
STDIN');
+    like($x, qr/^Can't open : .* at -e line 1/, '<> does not open empty string 
in ARGV');
 
     $x = runperl(
         prog   => 'push @ARGV,q//;print while <<>>',
         stderr => 1,
     );
-    like($x, qr/^Can't open : .* at -e line 1/, '<<>> does not treat - as 
STDIN');
+    like($x, qr/^Can't open : .* at -e line 1/, '<<>> does not open empty 
string in ARGV');
 }
 
 SKIP: {

--
Perl5 Master Repository

Reply via email to