From: Jarkko Hietaniemi Date: Sun, 18 Mar 2001 04:22:43 +0000 (+0000) Subject: tr/// UTF-8 patches from Inaba Hiroto. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=05d340b81db0665672bf1917f71d6cb9459a3b2b;p=p5sagit%2Fp5-mst-13.2.git tr/// UTF-8 patches from Inaba Hiroto. p4raw-id: //depot/perl@9192 --- diff --git a/doop.c b/doop.c index a6391b4..bd66b42 100644 --- a/doop.c +++ b/doop.c @@ -213,7 +213,8 @@ S_do_trans_complex(pTHX_ SV *sv)/* SPC - NOT OK */ else { matches++; if (!del) { - ch = (comp - 0x100 < rlen) ? + ch = (rlen == 0) ? comp : + (comp - 0x100 < rlen) ? tbl[comp+1] : tbl[0x100+rlen]; if (ch != pch) { d = uvchr_to_utf8(d, ch); @@ -601,6 +602,7 @@ Perl_do_trans(pTHX_ SV *sv) return do_trans_simple(sv); case OPpTRANS_IDENTICAL: + case OPpTRANS_IDENTICAL|OPpTRANS_COMPLEMENT: if (hasutf) return do_trans_count_utf8(sv); else diff --git a/op.c b/op.c index 64914ea..045b8d3 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];