This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix bug #39037: rcatline doesn't stringify references
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 14 Nov 2006 14:19:46 +0000 (14:19 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 14 Nov 2006 14:19:46 +0000 (14:19 +0000)
p4raw-id: //depot/perl@29273

pp_hot.c
t/op/readline.t

index 025e957..9b293de 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1640,8 +1640,12 @@ Perl_do_readline(pTHX)
   have_fp:
     if (gimme == G_SCALAR) {
        sv = TARG;
-       if (SvROK(sv))
-           sv_unref(sv);
+       if (SvROK(sv)) {
+           if (type == OP_RCATLINE)
+               SvPV_force_nolen(sv);
+           else
+               sv_unref(sv);
+       }
        else if (isGV_with_GP(sv)) {
            SvPV_force_nolen(sv);
        }
index 6dfe695..ffde6f1 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 14;
+plan tests => 15;
 
 eval { for (\2) { $_ = <FH> } };
 like($@, 'Modification of a read-only value attempted', '[perl #19566]');
@@ -83,8 +83,13 @@ fresh_perl_is('BEGIN{<>}', '',
               { switches => ['-w'], stdin => '', stderr => 1 },
               'No ARGVOUT used only once warning');
 
+my $obj = bless [];
+$obj .= <DATA>;
+like($obj, qr/main=ARRAY.*world/, 'rcatline and refs');
+
 __DATA__
 moo
 moo
  rules
  rules
+world