The code to calculate the length of the string to copy was
PL_regeol - startpos + (stringarg - strbeg);
This is a hangover from the original (perl 3) regexp implementation
that under //i, copied and folded the original buffer: so startpos might
not equal stringarg. These days it always is (except under a match failure
with (*COMMIT), and the code we're interested is only executed on success).
So simplify to just PL_regeol - strbeg.
if ( !(flags & REXEC_NOT_FIRST) ) {
RX_MATCH_COPY_FREE(rx);
if (flags & REXEC_COPY_STR) {
- const I32 i = PL_regeol - startpos + (stringarg - strbeg);
+ const I32 i = PL_regeol - strbeg;
#ifdef PERL_OLD_COPY_ON_WRITE
if ((SvIsCOW(sv)
|| (SvFLAGS(sv) & CAN_COW_MASK) == CAN_COW_FLAGS)) {