diff options
author | Larry Wall <larry@wall.org> | 1998-09-05 23:48:24 +0000 |
---|---|---|
committer | Larry Wall <larry@wall.org> | 1998-09-05 23:48:24 +0000 |
commit | 4757a2438b123364ad98fc0cb4698e56331f713b (patch) | |
tree | d1e491103e421493e8c170df368431ccea81971a /op.c | |
parent | 342930fbe48873e4ee7fdf12f4ea00e063c13bb8 (diff) | |
download | perl-4757a2438b123364ad98fc0cb4698e56331f713b.tar.gz |
tr/// logic was hosed under utf8
p4raw-id: //depot/perl@1781
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; |