diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-10-29 23:20:01 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-10-29 23:20:01 +0000 |
commit | a45c7426c93f17067d1734c68cb400246e1db490 (patch) | |
tree | e085a582d4f0b4b9dac9b8741884c96da1bee43a | |
parent | 76f68e9bb86f29e34e2aeb5c177571288f05b7ca (diff) | |
download | perl-a45c7426c93f17067d1734c68cb400246e1db490.tar.gz |
Add MUTABLE_IO(), and eliminate (IO *) casts in *.c.
p4raw-id: //depot/perl@34654
-rw-r--r-- | doio.c | 2 | ||||
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | handy.h | 1 | ||||
-rw-r--r-- | perl.c | 6 | ||||
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | pp_sys.c | 4 | ||||
-rw-r--r-- | sv.c | 10 |
7 files changed, 14 insertions, 13 deletions
@@ -1316,7 +1316,7 @@ Perl_my_stat(pTHX) goto do_fstat; } else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) { - io = (IO*)SvRV(sv); + io = MUTABLE_IO(SvRV(sv)); gv = NULL; goto do_fstat_have_io; } @@ -1499,7 +1499,7 @@ Perl_newIO(pTHX) { dVAR; GV *iogv; - IO * const io = (IO*)newSV_type(SVt_PVIO); + IO * const io = MUTABLE_IO(newSV_type(SVt_PVIO)); /* This used to read SvREFCNT(io) = 1; It's not clear why the reference count needed an explicit reset. NWC */ @@ -57,6 +57,7 @@ Null SV pointer. (No longer available when C<PERL_CORE> is defined.) #define MUTABLE_AV(p) ((AV *)MUTABLE_PTR(p)) #define MUTABLE_CV(p) ((CV *)MUTABLE_PTR(p)) #define MUTABLE_HV(p) ((HV *)MUTABLE_PTR(p)) +#define MUTABLE_IO(p) ((IO *)MUTABLE_PTR(p)) #define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) /* XXX Configure ought to have a test for a boolean type, if I can @@ -4554,7 +4554,7 @@ S_init_predump_symbols(pTHX) IoIFP(io) = PerlIO_stdin(); tmpgv = gv_fetchpvs("stdin", GV_ADD|GV_NOTQUAL, SVt_PV); GvMULTI_on(tmpgv); - GvIOp(tmpgv) = (IO*)SvREFCNT_inc_simple(io); + GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io)); tmpgv = gv_fetchpvs("STDOUT", GV_ADD|GV_NOTQUAL, SVt_PVIO); GvMULTI_on(tmpgv); @@ -4564,7 +4564,7 @@ S_init_predump_symbols(pTHX) setdefout(tmpgv); tmpgv = gv_fetchpvs("stdout", GV_ADD|GV_NOTQUAL, SVt_PV); GvMULTI_on(tmpgv); - GvIOp(tmpgv) = (IO*)SvREFCNT_inc_simple(io); + GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io)); PL_stderrgv = gv_fetchpvs("STDERR", GV_ADD|GV_NOTQUAL, SVt_PVIO); GvMULTI_on(PL_stderrgv); @@ -4573,7 +4573,7 @@ S_init_predump_symbols(pTHX) IoOFP(io) = IoIFP(io) = PerlIO_stderr(); tmpgv = gv_fetchpvs("stderr", GV_ADD|GV_NOTQUAL, SVt_PV); GvMULTI_on(tmpgv); - GvIOp(tmpgv) = (IO*)SvREFCNT_inc_simple(io); + GvIOp(tmpgv) = MUTABLE_IO(SvREFCNT_inc_simple(io)); PL_statname = newSV(0); /* last filename we did stat on */ @@ -139,7 +139,7 @@ PP(pp_rv2gv) if (SvTYPE(sv) == SVt_PVIO) { GV * const gv = (GV*) sv_newmortal(); gv_init(gv, 0, "", 0, 0); - GvIOp(gv) = (IO *)sv; + GvIOp(gv) = MUTABLE_IO(sv); SvREFCNT_inc_void_NN(sv); sv = (SV*) gv; } @@ -2207,7 +2207,7 @@ PP(pp_truncate) goto do_ftruncate_gv; } else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) { - io = (IO*) SvRV(sv); /* *main::FRED{IO} for example */ + io = MUTABLE_IO(SvRV(sv)); /* *main::FRED{IO} for example */ goto do_ftruncate_io; } @@ -2854,7 +2854,7 @@ PP(pp_stat) goto do_fstat_warning_check; goto do_fstat; } else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) { - io = (IO*)SvRV(sv); + io = MUTABLE_IO(SvRV(sv)); if (PL_op->op_type == OP_LSTAT) goto do_fstat_warning_check; goto do_fstat_have_io; @@ -4736,7 +4736,7 @@ Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const int how, */ if (how == PERL_MAGIC_tiedscalar && SvTYPE(sv) == SVt_PVIO && - obj && SvROK(obj) && GvIO(SvRV(obj)) == (IO*)sv) + obj && SvROK(obj) && GvIO(SvRV(obj)) == (const IO *)sv) { sv_rvweaken(obj); } @@ -5494,7 +5494,7 @@ Perl_sv_clear(pTHX_ register SV *const sv) IoIFP(sv) != PerlIO_stdout() && IoIFP(sv) != PerlIO_stderr()) { - io_close((IO*)sv, FALSE); + io_close(MUTABLE_IO(sv), FALSE); } if (IoDIRP(sv) && !(IoFLAGS(sv) & IOf_FAKE_DIRP)) PerlDir_close(IoDIRP(sv)); @@ -7889,7 +7889,7 @@ Perl_sv_2io(pTHX_ SV *const sv) switch (SvTYPE(sv)) { case SVt_PVIO: - io = (IO*)sv; + io = MUTABLE_IO(sv); break; case SVt_PVGV: if (isGV_with_GP(sv)) { @@ -10090,8 +10090,8 @@ ptr_table_* functions. #define hv_dup_inc(s,t) MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)s,t))) #define cv_dup(s,t) MUTABLE_CV(sv_dup((SV*)s,t)) #define cv_dup_inc(s,t) MUTABLE_CV(SvREFCNT_inc(sv_dup((const SV *)s,t))) -#define io_dup(s,t) (IO*)sv_dup((SV*)s,t) -#define io_dup_inc(s,t) (IO*)SvREFCNT_inc(sv_dup((const SV *)s,t)) +#define io_dup(s,t) MUTABLE_IO(sv_dup((SV*)s,t)) +#define io_dup_inc(s,t) MUTABLE_IO(SvREFCNT_inc(sv_dup((const SV *)s,t))) #define gv_dup(s,t) (GV*)sv_dup((SV*)s,t) #define gv_dup_inc(s,t) (GV*)SvREFCNT_inc(sv_dup((const SV *)s,t)) #define SAVEPV(p) ((p) ? savepv(p) : NULL) |