/* return the last filled */
while ( paren >= 0
- && (rx->startp[paren] == -1 || rx->endp[paren] == -1) )
+ && (rx->offs[paren].start == -1
+ || rx->offs[paren].end == -1) )
paren--;
return (U32)paren;
}
if (paren < 0)
return 0;
if (paren <= (I32)rx->nparens &&
- (s = rx->startp[paren]) != -1 &&
- (t = rx->endp[paren]) != -1)
+ (s = rx->offs[paren].start) != -1 &&
+ (t = rx->offs[paren].end) != -1)
{
register I32 i;
if (mg->mg_obj) /* @+ */
paren = atoi(mg->mg_ptr); /* $& is in [0] */
getparen:
if (paren <= (I32)rx->nparens &&
- (s1 = rx->startp[paren]) != -1 &&
- (t1 = rx->endp[paren]) != -1)
+ (s1 = rx->offs[paren].start) != -1 &&
+ (t1 = rx->offs[paren].end) != -1)
{
i = t1 - s1;
getlen:
return 0;
case '`':
if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
- if (rx->startp[0] != -1) {
- i = rx->startp[0];
+ if (rx->offs[0].start != -1) {
+ i = rx->offs[0].start;
if (i > 0) {
s1 = 0;
t1 = i;
return 0;
case '\'':
if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
- if (rx->endp[0] != -1) {
- i = rx->sublen - rx->endp[0];
+ if (rx->offs[0].end != -1) {
+ i = rx->sublen - rx->offs[0].end;
if (i > 0) {
- s1 = rx->endp[0];
+ s1 = rx->offs[0].end;
t1 = rx->sublen;
goto getlen;
}
s = orig + (m - s);
strend = s + (strend - m);
}
- m = rx->startp[0] + orig;
+ m = rx->offs[0].start + orig;
dstr = newSVpvn(s, m-s);
if (make_mortal)
sv_2mortal(dstr);
if (rx->nparens) {
I32 i;
for (i = 1; i <= (I32)rx->nparens; i++) {
- s = rx->startp[i] + orig;
- m = rx->endp[i] + orig;
+ s = rx->offs[i].start + orig;
+ m = rx->offs[i].end + orig;
/* japhy (07/27/01) -- the (m && s) test doesn't catch
parens that didn't match -- they should be set to
XPUSHs(dstr);
}
}
- s = rx->endp[0] + orig;
+ s = rx->offs[0].end + orig;
}
}
s = orig + (m - s);
cx->sb_strend = s + (cx->sb_strend - m);
}
- cx->sb_m = m = rx->startp[0] + orig;
+ cx->sb_m = m = rx->offs[0].start + orig;
if (m > s) {
if (DO_UTF8(dstr) && !SvUTF8(cx->sb_targ))
sv_catpvn_utf8_upgrade(dstr, s, m - s, nsv);
else
sv_catpvn(dstr, s, m-s);
}
- cx->sb_s = rx->endp[0] + orig;
+ cx->sb_s = rx->offs[0].end + orig;
{ /* Update the pos() information. */
SV * const sv = cx->sb_targ;
MAGIC *mg;
*p++ = PTR2UV(rx->subbeg);
*p++ = (UV)rx->sublen;
for (i = 0; i <= rx->nparens; ++i) {
- *p++ = (UV)rx->startp[i];
- *p++ = (UV)rx->endp[i];
+ *p++ = (UV)rx->offs[i].start;
+ *p++ = (UV)rx->offs[i].end;
}
}
rx->subbeg = INT2PTR(char*,*p++);
rx->sublen = (I32)(*p++);
for (i = 0; i <= rx->nparens; ++i) {
- rx->startp[i] = (I32)(*p++);
- rx->endp[i] = (I32)(*p++);
+ rx->offs[i].start = (I32)(*p++);
+ rx->offs[i].end = (I32)(*p++);
}
}
/* XXXX What part of this is needed with true \G-support? */
if ((global = dynpm->op_pmflags & PMf_GLOBAL)) {
- rx->startp[0] = -1;
+ rx->offs[0].start = -1;
if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG)) {
MAGIC* const mg = mg_find(TARG, PERL_MAGIC_regex_global);
if (mg && mg->mg_len >= 0) {
if (!(rx->extflags & RXf_GPOS_SEEN))
- rx->endp[0] = rx->startp[0] = mg->mg_len;
+ rx->offs[0].end = rx->offs[0].start = mg->mg_len;
else if (rx->extflags & RXf_ANCH_GPOS) {
r_flags |= REXEC_IGNOREPOS;
- rx->endp[0] = rx->startp[0] = mg->mg_len;
+ rx->offs[0].end = rx->offs[0].start = mg->mg_len;
} else if (rx->extflags & RXf_GPOS_FLOAT)
gpos = mg->mg_len;
else
- rx->endp[0] = rx->startp[0] = mg->mg_len;
+ rx->offs[0].end = rx->offs[0].start = mg->mg_len;
minmatch = (mg->mg_flags & MGf_MINMATCH) ? rx->gofs + 1 : 0;
update_minmatch = 0;
}
r_flags |= REXEC_SCREAM;
play_it_again:
- if (global && rx->startp[0] != -1) {
- t = s = rx->endp[0] + truebase - rx->gofs;
+ if (global && rx->offs[0].start != -1) {
+ t = s = rx->offs[0].end + truebase - rx->gofs;
if ((s + rx->minlen) > strend || s < truebase)
goto nope;
if (update_minmatch++)
EXTEND_MORTAL(nparens + i);
for (i = !i; i <= nparens; i++) {
PUSHs(sv_newmortal());
- if ((rx->startp[i] != -1) && rx->endp[i] != -1 ) {
- const I32 len = rx->endp[i] - rx->startp[i];
- s = rx->startp[i] + truebase;
- if (rx->endp[i] < 0 || rx->startp[i] < 0 ||
+ if ((rx->offs[i].start != -1) && rx->offs[i].end != -1 ) {
+ const I32 len = rx->offs[i].end - rx->offs[i].start;
+ s = rx->offs[i].start + truebase;
+ if (rx->offs[i].end < 0 || rx->offs[i].start < 0 ||
len < 0 || len > strend - s)
DIE(aTHX_ "panic: pp_match start/end pointers");
sv_setpvn(*SP, s, len);
mg = sv_magicext(TARG, NULL, PERL_MAGIC_regex_global,
&PL_vtbl_mglob, NULL, 0);
}
- if (rx->startp[0] != -1) {
- mg->mg_len = rx->endp[0];
- if (rx->startp[0] + rx->gofs == (UV)rx->endp[0])
+ if (rx->offs[0].start != -1) {
+ mg->mg_len = rx->offs[0].end;
+ if (rx->offs[0].start + rx->gofs == (UV)rx->offs[0].end)
mg->mg_flags |= MGf_MINMATCH;
else
mg->mg_flags &= ~MGf_MINMATCH;
}
}
- had_zerolen = (rx->startp[0] != -1
- && rx->startp[0] + rx->gofs == (UV)rx->endp[0]);
+ had_zerolen = (rx->offs[0].start != -1
+ && (rx->offs[0].start + rx->gofs
+ == (UV)rx->offs[0].end));
PUTBACK; /* EVAL blocks may use stack */
r_flags |= REXEC_IGNOREPOS | REXEC_NOT_FIRST;
goto play_it_again;
mg = sv_magicext(TARG, NULL, PERL_MAGIC_regex_global,
&PL_vtbl_mglob, NULL, 0);
}
- if (rx->startp[0] != -1) {
- mg->mg_len = rx->endp[0];
- if (rx->startp[0] + rx->gofs == (UV)rx->endp[0])
+ if (rx->offs[0].start != -1) {
+ mg->mg_len = rx->offs[0].end;
+ if (rx->offs[0].start + rx->gofs == (UV)rx->offs[0].end)
mg->mg_flags |= MGf_MINMATCH;
else
mg->mg_flags &= ~MGf_MINMATCH;
if (global) {
/* FIXME - should rx->subbeg be const char *? */
rx->subbeg = (char *) truebase;
- rx->startp[0] = s - truebase;
+ rx->offs[0].start = s - truebase;
if (RX_MATCH_UTF8(rx)) {
char * const t = (char*)utf8_hop((U8*)s, rx->minlenret);
- rx->endp[0] = t - truebase;
+ rx->offs[0].end = t - truebase;
}
else {
- rx->endp[0] = s - truebase + rx->minlenret;
+ rx->offs[0].end = s - truebase + rx->minlenret;
}
rx->sublen = strend - truebase;
goto gotcha;
}
rx->sublen = strend - t;
RX_MATCH_COPIED_on(rx);
- off = rx->startp[0] = s - t;
- rx->endp[0] = off + rx->minlenret;
+ off = rx->offs[0].start = s - t;
+ rx->offs[0].end = off + rx->minlenret;
}
else { /* startp/endp are used by @- @+. */
- rx->startp[0] = s - truebase;
- rx->endp[0] = s - truebase + rx->minlenret;
+ rx->offs[0].start = s - truebase;
+ rx->offs[0].end = s - truebase + rx->minlenret;
}
/* including rx->nparens in the below code seems highly suspicious.
-dmq */
SvSCREAM_off(TARG); /* disable possible screamer */
if (once) {
rxtainted |= RX_MATCH_TAINTED(rx);
- m = orig + rx->startp[0];
- d = orig + rx->endp[0];
+ m = orig + rx->offs[0].start;
+ d = orig + rx->offs[0].end;
s = orig;
if (m - s > strend - d) { /* faster to shorten from end */
if (clen) {
if (iters++ > maxiters)
DIE(aTHX_ "Substitution loop");
rxtainted |= RX_MATCH_TAINTED(rx);
- m = rx->startp[0] + orig;
+ m = rx->offs[0].start + orig;
if ((i = m - s)) {
if (s != d)
Move(s, d, i, char);
Copy(c, d, clen, char);
d += clen;
}
- s = rx->endp[0] + orig;
+ s = rx->offs[0].end + orig;
} while (CALLREGEXEC(rx, s, strend, orig, s == m,
TARG, NULL,
/* don't match same null twice */
s = orig + (m - s);
strend = s + (strend - m);
}
- m = rx->startp[0] + orig;
+ m = rx->offs[0].start + orig;
if (doutf8 && !SvUTF8(dstr))
sv_catpvn_utf8_upgrade(dstr, s, m - s, nsv);
else
sv_catpvn(dstr, s, m-s);
- s = rx->endp[0] + orig;
+ s = rx->offs[0].end + orig;
if (clen)
sv_catpvn(dstr, c, clen);
if (once)
ARG2L_SET( scan, RExC_open_parens[ARG(scan)-1] - scan );
}
}
- Newxz(r->startp, RExC_npar * 2, I32);
- r->endp = r->startp + RExC_npar;
+ Newxz(r->offs, RExC_npar, regexp_paren_pair);
/* assume we don't need to swap parens around before we match */
DEBUG_DUMP_r({
I32 *nums=(I32*)SvPVX(sv_dat);
for ( i=0; i<SvIVX(sv_dat); i++ ) {
if ((I32)(rx->nparens) >= nums[i]
- && rx->startp[nums[i]] != -1
- && rx->endp[nums[i]] != -1)
+ && rx->offs[nums[i]].start != -1
+ && rx->offs[nums[i]].end != -1)
{
ret = CALLREG_NUMBUF(rx,nums[i],NULL);
if (!retarray)
return sv;
}
else
- if (paren == -2 && rx->startp[0] != -1) {
+ if (paren == -2 && rx->offs[0].start != -1) {
/* $` */
- i = rx->startp[0];
+ i = rx->offs[0].start;
s = rx->subbeg;
}
else
- if (paren == -1 && rx->endp[0] != -1) {
+ if (paren == -1 && rx->offs[0].end != -1) {
/* $' */
- s = rx->subbeg + rx->endp[0];
- i = rx->sublen - rx->endp[0];
+ s = rx->subbeg + rx->offs[0].end;
+ i = rx->sublen - rx->offs[0].end;
}
else
if ( 0 <= paren && paren <= (I32)rx->nparens &&
- (s1 = rx->startp[paren]) != -1 &&
- (t1 = rx->endp[paren]) != -1)
+ (s1 = rx->offs[paren].start) != -1 &&
+ (t1 = rx->offs[paren].end) != -1)
{
/* $& $1 ... */
i = t1 - s1;
if (r->saved_copy)
SvREFCNT_dec(r->saved_copy);
#endif
- if (r->swap) {
- Safefree(r->swap->startp);
- Safefree(r->swap);
- }
- Safefree(r->startp);
+ Safefree(r->swap);
+ Safefree(r->offs);
Safefree(r);
}
(void)ReREFCNT_inc(r);
Newx(ret, 1, regexp);
StructCopy(r, ret, regexp);
- Newx(ret->startp, npar * 2, I32);
- Copy(r->startp, ret->startp, npar * 2, I32);
- ret->endp = ret->startp + npar;
+ Newx(ret->offs, npar, regexp_paren_pair);
+ Copy(r->offs, ret->offs, npar, regexp_paren_pair);
ret->refcnt = 1;
if (r->substrs) {
Newx(ret->substrs, 1, struct reg_substr_data);
npar = r->nparens+1;
Newx(ret, 1, regexp);
StructCopy(r, ret, regexp);
- Newx(ret->startp, npar * 2, I32);
- Copy(r->startp, ret->startp, npar * 2, I32);
- ret->endp = ret->startp + npar;
+ Newx(ret->offs, npar, regexp_paren_pair);
+ Copy(r->offs, ret->offs, npar, regexp_paren_pair);
if(ret->swap) {
- Newx(ret->swap, 1, regexp_paren_ofs);
/* no need to copy these */
- Newx(ret->swap->startp, npar * 2, I32);
- ret->swap->endp = ret->swap->startp + npar;
+ Newx(ret->swap, npar, regexp_paren_pair);
}
if (ret->substrs) {
if (paren_elems_to_push < 0)
Perl_croak(aTHX_ "panic: paren_elems_to_push < 0");
-#define REGCP_OTHER_ELEMS 8
+#define REGCP_OTHER_ELEMS 7
SSGROW(paren_elems_to_push + REGCP_OTHER_ELEMS);
for (p = PL_regsize; p > parenfloor; p--) {
/* REGCP_PARENS_ELEMS are pushed per pairs of parentheses. */
- SSPUSHINT(PL_regendp[p]);
- SSPUSHINT(PL_regstartp[p]);
+ SSPUSHINT(PL_regoffs[p].end);
+ SSPUSHINT(PL_regoffs[p].start);
SSPUSHPTR(PL_reg_start_tmp[p]);
SSPUSHINT(p);
DEBUG_BUFFERS_r(PerlIO_printf(Perl_debug_log,
" saving \\%"UVuf" %"IVdf"(%"IVdf")..%"IVdf"\n",
- (UV)p, (IV)PL_regstartp[p],
+ (UV)p, (IV)PL_regoffs[p].start,
(IV)(PL_reg_start_tmp[p] - PL_bostr),
- (IV)PL_regendp[p]
+ (IV)PL_regoffs[p].end
));
}
/* REGCP_OTHER_ELEMS are pushed in any case, parentheses or no. */
- SSPUSHPTR(PL_regstartp);
- SSPUSHPTR(PL_regendp);
+ SSPUSHPTR(PL_regoffs);
SSPUSHINT(PL_regsize);
SSPUSHINT(*PL_reglastparen);
SSPUSHINT(*PL_reglastcloseparen);
*PL_reglastcloseparen = SSPOPINT;
*PL_reglastparen = SSPOPINT;
PL_regsize = SSPOPINT;
- PL_regendp=(I32 *) SSPOPPTR;
- PL_regstartp=(I32 *) SSPOPPTR;
+ PL_regoffs=(regexp_paren_pair *) SSPOPPTR;
/* Now restore the parentheses context. */
I32 tmps;
U32 paren = (U32)SSPOPINT;
PL_reg_start_tmp[paren] = (char *) SSPOPPTR;
- PL_regstartp[paren] = SSPOPINT;
+ PL_regoffs[paren].start = SSPOPINT;
tmps = SSPOPINT;
if (paren <= *PL_reglastparen)
- PL_regendp[paren] = tmps;
+ PL_regoffs[paren].end = tmps;
DEBUG_BUFFERS_r(
PerlIO_printf(Perl_debug_log,
" restoring \\%"UVuf" to %"IVdf"(%"IVdf")..%"IVdf"%s\n",
- (UV)paren, (IV)PL_regstartp[paren],
+ (UV)paren, (IV)PL_regoffs[paren].start,
(IV)(PL_reg_start_tmp[paren] - PL_bostr),
- (IV)PL_regendp[paren],
+ (IV)PL_regoffs[paren].end,
(paren > *PL_reglastparen ? "(no)" : ""));
);
}
* --jhi */
for (i = *PL_reglastparen + 1; i <= rex->nparens; i++) {
if (i > PL_regsize)
- PL_regstartp[i] = -1;
- PL_regendp[i] = -1;
+ PL_regoffs[i].start = -1;
+ PL_regoffs[i].end = -1;
}
#endif
return input;
static void
S_swap_match_buff (pTHX_ regexp *prog) {
- I32 *t;
+ regexp_paren_pair *t;
if (!prog->swap) {
/* We have to be careful. If the previous successful match
to the re, and switch the buffer each match. If we fail
we switch it back, otherwise we leave it swapped.
*/
- Newxz(prog->swap, 1, regexp_paren_ofs);
- /* no need to copy these */
- Newxz(prog->swap->startp, 2 * (prog->nparens + 1), I32);
- prog->swap->endp = prog->swap->startp + prog->nparens + 1;
+ Newxz(prog->swap, (prog->nparens + 1), regexp_paren_pair);
}
- t = prog->swap->startp;
- prog->swap->startp = prog->startp;
- prog->startp = t;
- t = prog->swap->endp;
- prog->swap->endp = prog->endp;
- prog->endp = t;
+ t = prog->swap;
+ prog->swap = prog->offs;
+ prog->offs = t;
}
prog->sublen = PL_regeol - PL_bostr; /* strend may have been modified */
}
DEBUG_EXECUTE_r(PL_reg_starttry = *startpos);
- prog->startp[0] = *startpos - PL_bostr;
+ prog->offs[0].start = *startpos - PL_bostr;
PL_reginput = *startpos;
PL_reglastparen = &prog->lastparen;
PL_reglastcloseparen = &prog->lastcloseparen;
prog->lastparen = 0;
prog->lastcloseparen = 0;
PL_regsize = 0;
- PL_regstartp = prog->startp;
- PL_regendp = prog->endp;
+ PL_regoffs = prog->offs;
if (PL_reg_start_tmpl <= prog->nparens) {
PL_reg_start_tmpl = prog->nparens*3/2 + 3;
if(PL_reg_start_tmp)
* --jhi */
#if 1
if (prog->nparens) {
- I32 *sp = PL_regstartp;
- I32 *ep = PL_regendp;
+ regexp_paren_pair *pp = PL_regoffs;
register I32 i;
for (i = prog->nparens; i > (I32)*PL_reglastparen; i--) {
- *++sp = -1;
- *++ep = -1;
+ ++pp;
+ pp->start = -1;
+ pp->end = -1;
}
}
#endif
REGCP_SET(lastcp);
if (regmatch(reginfo, progi->program + 1)) {
- PL_regendp[0] = PL_reginput - PL_bostr;
+ PL_regoffs[0].end = PL_reginput - PL_bostr;
return 1;
}
if (reginfo->cutpoint)
I32 *nums=(I32*)SvPVX(sv_dat);
for ( n=0; n<SvIVX(sv_dat); n++ ) {
if ((I32)*PL_reglastparen >= nums[n] &&
- PL_regendp[nums[n]] != -1)
+ PL_regoffs[nums[n]].end != -1)
{
return nums[n];
}
case KEEPS:
/* update the startpoint */
- st->u.keeper.val = PL_regstartp[0];
+ st->u.keeper.val = PL_regoffs[0].start;
PL_reginput = locinput;
- PL_regstartp[0] = locinput - PL_bostr;
+ PL_regoffs[0].start = locinput - PL_bostr;
PUSH_STATE_GOTO(KEEPS_next, next);
/*NOT-REACHED*/
case KEEPS_next_fail:
/* rollback the start point change */
- PL_regstartp[0] = st->u.keeper.val;
+ PL_regoffs[0].start = st->u.keeper.val;
sayNO_SILENT;
/*NOT-REACHED*/
case EOL:
if ( ST.jump) {
REGCP_UNWIND(ST.cp);
for (n = *PL_reglastparen; n > ST.lastparen; n--)
- PL_regendp[n] = -1;
+ PL_regoffs[n].end = -1;
*PL_reglastparen = n;
}
trie_first_try:
n = ARG(scan); /* which paren pair */
type = OP(scan);
do_ref:
- ln = PL_regstartp[n];
+ ln = PL_regoffs[n].start;
PL_reg_leftiter = PL_reg_maxiter; /* Void cache */
if (*PL_reglastparen < n || ln == -1)
sayNO; /* Do not match unless seen CLOSEn. */
- if (ln == PL_regendp[n])
+ if (ln == PL_regoffs[n].end)
break;
s = PL_bostr + ln;
if (do_utf8 && type != REF) { /* REF can do byte comparison */
char *l = locinput;
- const char *e = PL_bostr + PL_regendp[n];
+ const char *e = PL_bostr + PL_regoffs[n].end;
/*
* Note that we can't do the "other character" lookup trick as
* in the 8-bit case (no pun intended) because in Unicode we
(UCHARAT(s) != (type == REFF
? PL_fold : PL_fold_locale)[nextchr])))
sayNO;
- ln = PL_regendp[n] - ln;
+ ln = PL_regoffs[n].end - ln;
if (locinput + ln > PL_regeol)
sayNO;
if (ln > 1 && (type == REF
DEBUG_STATE_r( PerlIO_printf(Perl_debug_log,
" re_eval 0x%"UVxf"\n", PTR2UV(PL_op)) );
PAD_SAVE_LOCAL(old_comppad, (PAD*)rexi->data->data[n + 2]);
- PL_regendp[0] = PL_reg_magic->mg_len = locinput - PL_bostr;
+ PL_regoffs[0].end = PL_reg_magic->mg_len = locinput - PL_bostr;
if (sv_yes_mark) {
SV *sv_mrk = get_sv("REGMARK", 1);
ST.cp = regcppush(0); /* Save *all* the positions. */
REGCP_SET(ST.lastcp);
- PL_regstartp = re->startp; /* essentially NOOP on GOSUB */
- PL_regendp = re->endp; /* essentially NOOP on GOSUB */
+ PL_regoffs = re->offs; /* essentially NOOP on GOSUB */
*PL_reglastparen = 0;
*PL_reglastcloseparen = 0;
break;
case CLOSE:
n = ARG(scan); /* which paren pair */
- PL_regstartp[n] = PL_reg_start_tmp[n] - PL_bostr;
- PL_regendp[n] = locinput - PL_bostr;
+ PL_regoffs[n].start = PL_reg_start_tmp[n] - PL_bostr;
+ PL_regoffs[n].end = locinput - PL_bostr;
/*if (n > PL_regsize)
PL_regsize = n;*/
if (n > *PL_reglastparen)
if ( OP(cursor)==CLOSE ){
n = ARG(cursor);
if ( n <= lastopen ) {
- PL_regstartp[n] = PL_reg_start_tmp[n] - PL_bostr;
- PL_regendp[n] = locinput - PL_bostr;
+ PL_regoffs[n].start
+ = PL_reg_start_tmp[n] - PL_bostr;
+ PL_regoffs[n].end = locinput - PL_bostr;
/*if (n > PL_regsize)
PL_regsize = n;*/
if (n > *PL_reglastparen)
/*NOTREACHED*/
case GROUPP:
n = ARG(scan); /* which paren pair */
- sw = (bool)(*PL_reglastparen >= n && PL_regendp[n] != -1);
+ sw = (bool)(*PL_reglastparen >= n && PL_regoffs[n].end != -1);
break;
case NGROUPP:
/* reg_check_named_buff_matched returns 0 for no match */
}
REGCP_UNWIND(ST.cp);
for (n = *PL_reglastparen; n > ST.lastparen; n--)
- PL_regendp[n] = -1;
+ PL_regoffs[n].end = -1;
*PL_reglastparen = n;
/*dmq: *PL_reglastcloseparen = n; */
scan = ST.next_branch;
/* mark current A as captured */
I32 paren = ST.me->flags;
if (ST.count) {
- PL_regstartp[paren]
+ PL_regoffs[paren].start
= HOPc(PL_reginput, -ST.alen) - PL_bostr;
- PL_regendp[paren] = PL_reginput - PL_bostr;
+ PL_regoffs[paren].end = PL_reginput - PL_bostr;
/*dmq: *PL_reglastcloseparen = paren; */
}
else
- PL_regendp[paren] = -1;
+ PL_regoffs[paren].end = -1;
if (cur_eval && cur_eval->u.eval.close_paren &&
cur_eval->u.eval.close_paren == (U32)ST.me->flags)
{
#define CURLY_SETPAREN(paren, success) \
if (paren) { \
if (success) { \
- PL_regstartp[paren] = HOPc(locinput, -1) - PL_bostr; \
- PL_regendp[paren] = locinput - PL_bostr; \
+ PL_regoffs[paren].start = HOPc(locinput, -1) - PL_bostr; \
+ PL_regoffs[paren].end = locinput - PL_bostr; \
*PL_reglastcloseparen = paren; \
} \
else \
- PL_regendp[paren] = -1; \
+ PL_regoffs[paren].end = -1; \
}
case STAR: /* /A*B/ where A is width 1 */
case CURLY_B_min_known_fail:
/* failed to find B in a non-greedy match where c1,c2 valid */
if (ST.paren && ST.count)
- PL_regendp[ST.paren] = -1;
+ PL_regoffs[ST.paren].end = -1;
PL_reginput = locinput; /* Could be reset... */
REGCP_UNWIND(ST.cp);
case CURLY_B_min_fail:
/* failed to find B in a non-greedy match where c1,c2 invalid */
if (ST.paren && ST.count)
- PL_regendp[ST.paren] = -1;
+ PL_regoffs[ST.paren].end = -1;
REGCP_UNWIND(ST.cp);
/* failed -- move forward one */
case CURLY_B_max_fail:
/* failed to find B in a greedy match */
if (ST.paren && ST.count)
- PL_regendp[ST.paren] = -1;
+ PL_regoffs[ST.paren].end = -1;
REGCP_UNWIND(ST.cp);
/* back up. */
#define SV_SAVED_COPY
#endif
-/* swap buffer for paren structs */
-typedef struct regexp_paren_ofs {
- I32 *startp;
- I32 *endp;
-} regexp_paren_ofs;
+typedef struct regexp_paren_pair {
+ I32 start;
+ I32 end;
+} regexp_paren_pair;
/* this is ordered such that the most commonly used
fields are at the start of the struct */
/* Data about the last/current match. These are modified during matching*/
U32 lastparen; /* last open paren matched */
U32 lastcloseparen; /* last close paren matched */
- regexp_paren_ofs *swap; /* Swap copy of *startp / *endp */
- I32 *startp; /* Array of offsets from start of string (@-) */
- I32 *endp; /* Array of offsets from start of string (@+) */
+ regexp_paren_pair *swap; /* Swap copy of *offs */
+ regexp_paren_pair *offs; /* Array of offsets for (@-) and (@+) */
char *subbeg; /* saved or original string
so \digit works forever. */
#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_regstartp PL_reg_state.re_state_regstartp
-#define PL_regendp PL_reg_state.re_state_regendp
+#define PL_regoffs PL_reg_state.re_state_regoffs
#define PL_reglastparen PL_reg_state.re_state_reglastparen
#define PL_reglastcloseparen PL_reg_state.re_state_reglastcloseparen
#define PL_reg_start_tmp PL_reg_state.re_state_reg_start_tmp
char *re_state_bostr;
char *re_state_reginput; /* String-input pointer. */
char *re_state_regeol; /* End of input, for $ check. */
- I32 *re_state_regstartp; /* Pointer to startp array. */
- I32 *re_state_regendp; /* Ditto for endp. */
+ regexp_paren_pair *re_state_regoffs; /* Pointer to start/end pairs */
U32 *re_state_reglastparen; /* Similarly for lastparen. */
U32 *re_state_reglastcloseparen; /* Similarly for lastcloseparen. */
char **re_state_reg_start_tmp; /* from regexec.c */
= pv_dup(old_state->re_state_reginput);
new_state->re_state_regeol
= pv_dup(old_state->re_state_regeol);
- new_state->re_state_regstartp
- = (I32*) any_dup(old_state->re_state_regstartp, proto_perl);
- new_state->re_state_regendp
- = (I32*) any_dup(old_state->re_state_regendp, proto_perl);
+ new_state->re_state_regoffs
+ = (regexp_paren_pair*)
+ any_dup(old_state->re_state_regoffs, proto_perl);
new_state->re_state_reglastparen
= (U32*) any_dup(old_state->re_state_reglastparen,
proto_perl);
I32 *nums = (I32*)SvPVX(sv_dat);
for ( i = 0; i < SvIVX(sv_dat); i++ ) {
if ((I32)(re->lastcloseparen) >= nums[i] &&
- re->startp[nums[i]] != -1 &&
- re->endp[nums[i]] != -1)
+ re->offs[nums[i]].start != -1 &&
+ re->offs[nums[i]].end != -1)
{
parno = nums[i];
break;
I32 *nums = (I32*)SvPVX(sv_dat);
for ( i = 0; i < SvIVX(sv_dat); i++ ) {
if ((I32)(re->lastcloseparen) >= nums[i] &&
- re->startp[nums[i]] != -1 &&
- re->endp[nums[i]] != -1)
+ re->offs[nums[i]].start != -1 &&
+ re->offs[nums[i]].end != -1)
{
parno = nums[i];
break;