summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-06 15:21:53 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-06 15:21:53 +0000
commitede1273d4e7ecb92df498e88937c3198127171a4 (patch)
tree14f4a7fa8583d7bea84c34019b0518e54bf9053f /op.h
parent9cddf794fc52f08a145668164b1e3c15c91a713f (diff)
downloadperl-ede1273d4e7ecb92df498e88937c3198127171a4.tar.gz
Enforce some type safety in PM_SETRE by adding PM_SETRE_OFFSET.
p4raw-id: //depot/perl@32868
Diffstat (limited to 'op.h')
-rw-r--r--op.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/op.h b/op.h
index 264dd52ab8..adf5d1f223 100644
--- a/op.h
+++ b/op.h
@@ -330,10 +330,20 @@ struct pmop {
#ifdef USE_ITHREADS
#define PM_GETRE(o) (INT2PTR(REGEXP*,SvIVX(PL_regex_pad[(o)->op_pmoffset])))
-#define PM_SETRE(o,r) STMT_START { \
+/* The assignment is just to enforce type safety (or at least get a warning).
+ */
+#define PM_SETRE(o,r) STMT_START { \
+ const REGEXP *const slosh = (r); \
+ PM_SETRE_OFFSET((o), PTR2IV(slosh)); \
+ } STMT_END
+/* Actually you can assign any IV, not just an offset. And really should it be
+ UV? */
+#define PM_SETRE_OFFSET(o,iv) \
+ STMT_START { \
SV* const sv = PL_regex_pad[(o)->op_pmoffset]; \
- sv_setiv(sv, PTR2IV(r)); \
+ sv_setiv(sv, (iv)); \
} STMT_END
+
# ifndef PERL_CORE
/* No longer used anywhere in the core. Migrate to Devel::PPPort? */
#define PM_GETRE_SAFE(o) (PL_regex_pad ? PM_GETRE(o) : (REGEXP*)0)