From: Steven Schubiger Date: Thu, 7 Feb 2008 17:51:58 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5de3775cb1f5ef0af0777e63f1032a2b570b9dd9;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080207165158.GA22321@refcnt.homeunix.org> p4raw-id: //depot/perl@33249 --- diff --git a/embed.fnc b/embed.fnc index 2cc3250..9a6dfe5 100644 --- a/embed.fnc +++ b/embed.fnc @@ -813,17 +813,17 @@ s |bool |glob_2number |NN GV* const gv s |char* |glob_2pv |NN GV* const gv|NULLOK STRLEN * const len #endif Amb |IV |sv_2iv |NN SV* sv -Apd |IV |sv_2iv_flags |NN SV* sv|I32 flags +Apd |IV |sv_2iv_flags |NN SV *const sv|const I32 flags Apd |SV* |sv_2mortal |NULLOK SV* sv -Apd |NV |sv_2nv |NN SV* sv -pMd |SV* |sv_2num |NN SV* sv +Apd |NV |sv_2nv |NN SV *const sv +pMd |SV* |sv_2num |NN SV *const sv Amb |char* |sv_2pv |NN SV* sv|NULLOK STRLEN* lp -Apd |char* |sv_2pv_flags |NN SV* sv|NULLOK STRLEN* lp|I32 flags +Apd |char* |sv_2pv_flags |NN SV *const sv|NULLOK STRLEN *const lp|const I32 flags Apd |char* |sv_2pvutf8 |NN SV* sv|NULLOK STRLEN* lp -Apd |char* |sv_2pvbyte |NN SV* sv|NULLOK STRLEN* lp +Apd |char* |sv_2pvbyte |NN SV *const sv|NULLOK STRLEN *const lp Ap |char* |sv_pvn_nomg |NN SV* sv|NULLOK STRLEN* lp Amb |UV |sv_2uv |NN SV* sv -Apd |UV |sv_2uv_flags |NN SV* sv|I32 flags +Apd |UV |sv_2uv_flags |NN SV *const sv|const I32 flags Apd |IV |sv_iv |NN SV* sv Apd |UV |sv_uv |NN SV* sv Apd |NV |sv_nv |NN SV* sv @@ -1492,7 +1492,7 @@ poM |int |sv_kill_backrefs |NN SV *sv|NN AV *av #endif #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) -nsR |char * |uiv_2buf |NN char *buf|IV iv|UV uv|int is_uv|NN char **peob +nsR |char * |uiv_2buf |NN char *const buf|const IV iv|UV uv|const int is_uv|NN char **const peob s |void |sv_unglob |NN SV* sv s |void |not_a_number |NN SV *const sv s |I32 |visit |NN SVFUNC_t f|const U32 flags|const U32 mask @@ -1504,9 +1504,9 @@ s |void |del_sv |NN SV *p # endif # if !defined(NV_PRESERVES_UV) # ifdef DEBUGGING -s |int |sv_2iuv_non_preserve |NN SV *sv|I32 numtype +s |int |sv_2iuv_non_preserve |NN SV *const sv|I32 numtype # else -s |int |sv_2iuv_non_preserve |NN SV *sv +s |int |sv_2iuv_non_preserve |NN SV *const sv # endif # endif sR |I32 |expect_number |NN char** pattern @@ -1528,7 +1528,7 @@ sM |void |sv_release_COW |NN SV *sv|NN const char *pvx|NN SV *after # endif s |SV * |more_sv s |void * |more_bodies |const svtype sv_type -s |bool |sv_2iuv_common |NN SV *sv +s |bool |sv_2iuv_common |NN SV *const sv s |void |glob_assign_glob|NN SV *dstr|NN SV *sstr|const int dtype s |void |glob_assign_ref|NN SV *dstr|NN SV *sstr sRn |PTR_TBL_ENT_t *|ptr_table_find|NN PTR_TBL_t *tbl|NN const void *sv @@ -1626,7 +1626,7 @@ Apd |void |sv_catpvn_flags|NN SV* sv|NN const char* ptr|STRLEN len|I32 flags Apd |void |sv_catsv_flags |NN SV* dsv|NULLOK SV* ssv|I32 flags Apd |STRLEN |sv_utf8_upgrade_flags|NN SV *sv|I32 flags Apd |char* |sv_pvn_force_flags|NN SV* sv|NULLOK STRLEN* lp|I32 flags -Apd |void |sv_copypv |NN SV* dsv|NN SV* ssv +Apd |void |sv_copypv |NN SV *const dsv|NN SV *const ssv Ap |char* |my_atof2 |NN const char *s|NN NV* value Apn |int |my_socketpair |int family|int type|int protocol|int fd[2] Ap |int |my_dirfd |NULLOK DIR* dir diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 6cf527c..17bc41c 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5358,7 +5358,7 @@ Return the integer value of an SV, doing any necessary string conversion. If flags includes SV_GMAGIC, does an mg_get() first. Normally used via the C and C macros. - IV sv_2iv_flags(SV* sv, I32 flags) + IV sv_2iv_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c @@ -5384,7 +5384,7 @@ Return the num value of an SV, doing any necessary string or integer conversion, magic etc. Normally used via the C and C macros. - NV sv_2nv(SV* sv) + NV sv_2nv(SV *const sv) =for hackers Found in file sv.c @@ -5398,7 +5398,7 @@ side-effect. Usually accessed via the C macro. - char* sv_2pvbyte(SV* sv, STRLEN* lp) + char* sv_2pvbyte(SV *const sv, STRLEN *const lp) =for hackers Found in file sv.c @@ -5425,7 +5425,7 @@ if necessary. Normally invoked via the C macro. C and C usually end up here too. - char* sv_2pv_flags(SV* sv, STRLEN* lp, I32 flags) + char* sv_2pv_flags(SV *const sv, STRLEN *const lp, const I32 flags) =for hackers Found in file sv.c @@ -5437,7 +5437,7 @@ Return the unsigned integer value of an SV, doing any necessary string conversion. If flags includes SV_GMAGIC, does an mg_get() first. Normally used via the C and C macros. - UV sv_2uv_flags(SV* sv, I32 flags) + UV sv_2uv_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c @@ -5658,7 +5658,7 @@ sv_2pv[_flags] but operates directly on an SV instead of just the string. Mostly uses sv_2pv_flags to do its work, except when that would lose the UTF-8'ness of the PV. - void sv_copypv(SV* dsv, SV* ssv) + void sv_copypv(SV *const dsv, SV *const ssv) =for hackers Found in file sv.c diff --git a/pod/perlintern.pod b/pod/perlintern.pod index 3703b40..3b2b155 100644 --- a/pod/perlintern.pod +++ b/pod/perlintern.pod @@ -1050,7 +1050,7 @@ Return an SV with the numeric value of the source SV, doing any necessary reference or overload conversion. You must use the C macro to access this function. - SV* sv_2num(SV* sv) + SV* sv_2num(SV *const sv) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index 37ee797..35e8ae2 100644 --- a/proto.h +++ b/proto.h @@ -2170,26 +2170,26 @@ STATIC char* S_glob_2pv(pTHX_ GV* const gv, STRLEN * const len) /* PERL_CALLCONV IV Perl_sv_2iv(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); */ -PERL_CALLCONV IV Perl_sv_2iv_flags(pTHX_ SV* sv, I32 flags) +PERL_CALLCONV IV Perl_sv_2iv_flags(pTHX_ SV *const sv, const I32 flags) __attribute__nonnull__(pTHX_1); PERL_CALLCONV SV* Perl_sv_2mortal(pTHX_ SV* sv); -PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV* sv) +PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV SV* Perl_sv_2num(pTHX_ SV* sv) +PERL_CALLCONV SV* Perl_sv_2num(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); /* PERL_CALLCONV char* Perl_sv_2pv(pTHX_ SV* sv, STRLEN* lp) __attribute__nonnull__(pTHX_1); */ -PERL_CALLCONV char* Perl_sv_2pv_flags(pTHX_ SV* sv, STRLEN* lp, I32 flags) +PERL_CALLCONV char* Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags) __attribute__nonnull__(pTHX_1); PERL_CALLCONV char* Perl_sv_2pvutf8(pTHX_ SV* sv, STRLEN* lp) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV char* Perl_sv_2pvbyte(pTHX_ SV* sv, STRLEN* lp) +PERL_CALLCONV char* Perl_sv_2pvbyte(pTHX_ SV *const sv, STRLEN *const lp) __attribute__nonnull__(pTHX_1); PERL_CALLCONV char* Perl_sv_pvn_nomg(pTHX_ SV* sv, STRLEN* lp) @@ -2198,7 +2198,7 @@ PERL_CALLCONV char* Perl_sv_pvn_nomg(pTHX_ SV* sv, STRLEN* lp) /* PERL_CALLCONV UV Perl_sv_2uv(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); */ -PERL_CALLCONV UV Perl_sv_2uv_flags(pTHX_ SV* sv, I32 flags) +PERL_CALLCONV UV Perl_sv_2uv_flags(pTHX_ SV *const sv, const I32 flags) __attribute__nonnull__(pTHX_1); PERL_CALLCONV IV Perl_sv_iv(pTHX_ SV* sv) @@ -3945,7 +3945,7 @@ PERL_CALLCONV int Perl_sv_kill_backrefs(pTHX_ SV *sv, AV *av) #endif #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) -STATIC char * S_uiv_2buf(char *buf, IV iv, UV uv, int is_uv, char **peob) +STATIC char * S_uiv_2buf(char *const buf, const IV iv, UV uv, const int is_uv, char **const peob) __attribute__warn_unused_result__ __attribute__nonnull__(1) __attribute__nonnull__(5); @@ -3973,11 +3973,11 @@ STATIC void S_del_sv(pTHX_ SV *p) # endif # if !defined(NV_PRESERVES_UV) # ifdef DEBUGGING -STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *sv, I32 numtype) +STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *const sv, I32 numtype) __attribute__nonnull__(pTHX_1); # else -STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *sv) +STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); # endif @@ -4023,7 +4023,7 @@ STATIC void S_sv_release_COW(pTHX_ SV *sv, const char *pvx, SV *after) # endif STATIC SV * S_more_sv(pTHX); STATIC void * S_more_bodies(pTHX_ const svtype sv_type); -STATIC bool S_sv_2iuv_common(pTHX_ SV *sv) +STATIC bool S_sv_2iuv_common(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); STATIC void S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype) @@ -4243,7 +4243,7 @@ PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade_flags(pTHX_ SV *sv, I32 flags) PERL_CALLCONV char* Perl_sv_pvn_force_flags(pTHX_ SV* sv, STRLEN* lp, I32 flags) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_copypv(pTHX_ SV* dsv, SV* ssv) +PERL_CALLCONV void Perl_sv_copypv(pTHX_ SV *const dsv, SV *const ssv) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); diff --git a/sv.c b/sv.c index 59fc604..41374b2 100644 --- a/sv.c +++ b/sv.c @@ -1863,7 +1863,7 @@ S_glob_2pv(pTHX_ GV * const gv, STRLEN * const len) /* For sv_2nv these three cases are "SvNOK and don't bother casting" */ STATIC int -S_sv_2iuv_non_preserve(pTHX_ register SV *sv +S_sv_2iuv_non_preserve(pTHX_ register SV *const sv # ifdef DEBUGGING , I32 numtype # endif @@ -1915,7 +1915,7 @@ S_sv_2iuv_non_preserve(pTHX_ register SV *sv #endif /* !NV_PRESERVES_UV*/ STATIC bool -S_sv_2iuv_common(pTHX_ SV *sv) { +S_sv_2iuv_common(pTHX_ SV *const sv) { dVAR; if (SvNOKp(sv)) { /* erm. not sure. *should* never get NOKp (without NOK) from sv_2nv @@ -2191,7 +2191,7 @@ Normally used via the C and C macros. */ IV -Perl_sv_2iv_flags(pTHX_ register SV *sv, I32 flags) +Perl_sv_2iv_flags(pTHX_ register SV *const sv, const I32 flags) { dVAR; if (!sv) @@ -2275,7 +2275,7 @@ Normally used via the C and C macros. */ UV -Perl_sv_2uv_flags(pTHX_ register SV *sv, I32 flags) +Perl_sv_2uv_flags(pTHX_ register SV *const sv, const I32 flags) { dVAR; if (!sv) @@ -2352,7 +2352,7 @@ macros. */ NV -Perl_sv_2nv(pTHX_ register SV *sv) +Perl_sv_2nv(pTHX_ register SV *const sv) { dVAR; if (!sv) @@ -2577,7 +2577,7 @@ access this function. */ SV * -Perl_sv_2num(pTHX_ register SV *sv) +Perl_sv_2num(pTHX_ register SV *const sv) { if (!SvROK(sv)) return sv; @@ -2597,7 +2597,7 @@ Perl_sv_2num(pTHX_ register SV *sv) */ static char * -S_uiv_2buf(char *buf, IV iv, UV uv, int is_uv, char **peob) +S_uiv_2buf(char *const buf, const IV iv, UV uv, const int is_uv, char **const peob) { char *ptr = buf + TYPE_CHARS(UV); char * const ebuf = ptr; @@ -2634,7 +2634,7 @@ usually end up here too. */ char * -Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags) +Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN *const lp, const I32 flags) { dVAR; register char *s; @@ -2919,7 +2919,7 @@ would lose the UTF-8'ness of the PV. */ void -Perl_sv_copypv(pTHX_ SV *dsv, register SV *ssv) +Perl_sv_copypv(pTHX_ SV *const dsv, register SV *const ssv) { STRLEN len; const char * const s = SvPV_const(ssv,len); @@ -2943,7 +2943,7 @@ Usually accessed via the C macro. */ char * -Perl_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp) +Perl_sv_2pvbyte(pTHX_ register SV *const sv, STRLEN *const lp) { sv_utf8_downgrade(sv,0); return lp ? SvPV(sv,*lp) : SvPV_nolen(sv);