summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-19 18:58:43 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-19 18:58:43 +0000
commit45005bfbea59991ddd034f988e68062807387b7b (patch)
tree6ff32689626cb3b2431a16153a386f04acc13672 /op.c
parentf25c30a36f648c97d3a53def7f4ce5abc9040330 (diff)
downloadperl-45005bfbea59991ddd034f988e68062807387b7b.tar.gz
UTF-8 tr/// battle continues, ammunition from Inaba Hiroto.
TODO: tests. p4raw-id: //depot/perl@9242
Diffstat (limited to 'op.c')
-rw-r--r--op.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/op.c b/op.c
index 25e7aa5058..5cdb3df2f7 100644
--- a/op.c
+++ b/op.c
@@ -2710,7 +2710,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
I32 from_utf = o->op_private & OPpTRANS_FROM_UTF;
I32 to_utf = o->op_private & OPpTRANS_TO_UTF;
U8* tsave = from_utf ? NULL : trlist_upgrade(&t, &tend);
- U8* rsave = to_utf ? NULL : trlist_upgrade(&r, &rend);
+ U8* rsave = (to_utf || !rlen) ? NULL : trlist_upgrade(&r, &rend);
if (complement) {
U8 tmpbuf[UTF8_MAXLEN+1];
@@ -2832,9 +2832,10 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
if (rfirst + diff > max)
max = rfirst + diff;
- rfirst += diff + 1;
if (!grows)
- grows = (UNISKIP(tfirst) < UNISKIP(rfirst));
+ grows = (tfirst < rfirst &&
+ UNISKIP(tfirst) < UNISKIP(rfirst + diff));
+ rfirst += diff + 1;
}
tfirst += diff + 1;
}
@@ -2856,7 +2857,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
if (transv)
SvREFCNT_dec(transv);
- if (!del && havefinal)
+ if (!del && havefinal && rlen)
(void)hv_store((HV*)SvRV((cSVOPo->op_sv)), "FINAL", 5,
newSVuv((UV)final), 0);