Re: [ID 20020713.001] chomp($data=<tied_fh>) strangeness.
Hugo van der Sanden [Sat, 13 Jul 2002 17:44:02 +0000 (18:44 +0100)]
Message-id: <200207131644.g6DGi2214456@crypt.compulink.co.uk>

p4raw-id: //depot/perl@17716

pp_hot.c
t/op/tiehandle.t

index 8f042b9..8e36c8a 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1490,8 +1490,11 @@ Perl_do_readline(pTHX)
        call_method("READLINE", gimme);
        LEAVE;
        SPAGAIN;
-       if (gimme == G_SCALAR)
-           SvSetMagicSV_nosteal(TARG, TOPs);
+       if (gimme == G_SCALAR) {
+           SV* result = POPs;
+           SvSetSV_nosteal(TARG, result);
+           PUSHTARG;
+       }
        RETURN;
     }
     fp = Nullfp;
index 257a613..818cecf 100755 (executable)
@@ -77,7 +77,7 @@ package main;
 
 use Symbol;
 
-print "1..39\n";
+print "1..40\n";
 
 my $fh = gensym;
 
@@ -230,3 +230,15 @@ ok($r == 1);
     Implement::compare(PRINT => @received);
 }
 
+{
+    # [ID 20020713.001] chomp($data=<tied_fh>)
+    local *TEST;
+    tie *TEST, 'CHOMP';
+    my $data;
+    chomp($data = <TEST>);
+    ok($data eq 'foobar');
+
+    package CHOMP;
+    sub TIEHANDLE { bless {}, $_[0] }
+    sub READLINE { "foobar\n" }
+}