develooper Front page | perl.perl5.porters | Postings from December 2004

Missign STATEMENT brackets in PUSHMARK

Thread Next
From:
perl5-porters
Date:
December 23, 2004 09:55
Subject:
Missign STATEMENT brackets in PUSHMARK
Message ID:
cqf0q1$9cc$1@post.home.lunix
While trying to do 

...
if (condition) PUSHMARK(SP);
...

I didn't work at all until I finally realized that PUSHMARK
is not protected by STMT_START and STMT_END

Here is a patch for pp.h (5.8.5 version) that adds the missing cases:

--- ppold.h	Thu Dec 23 18:17:22 2004
+++ pp.h	Thu Dec 23 18:50:36 2004
@@ -63,9 +63,12 @@
 #define MARK mark
 #define TARG targ
 
-#define PUSHMARK(p) if (++PL_markstack_ptr == PL_markstack_max)	\
-			markstack_grow();			\
-		    *PL_markstack_ptr = (p) - PL_stack_base
+#define PUSHMARK(p)	\
+	STMT_START {					\
+	    if (++PL_markstack_ptr == PL_markstack_max)	\
+	    markstack_grow();				\
+	    *PL_markstack_ptr = (p) - PL_stack_base;	\
+	} STMT_END
 
 #define TOPMARK		(*PL_markstack_ptr)
 #define POPMARK		(*PL_markstack_ptr--)
@@ -78,7 +81,7 @@
 #define ORIGMARK	(PL_stack_base + origmark)
 
 #define SPAGAIN		sp = PL_stack_sp
-#define MSPAGAIN	sp = PL_stack_sp; mark = ORIGMARK
+#define MSPAGAIN	STMT_START { sp = PL_stack_sp; mark = ORIGMARK; } STMT_END
 
 #define GETTARGETSTACKED targ = (PL_op->op_flags & OPf_STACKED ? POPs : PAD_SV(PL_op->op_targ))
 #define dTARGETSTACKED SV * GETTARGETSTACKED
@@ -445,17 +448,20 @@
 #define tryAMAGICun(meth)	tryAMAGICunW(meth,SETsvUN,0,RETURN)
 #define tryAMAGICunSET(meth)	tryAMAGICunW(meth,SETs,0,RETURN)
 #define tryAMAGICunTARGET(meth, shift)					\
-	{ dSP; sp--; 	/* get TARGET from below PL_stack_sp */		\
+	STMT_START { dSP; sp--; 	/* get TARGET from below PL_stack_sp */		\
 	    { dTARGETSTACKED; 						\
-		{ dSP; tryAMAGICunW(meth,FORCE_SETs,shift,RETURN);}}}
+		{ dSP; tryAMAGICunW(meth,FORCE_SETs,shift,RETURN);}}} STMT_END
 
-#define setAGAIN(ref) sv = ref;							\
-  if (!SvROK(ref))								\
-      Perl_croak(aTHX_ "Overloaded dereference did not return a reference");	\
-  if (ref != arg && SvRV(ref) != SvRV(arg)) {					\
-      arg = ref;								\
-      goto am_again;								\
-  }
+#define setAGAIN(ref)	\
+    STMT_START {					\
+	sv = ref;					\
+	if (!SvROK(ref))				\
+	    Perl_croak(aTHX_ "Overloaded dereference did not return a reference");	\
+	if (ref != arg && SvRV(ref) != SvRV(arg)) {	\
+	    arg = ref;					\
+	    goto am_again;				\
+	}						\
+    } STMT_END
 
 #define tryAMAGICunDEREF(meth) tryAMAGICunW(meth,setAGAIN,0,(void)0)
 




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About