summaryrefslogtreecommitdiff
path: root/mg.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-10-27 20:25:46 +0000
committerNicholas Clark <nick@ccl4.org>2008-10-27 20:25:46 +0000
commitb1bc3f345d4dfe19cd94c120c46649336b5cb92b (patch)
treebdfcef0c7875037af6a5fa8195d2203fe76e6b27 /mg.h
parentbb5dd93d07e2d54d352e519c7b43ff2d3e5c5f36 (diff)
downloadperl-b1bc3f345d4dfe19cd94c120c46649336b5cb92b.tar.gz
Add a macro MUTABLE_PTR(p), which on (non-pedantic) gcc will not cast
away const, returning a void *. Add MUTABLE_SV(sv) which uses this, and replace all (SV *) casts either with MUTABLE_SV(sv), or (const SV *). This probably still needs some work - assigning to SvPVX() and SvRV() is now likely to generate a casting error. The core doesn't do this. But as-is it's finding bugs that can be fixed. p4raw-id: //depot/perl@34605
Diffstat (limited to 'mg.h')
-rw-r--r--mg.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/mg.h b/mg.h
index 1274efda85..fcac411113 100644
--- a/mg.h
+++ b/mg.h
@@ -48,13 +48,13 @@ struct magic {
#define MgTAINTEDDIR_off(mg) (mg->mg_flags &= ~MGf_TAINTEDDIR)
#define MgPV(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \
- SvPV((SV*)((mg)->mg_ptr),lp) : \
+ SvPV(MUTABLE_SV((mg)->mg_ptr),lp) : \
(mg)->mg_ptr)
#define MgPV_const(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \
- SvPV_const((SV*)((mg)->mg_ptr),lp) : \
+ SvPV_const(MUTABLE_SV((mg)->mg_ptr),lp) : \
(const char*)(mg)->mg_ptr)
-#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \
- SvPV_nolen_const((SV*)((mg)->mg_ptr)) : \
+#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \
+ SvPV_nolen_const(MUTABLE_SV((mg)->mg_ptr)) : \
(const char*)(mg)->mg_ptr)
#define SvTIED_mg(sv,how) (SvRMAGICAL(sv) ? mg_find((sv),(how)) : NULL)