From: Rafael Garcia-Suarez <rgarciasuarez@gmail.com>
Date: Sat, 23 Dec 2006 15:38:50 +0000 (+0000)
Subject: A better fix for RT #6006: revert change 29616, which was bogus,
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e80b829c678662da5bda5d8b6fb6d7de54064909;p=p5sagit%2Fp5-mst-13.2.git

A better fix for RT #6006: revert change 29616, which was bogus,
and add OP_SCOPE to the list of "dangerous" ops that might appear
on the right side of s///.
However, this fix does not work under taint mode, and op/subst.t
has -T.

p4raw-id: //depot/perl@29617
---

diff --git a/op.c b/op.c
index 69db999..626f3e8 100644
--- a/op.c
+++ b/op.c
@@ -3313,7 +3313,8 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
 	else {
 	    OP *lastop = NULL;
 	    for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) {
-		if (PL_opargs[curop->op_type] & OA_DANGEROUS) {
+		if (curop->op_type == OP_SCOPE
+			|| (PL_opargs[curop->op_type] & OA_DANGEROUS)) {
 		    if (curop->op_type == OP_GV) {
 			GV * const gv = cGVOPx_gv(curop);
 			repl_has_vars = 1;
@@ -3332,9 +3333,8 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
 		    else if (curop->op_type == OP_PADSV ||
 			     curop->op_type == OP_PADAV ||
 			     curop->op_type == OP_PADHV ||
-			     curop->op_type == OP_PADANY ||
-			     curop->op_type == OP_SCOPE /* ${10} */
-			     ) {
+			     curop->op_type == OP_PADANY)
+		    {
 			repl_has_vars = 1;
 		    }
 		    else if (curop->op_type == OP_PUSHRE)
@@ -3346,8 +3346,9 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg)
 	    }
 	}
 	if (curop == repl
-	    && !repl_has_vars
-	    && (PM_GETRE(pm) && !PM_GETRE(pm)->extflags & RXf_EVAL_SEEN))
+	    && !(repl_has_vars
+		 && (!PM_GETRE(pm)
+		     || PM_GETRE(pm)->extflags & RXf_EVAL_SEEN)))
 	{
 	    pm->op_pmflags |= PMf_CONST;	/* const for long enough */
 	    pm->op_pmpermflags |= PMf_CONST;	/* const for long enough */