Change 33141 by [EMAIL PROTECTED] on 2008/01/30 23:50:34
Integrate:
[ 32867]
Clarify the intent of the code in Perl_op_clear. Under ithreads, avoid
calling sv_ivset twice. As a side effect, eliminate PM_GETRE_SAFE
and PM_SETRE_SAFE, as we're doing "safe" explicitly in Perl_op_clear().
[ 32868]
Enforce some type safety in PM_SETRE by adding PM_SETRE_OFFSET.
Affected files ...
... //depot/maint-5.10/perl/op.c#5 integrate
... //depot/maint-5.10/perl/op.h#4 integrate
Differences ...
==== //depot/maint-5.10/perl/op.c#5 (text) ====
Index: perl/op.c
--- perl/op.c#4~33132~ 2008-01-30 10:18:00.000000000 -0800
+++ perl/op.c 2008-01-30 15:50:34.000000000 -0800
@@ -613,21 +613,23 @@
clear_pmop:
forget_pmop(cPMOPo, 1);
cPMOPo->op_pmreplrootu.op_pmreplroot = NULL;
- /* we use the "SAFE" version of the PM_ macros here
- * since sv_clean_all might release some PMOPs
+ /* we use the same protection as the "SAFE" version of the PM_ macros
+ * here since sv_clean_all might release some PMOPs
* after PL_regex_padav has been cleared
* and the clearing of PL_regex_padav needs to
* happen before sv_clean_all
*/
- ReREFCNT_dec(PM_GETRE_SAFE(cPMOPo));
- PM_SETRE_SAFE(cPMOPo, NULL);
#ifdef USE_ITHREADS
if(PL_regex_pad) { /* We could be in destruction */
+ ReREFCNT_dec(PM_GETRE(cPMOPo));
av_push((AV*) PL_regex_pad[0],(SV*)
PL_regex_pad[(cPMOPo)->op_pmoffset]);
SvREADONLY_off(PL_regex_pad[(cPMOPo)->op_pmoffset]);
SvREPADTMP_on(PL_regex_pad[(cPMOPo)->op_pmoffset]);
- PM_SETRE(cPMOPo, (cPMOPo)->op_pmoffset);
+ PM_SETRE_OFFSET(cPMOPo, (cPMOPo)->op_pmoffset);
}
+#else
+ ReREFCNT_dec(PM_GETRE(cPMOPo));
+ PM_SETRE(cPMOPo, NULL);
#endif
break;
==== //depot/maint-5.10/perl/op.h#4 (text) ====
Index: perl/op.h
--- perl/op.h#3~33131~ 2008-01-30 09:34:36.000000000 -0800
+++ perl/op.h 2008-01-30 15:50:34.000000000 -0800
@@ -330,17 +330,32 @@
#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)
#define PM_SETRE_SAFE(o,r) if (PL_regex_pad) PM_SETRE(o,r)
+# endif
#else
#define PM_GETRE(o) ((o)->op_pmregexp)
#define PM_SETRE(o,r) ((o)->op_pmregexp = (r))
+# ifndef PERL_CORE
#define PM_GETRE_SAFE PM_GETRE
#define PM_SETRE_SAFE PM_SETRE
+# endif
#endif
End of Patch.