SV* sv_dat=HeVAL(he_str);
I32 *nums=(I32*)SvPVX(sv_dat);
for ( i=0; i<SvIVX(sv_dat); i++ ) {
- if ((I32)(rx->lastparen) >= nums[i] &&
- rx->endp[nums[i]] != -1)
+ if ((I32)(rx->nparens) >= nums[i]
+ && rx->startp[nums[i]] != -1
+ && rx->endp[nums[i]] != -1)
{
ret = reg_numbered_buff_get(nums[i],rx,NULL,0);
if (!retarray)
}
+
+
/*
- regtry - try match at specific point
*/
} else {
nochange_depth = 0;
}
+ { regexp *ocurpm = PM_GETRE(PL_curpm);
+ char *osubbeg = rex->subbeg;
+ STRLEN osublen = rex->sublen;
{
/* execute the code in the {...} */
dSP;
OP_4tree * const oop = PL_op;
COP * const ocurcop = PL_curcop;
PAD *old_comppad;
+
n = ARG(scan);
PL_op = (OP_4tree*)rexi->data->data[n];
SV *sv_mrk = get_sv("REGMARK", 1);
sv_setsv(sv_mrk, sv_yes_mark);
}
+ /* make sure that $1 and friends are available with nested eval */
+ PM_SETRE(PL_curpm,rex);
+ rex->subbeg = ocurpm->subbeg;
+ rex->sublen = ocurpm->sublen;
CALLRUNOPS(aTHX); /* Scalar context. */
SPAGAIN;
PL_op = oop;
PAD_RESTORE_LOCAL(old_comppad);
PL_curcop = ocurcop;
+
if (!logical) {
/* /(?{...})/ */
sv_setsv(save_scalar(PL_replgv), ret);
}
}
rei = RXi_GET(re);
+
+ /* restore PL_curpm after the eval */
+ PM_SETRE(PL_curpm,ocurpm);
+ rex->sublen = osublen;
+ rex->subbeg = osubbeg;
+
DEBUG_EXECUTE_r(
debug_start_match(re, do_utf8, locinput, PL_regeol,
"Matching embedded");
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 (??{...}) */
PUSH_YES_STATE_GOTO(EVAL_AB, startpoint);
/* NOTREACHED */
}
+ /* restore PL_curpm after the eval */
+ PM_SETRE(PL_curpm,ocurpm);
+ rex->sublen = osublen;
+ rex->subbeg = osubbeg;
+ }
/* logical is 1, /(?(?{...})X|Y)/ */
sw = (bool)SvTRUE(ret);
logical = 0;
$x =~ s/(.)\K/$1/g;
ok($x eq "aabbccddee");
}
+sub kt
+{
+ return '4' if $_[0] eq '09028623';
+}
+{ # Nested EVAL using PL_curpm (via $1 or friends)
+ my $re;
+ our $grabit = qr/ ([0-6][0-9]{7}) (??{ kt $1 }) [890] /x;
+ $re = qr/^ ( (??{ $grabit }) ) $ /x;
+ my @res = '0902862349' =~ $re;
+ iseq(join("-",@res),"0902862349",
+ 'PL_curpm is set properly on nested eval');
+
+ our $qr = qr/ (o) (??{ $1 }) /x;
+ ok( 'boob'=~/( b (??{ $qr }) b )/x && 1,
+ "PL_curpm, nested eval");
+}
# Test counter is at bottom of file. Put new tests above here.
#-------------------------------------------------------------------
iseq(0+$::test,$::TestCount,"Got the right number of tests!");
# Don't forget to update this!
BEGIN {
- $::TestCount = 1620;
+ $::TestCount = 1622;
print "1..$::TestCount\n";
}