From: Nicholas Clark Date: Sun, 6 Jan 2008 15:21:53 +0000 (+0000) Subject: Enforce some type safety in PM_SETRE by adding PM_SETRE_OFFSET. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ede1273d4e7ecb92df498e88937c3198127171a4;p=p5sagit%2Fp5-mst-13.2.git Enforce some type safety in PM_SETRE by adding PM_SETRE_OFFSET. p4raw-id: //depot/perl@32868 --- diff --git a/op.c b/op.c index 569a159..93a8bfd 100644 --- a/op.c +++ b/op.c @@ -627,7 +627,7 @@ clear_pmop: 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)); diff --git a/op.h b/op.h index 264dd52..adf5d1f 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)