From: Nicholas Clark <nick@ccl4.org>
Date: Sat, 25 Feb 2006 16:48:46 +0000 (+0000)
Subject: Abstract the specific use of SvCUR in GVs for detecting variables on
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=169d2d72355cfee106217aa142a9e61dc32e53d9;p=p5sagit%2Fp5-mst-13.2.git

Abstract the specific use of SvCUR in GVs for detecting variables on
both sides of an assignment using GvASSIGN_GENERATION() and
GvASSIGN_GENERATION_set().

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

diff --git a/gv.h b/gv.h
index 3e2bc90..81a42cf 100644
--- a/gv.h
+++ b/gv.h
@@ -63,6 +63,11 @@ struct gp {
 #  define GvNAMELEN(gv)	(GvXPVGV(gv)->xgv_namelen)
 #endif
 
+#define	GvASSIGN_GENERATION(gv)		(0 + ((XPV*) SvANY(gv))->xpv_cur)
+#define	GvASSIGN_GENERATION_set(gv,val)			\
+	STMT_START { assert(SvTYPE(gv) == SVt_PVGV);	\
+		(((XPV*) SvANY(gv))->xpv_cur = (val)); } STMT_END
+
 /*
 =head1 GV Functions
 
diff --git a/op.c b/op.c
index d65bf16..70a2acf 100644
--- a/op.c
+++ b/op.c
@@ -3362,9 +3362,10 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right)
 		if (PL_opargs[curop->op_type] & OA_DANGEROUS) {
 		    if (curop->op_type == OP_GV) {
 			GV *gv = cGVOPx_gv(curop);
-			if (gv == PL_defgv || (int)SvCUR(gv) == PL_generation)
+			if (gv == PL_defgv
+			    || (int)GvASSIGN_GENERATION(gv) == PL_generation)
 			    break;
-			SvCUR_set(gv, PL_generation);
+			GvASSIGN_GENERATION_set(gv, PL_generation);
 		    }
 		    else if (curop->op_type == OP_PADSV ||
 			     curop->op_type == OP_PADAV ||
@@ -3394,9 +3395,11 @@ Perl_newASSIGNOP(pTHX_ I32 flags, OP *left, I32 optype, OP *right)
 #else
 			    GV *gv = (GV*)((PMOP*)curop)->op_pmreplroot;
 #endif
-			    if (gv == PL_defgv || (int)SvCUR(gv) == PL_generation)
+			    if (gv == PL_defgv
+				|| (int)GvASSIGN_GENERATION(gv) == PL_generation)
 				break;
-			    SvCUR_set(gv, PL_generation);
+			    GvASSIGN_GENERATION_set(gv, PL_generation);
+			    GvASSIGN_GENERATION_set(gv, PL_generation);
 			}
 		    }
 		    else