summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorLarry Wall <larry@wall.org>1998-09-05 23:48:24 +0000
committerLarry Wall <larry@wall.org>1998-09-05 23:48:24 +0000
commit4757a2438b123364ad98fc0cb4698e56331f713b (patch)
treed1e491103e421493e8c170df368431ccea81971a /op.c
parent342930fbe48873e4ee7fdf12f4ea00e063c13bb8 (diff)
downloadperl-4757a2438b123364ad98fc0cb4698e56331f713b.tar.gz
tr/// logic was hosed under utf8
p4raw-id: //depot/perl@1781
Diffstat (limited to 'op.c')
-rw-r--r--op.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/op.c b/op.c
index 53fb8c1ce3..ca89229a0d 100644
--- a/op.c
+++ b/op.c
@@ -2156,8 +2156,17 @@ pmtrans(OP *o, OP *expr, OP *repl)
}
else if (!rlen && !del) {
r = t; rlen = tlen; rend = tend;
- if (!squash && to_utf && from_utf)
- o->op_private |= OPpTRANS_COUNTONLY;
+ }
+ if (!squash) {
+ if (to_utf && from_utf) { /* only counting characters */
+ if (t == r || (tlen == rlen && memEQ(t, r, tlen)))
+ o->op_private |= OPpTRANS_IDENTICAL;
+ }
+ else { /* straight latin-1 translation */
+ if (tlen == 4 && memEQ(t, "\0\377\303\277", 4) &&
+ rlen == 4 && memEQ(r, "\0\377\303\277", 4))
+ o->op_private |= OPpTRANS_IDENTICAL;
+ }
}
while (t < tend || tfirst <= tlast) {
@@ -2286,7 +2295,7 @@ pmtrans(OP *o, OP *expr, OP *repl)
if (!rlen && !del) {
r = t; rlen = tlen;
if (!squash)
- o->op_private |= OPpTRANS_COUNTONLY;
+ o->op_private |= OPpTRANS_IDENTICAL;
}
for (i = 0; i < 256; i++)
tbl[i] = -1;