}
if (!rx->nparens && !global)
gimme = G_SCALAR; /* accidental array context? */
- safebase = (((gimme == G_ARRAY) || global) && !sawampersand);
+ safebase = (((gimme == G_ARRAY) || global || !rx->nparens)
+ && !sawampersand);
if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
SAVEINT(multiline);
multiline = pm->op_pmflags & PMf_MULTILINE;
RETPUSHYES;
}
-static void
-leave_subst(p)
-void *p;
-{
- ((PMOP*)p)->op_private &= ~OPpLVAL_INTRO;
-}
-
PP(pp_subst)
{
dSP; dTARG;
force_on_match = 1;
TAINT_NOT;
- if (pm->op_private & OPpLVAL_INTRO)
- croak("Recursive substitution detected");
- if (!dstr) {
- SAVEDESTRUCTOR(leave_subst, pm);
- pm->op_private |= OPpLVAL_INTRO;
- }
-
force_it:
if (!pm || !s)
DIE("panic: do_subst");
c = dstr ? SvPV(dstr, clen) : Nullch;
/* can do inplace substitution? */
- if (c && clen <= rx->minlen) {
+ if (c && clen <= rx->minlen && safebase) {
if (! pregexec(rx, s, strend, orig, 0,
SvSCREAM(TARG) ? TARG : Nullsv, safebase)) {
PUSHs(&sv_no);
s = SvPV_force(TARG, len);
goto force_it;
}
- if (rx->subbase) /* oops, no we can't */
- goto long_way;
d = s;
curpm = pm;
SvSCREAM_off(TARG); /* disable possible screamer */
if (pregexec(rx, s, strend, orig, 0,
SvSCREAM(TARG) ? TARG : Nullsv, safebase)) {
- long_way:
if (force_on_match) {
force_on_match = 0;
s = SvPV_force(TARG, len);