From: Rafael Garcia-Suarez Date: Wed, 9 Oct 2002 19:17:08 +0000 (+0000) Subject: Fix bug #17823 : non-modifying tr/// stringifies references X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d59e14dbffe53a28b0845a7d6b4250babf9e83ac;p=p5sagit%2Fp5-mst-13.2.git Fix bug #17823 : non-modifying tr/// stringifies references p4raw-id: //depot/perl@17984 --- diff --git a/doop.c b/doop.c index a8d1672..20dc68b 100644 --- a/doop.c +++ b/doop.c @@ -608,10 +608,11 @@ Perl_do_trans(pTHX_ SV *sv) (void)SvPV(sv, len); if (!len) return 0; - if (!SvPOKp(sv)) - (void)SvPV_force(sv, len); - if (!(PL_op->op_private & OPpTRANS_IDENTICAL)) + if (!(PL_op->op_private & OPpTRANS_IDENTICAL)) { + if (!SvPOKp(sv)) + (void)SvPV_force(sv, len); (void)SvPOK_only_UTF8(sv); + } DEBUG_t( Perl_deb(aTHX_ "2.TBL\n")); diff --git a/t/op/tr.t b/t/op/tr.t index 69f3796..3a4f610 100755 --- a/t/op/tr.t +++ b/t/op/tr.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 97; +plan tests => 99; my $Is_EBCDIC = (ord('i') == 0x89 & ord('J') == 0xd1); @@ -379,3 +379,7 @@ my %foo = (); eval '$foo{bar} =~ tr/N/N/'; is( $@, '', 'implicit count outside hash bounds' ); is( scalar keys %foo, 0, " doesn't extend the hash"); + +$x = \"foo"; +is( $x =~ tr/A/A/, 2, 'non-modifying tr/// on a scalar ref' ); +is( ref $x, 'SCALAR', " doesn't stringify its argument" );