* assume cannot */
if (! out_is_utf8 && (PL_op->op_private & OPpTRANS_CAN_FORCE_UTF8)) {
inplace = FALSE;
- if (max_expansion < 2) {
- max_expansion = 2;
- }
}
s = (U8*)SvPV_nomg(sv, len);
else {
/* Here, we can't edit in place. We have no idea how much, if any,
* this particular input string will grow. However, the compilation
- * calculated the maximum expansion possible. Use that to allocale
- * based on the worst case scenario. */
+ * calculated the maximum expansion possible. Use that to allocate
+ * based on the worst case scenario. (First +1 is to round up; 2nd is
+ * for \0) */
Newx(d, (STRLEN) (len * max_expansion + 1 + 1), U8);
d0 = d;
}
}
}
else if (size < 8)
- retnum = (s[uoffset] >> bitoffs) & ((1 << size) - 1);
+ retnum = (s[uoffset] >> bitoffs) & nBIT_MASK(size);
else {
if (size == 8)
retnum = s[uoffset];
}
if (size < 8) {
- mask = (1 << size) - 1;
+ mask = nBIT_MASK(size);
lval &= mask;
s[offset] &= ~(mask << bitoffs);
s[offset] |= lval << bitoffs;