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);
return do_trans_simple(sv);
case OPpTRANS_IDENTICAL:
+ case OPpTRANS_IDENTICAL|OPpTRANS_COMPLEMENT:
if (hasutf)
return do_trans_count_utf8(sv);
else
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;
}
}
}
- 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];