/* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */
SSPUSHINT(rex->offs[p].end);
SSPUSHINT(rex->offs[p].start);
- SSPUSHPTR(PL_reg_start_tmp[p]);
+ SSPUSHPTR(rex->offs[p].start_tmp);
SSPUSHINT(p);
DEBUG_BUFFERS_r(PerlIO_printf(Perl_debug_log,
" saving \\%"UVuf" %"IVdf"(%"IVdf")..%"IVdf"\n",
(UV)p, (IV)rex->offs[p].start,
- (IV)(PL_reg_start_tmp[p] - PL_bostr),
+ (IV)(rex->offs[p].start_tmp - PL_bostr),
(IV)rex->offs[p].end
));
}
for ( ; i > 0; i -= REGCP_PAREN_ELEMS) {
I32 tmps;
U32 paren = (U32)SSPOPINT;
- PL_reg_start_tmp[paren] = (char *) SSPOPPTR;
+ rex->offs[paren].start_tmp = (char *) SSPOPPTR;
rex->offs[paren].start = SSPOPINT;
tmps = SSPOPINT;
if (paren <= rex->lastparen)
PerlIO_printf(Perl_debug_log,
" restoring \\%"UVuf" to %"IVdf"(%"IVdf")..%"IVdf"%s\n",
(UV)paren, (IV)rex->offs[paren].start,
- (IV)(PL_reg_start_tmp[paren] - PL_bostr),
+ (IV)(rex->offs[paren].start_tmp - PL_bostr),
(IV)rex->offs[paren].end,
(paren > rex->lastparen ? "(no)" : ""));
);
prog->lastparen = 0;
prog->lastcloseparen = 0;
PL_regsize = 0;
- if (PL_reg_start_tmpl <= prog->nparens) {
- PL_reg_start_tmpl = prog->nparens*3/2 + 3;
- if(PL_reg_start_tmp)
- Renew(PL_reg_start_tmp, PL_reg_start_tmpl, char*);
- else
- Newx(PL_reg_start_tmp, PL_reg_start_tmpl, char*);
- }
/* XXXX What this code is doing here?!!! There should be no need
to do this again and again, prog->lastparen should take care of
);
startpoint = rei->program + 1;
ST.close_paren = 0; /* only used for GOSUB */
- /* borrowed from regtry */
- if (PL_reg_start_tmpl <= re->nparens) {
- PL_reg_start_tmpl = re->nparens*3/2 + 3;
- if(PL_reg_start_tmp)
- Renew(PL_reg_start_tmp, PL_reg_start_tmpl, char*);
- else
- Newx(PL_reg_start_tmp, PL_reg_start_tmpl, char*);
- }
eval_recurse_doit: /* Share code with GOSUB below this line */
/* run the pattern returned from (??{...}) */
case OPEN:
n = ARG(scan); /* which paren pair */
- PL_reg_start_tmp[n] = locinput;
+ rex->offs[n].start_tmp = locinput;
if (n > PL_regsize)
PL_regsize = n;
lastopen = n;
break;
case CLOSE:
n = ARG(scan); /* which paren pair */
- rex->offs[n].start = PL_reg_start_tmp[n] - PL_bostr;
+ rex->offs[n].start = rex->offs[n].start_tmp - PL_bostr;
rex->offs[n].end = locinput - PL_bostr;
/*if (n > PL_regsize)
PL_regsize = n;*/
n = ARG(cursor);
if ( n <= lastopen ) {
rex->offs[n].start
- = PL_reg_start_tmp[n] - PL_bostr;
+ = rex->offs[n].start_tmp - PL_bostr;
rex->offs[n].end = locinput - PL_bostr;
/*if (n > PL_regsize)
PL_regsize = n;*/
#define SV_SAVED_COPY
#endif
+/* offsets within a string of a particular /(.)/ capture */
+
typedef struct regexp_paren_pair {
I32 start;
I32 end;
+ /* 'start_tmp' records a new opening position before the matching end
+ * has been found, so that the old start and end values are still
+ * valid, e.g.
+ * "abc" =~ /(.(?{print "[$1]"}))+/
+ *outputs [][a][b]
+ * This field is not part of the API. */
+ char *start_tmp;
} regexp_paren_pair;
#if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_UTF8_C)
#define PL_bostr PL_reg_state.re_state_bostr
#define PL_reginput PL_reg_state.re_state_reginput
#define PL_regeol PL_reg_state.re_state_regeol
-#define PL_reg_start_tmp PL_reg_state.re_state_reg_start_tmp
-#define PL_reg_start_tmpl PL_reg_state.re_state_reg_start_tmpl
#define PL_reg_match_utf8 PL_reg_state.re_state_reg_match_utf8
#define PL_reg_magic PL_reg_state.re_state_reg_magic
#define PL_reg_oldpos PL_reg_state.re_state_reg_oldpos
struct re_save_state {
U32 re_state_reg_flags; /* from regexec.c */
- U32 re_state_reg_start_tmpl; /* from regexec.c */
bool re_state_eval_setup_done; /* from regexec.c */
bool re_state_reg_match_utf8; /* from regexec.c */
bool re_reparsing; /* runtime (?{}) fed back into parser */
char *re_state_bostr;
char *re_state_reginput; /* String-input pointer. */
char *re_state_regeol; /* End of input, for $ check. */
- char **re_state_reg_start_tmp; /* from regexec.c */
MAGIC *re_state_reg_magic; /* from regexec.c */
PMOP *re_state_reg_oldcurpm; /* from regexec.c */
PMOP *re_state_reg_curpm; /* from regexec.c */
= pv_dup(old_state->re_state_reginput);
new_state->re_state_regeol
= pv_dup(old_state->re_state_regeol);
- /* XXX This just has to be broken. The old save_re_context
- code did SAVEGENERICPV(PL_reg_start_tmp);
- PL_reg_start_tmp is char **.
- Look above to what the dup code does for
- SAVEt_GENERIC_PVREF
- It can never have worked.
- So this is merely a faithful copy of the exiting bug: */
- new_state->re_state_reg_start_tmp
- = (char **) pv_dup((char *)
- old_state->re_state_reg_start_tmp);
- /* I assume that it only ever "worked" because no-one called
- (pseudo)fork while the regexp engine had re-entered itself.
- */
#ifdef PERL_OLD_COPY_ON_WRITE
new_state->re_state_nrs
= sv_dup(old_state->re_state_nrs, param);