summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-18 04:22:43 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-18 04:22:43 +0000
commit05d340b81db0665672bf1917f71d6cb9459a3b2b (patch)
tree59b1656dc9aaed95bc0d7013cb8512ec19aa5602 /op.c
parent62fe13c2faf7fffe785bfea95f8e9e927ace891e (diff)
downloadperl-05d340b81db0665672bf1917f71d6cb9459a3b2b.tar.gz
tr/// UTF-8 patches from Inaba Hiroto.
p4raw-id: //depot/perl@9192
Diffstat (limited to 'op.c')
-rw-r--r--op.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/op.c b/op.c
index 64914ea309..045b8d34b5 100644
--- a/op.c
+++ b/op.c
@@ -2740,7 +2740,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
r = t; rlen = tlen; rend = tend;
}
if (!squash) {
- if (t == r ||
+ if ((!rlen && !del) || t == r ||
(tlen == rlen && memEQ((char *)t, (char *)r, tlen)))
{
o->op_private |= OPpTRANS_IDENTICAL;
@@ -2872,8 +2872,16 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
}
}
}
- if (!del && rlen >= j) {
- cPVOPo->op_pv = (char*)Renew(tbl, 0x101+rlen-j, short);
+ if (!del) {
+ if (!rlen) {
+ j = rlen;
+ if (!squash)
+ o->op_private |= OPpTRANS_IDENTICAL;
+ }
+ else if (j >= rlen)
+ j = rlen - 1;
+ else
+ cPVOPo->op_pv = (char*)Renew(tbl, 0x101+rlen-j, short);
tbl[0x100] = rlen - j;
for (i=0; i < rlen - j; i++)
tbl[0x101+i] = r[j+i];