Message-Id: <
20011010172344.C22440@rafael>
p4raw-id: //depot/perl@12392
rxres_restore(&cx->sb_rxres, rx);
if (cx->sb_iters++) {
+ I32 saviters = cx->sb_iters;
if (cx->sb_iters > cx->sb_maxiters)
DIE(aTHX_ "Substitution loop");
POPSUBST(cx);
RETURNOP(pm->op_next);
}
+ cx->sb_iters = saviters;
}
if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) {
m = s;
PL_curpad = AvARRAY((AV*)PL_regdata->data[n + 2]);
PL_regendp[0] = PL_reg_magic->mg_len = locinput - PL_bostr;
- CALLRUNOPS(aTHX); /* Scalar context. */
- SPAGAIN;
- ret = POPs;
- PUTBACK;
-
+ {
+ SV **before = SP;
+ CALLRUNOPS(aTHX); /* Scalar context. */
+ SPAGAIN;
+ if (SP == before)
+ ret = Nullsv; /* protect against empty (?{}) blocks. */
+ else {
+ ret = POPs;
+ PUTBACK;
+ }
+ }
+
PL_op = oop;
PL_curpad = ocurpad;
PL_curcop = ocurcop;
}
require './test.pl';
-plan( tests => 86 );
+plan( tests => 87 );
$x = 'foo';
$_ = "x";
[^A-Za-z0-9\s]+ (?{ '$@%#' })
}{$^R}xg;
ok( $_ eq $foo );
-ok( $snum == 31, "# TODO \$snum == $snum, should be 31" );
+ok( $snum == 31 );
+
+$_ = 'a' x 6;
+$snum = s/a(?{})//g;
+ok( $_ eq '' && $snum == 6 );
$_ = 'x' x 20;
$snum = s/(\d*|x)/<$1>/g;