Message-ID: <14808.56336.594486.626712@busy.netsoft.ro>
p4raw-id: //depot/perl@7111
return ck_fun(o);
}
+OP *
+Perl_ck_substr(pTHX_ OP *o)
+{
+ o = ck_fun(o);
+ if ((o->op_flags & OPf_KIDS) && o->op_private == 4) {
+ OP *kid = cLISTOPo->op_first;
+
+ if (kid->op_type == OP_NULL)
+ kid = kid->op_sibling;
+ if (kid)
+ kid->op_flags |= OPf_MOD;
+
+ }
+ return o;
+}
+
/* A peephole optimizer. We visit the ops in the order they're to execute. */
void
# String stuff.
length length ck_lengthconst isTu% S?
-substr substr ck_fun st@ S S S? S?
+substr substr ck_substr st@ S S S? S?
vec vec ck_fun ist@ S S S
index index ck_index isT@ S S S?
#!./perl
-print "1..135\n";
+print "1..136\n";
#P = start of string Q = start of substr R = end of substr S = end of string
ok 134, length($z) == 5;
ok 135, $z eq "21\x{263a}10";
}
+
+# replacement should work on magical values
+require Tie::Scalar;
+my %data;
+tie $data{'a'}, 'Tie::StdScalar'; # makes $data{'a'} magical
+$data{a} = "firstlast";
+ok 136, substr($data{'a'}, 0, 5, "") eq "first" && $data{'a'} eq "last";