From: Ilya Zakharevich Date: Wed, 1 Sep 1999 02:56:06 +0000 (-0400) Subject: Re: [ID 19990830.005] Assigning value of an op on an SV to said SV X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c212fd856fd0936eb904513d43838a7d254f2a09;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 19990830.005] Assigning value of an op on an SV to said SV To: ilya@math.ohio-state.edu (Ilya Zakharevich) Cc: perl5-porters@perl.org, cloos@adamsmith.ai Message-Id: <199909010656.CAA04478@monk.mps.ohio-state.edu> p4raw-id: //depot/cfgperl@4061 --- diff --git a/op.c b/op.c index a371d79..57ff104 100644 --- a/op.c +++ b/op.c @@ -5294,6 +5294,19 @@ Perl_ck_sassign(pTHX_ OP *o) { return o; } + if (kid->op_type == OP_JOIN) { + /* do_join has problems the arguments coincide with target. + In fact the second argument *can* safely coincide, + but ignore=pessimize this rare occasion. */ + OP *arg = kLISTOP->op_first->op_sibling; /* Skip PUSHMARK */ + + while (arg) { + if (arg->op_type == OP_PADSV + && arg->op_targ == kkid->op_targ) + return o; + arg = arg->op_sibling; + } + } kid->op_targ = kkid->op_targ; /* Now we do not need PADSV and SASSIGN. */ kid->op_sibling = o->op_sibling; /* NULL */ diff --git a/t/op/join.t b/t/op/join.t index eec4611..def5a9e 100755 --- a/t/op/join.t +++ b/t/op/join.t @@ -1,8 +1,6 @@ #!./perl -# $RCSfile: join.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:01 $ - -print "1..3\n"; +print "1..6\n"; @x = (1, 2, 3); if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";} @@ -10,3 +8,15 @@ if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";} if (join('',1,2,3) eq '123') {print "ok 2\n";} else {print "not ok 2\n";} if (join(':',split(/ /,"1 2 3")) eq '1:2:3') {print "ok 3\n";} else {print "not ok 3\n";} + +my $f = 'a'; +$f = join ',', 'b', $f, 'e'; +if ($f eq 'b,a,e') {print "ok 4\n";} else {print "# '$f'\nnot ok 4\n";} + +$f = 'a'; +$f = join ',', $f, 'b', 'e'; +if ($f eq 'a,b,e') {print "ok 5\n";} else {print "not ok 5\n";} + +$f = 'a'; +$f = join $f, 'b', 'e', 'k'; +if ($f eq 'baeak') {print "ok 6\n";} else {print "# '$f'\nnot ok 6\n";}