p4raw-id: //depot/perl@359
register I32 squash = op->op_private & OPpTRANS_SQUASH;
STRLEN len;
- if (SvREADONLY(sv))
+ if (SvREADONLY(sv) && !(op->op_private & OPpTRANS_COUNTONLY))
croak(no_modify);
tbl = (short*)cPVOP->op_pv;
s = (U8*)SvPV(sv, len);
}
s++;
}
+ SvSETMAGIC(sv);
+ }
+ else if (op->op_private & OPpTRANS_COUNTONLY) {
+ while (s < send) {
+ if (tbl[*s] >= 0)
+ matches++;
+ s++;
+ }
}
else {
d = s;
matches += send - d; /* account for disappeared chars */
*d = '\0';
SvCUR_set(sv, d - (U8*)SvPVX(sv));
+ SvSETMAGIC(sv);
}
- SvSETMAGIC(sv);
return matches;
}
register I32 j;
I32 Delete;
I32 complement;
+ I32 squash;
register short *tbl;
tbl = (short*)cPVOPo->op_pv;
complement = o->op_private & OPpTRANS_COMPLEMENT;
Delete = o->op_private & OPpTRANS_DELETE;
- /* squash = o->op_private & OPpTRANS_SQUASH; */
+ squash = o->op_private & OPpTRANS_SQUASH;
if (complement) {
Zero(tbl, 256, short);
else {
if (!rlen && !Delete) {
r = t; rlen = tlen;
+ if (!squash)
+ o->op_private |= OPpTRANS_COUNTONLY;
}
for (i = 0; i < 256; i++)
tbl[i] = -1;
#define OPpRUNTIME 64 /* Pattern coming in on the stack */
/* Private for OP_TRANS */
+#define OPpTRANS_COUNTONLY 8
#define OPpTRANS_SQUASH 16
#define OPpTRANS_DELETE 32
#define OPpTRANS_COMPLEMENT 64