From: Steven Schubiger Date: Tue, 11 Mar 2008 11:49:30 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=12964ddd5d77e0f02593286e5ca100221b0f8c59;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080311104929.GA4950@refcnt.homeunix.org> p4raw-id: //depot/perl@33473 --- diff --git a/embed.fnc b/embed.fnc index f37e51e..1dd81d5 100644 --- a/embed.fnc +++ b/embed.fnc @@ -610,7 +610,7 @@ Apda |SV* |newSVhek |NULLOK const HEK *const hek Apda |SV* |newSVpvn_share |NULLOK const char* s|I32 len|U32 hash Afpda |SV* |newSVpvf |NN const char *const pat|... Apa |SV* |vnewSVpvf |NN const char *const pat|NULLOK va_list *const args -Apd |SV* |newSVrv |NN SV* rv|NULLOK const char* classname +Apd |SV* |newSVrv |NN SV *const rv|NULLOK const char *const classname Apda |SV* |newSVsv |NULLOK SV *const old Apda |SV* |newSV_type |const svtype type Apa |OP* |newUNOP |I32 type|I32 flags|NULLOK OP* first @@ -852,7 +852,7 @@ Apd |char* |sv_pvbyten |NN SV *sv|NN STRLEN *lp Apd |I32 |sv_true |NULLOK SV *const sv pd |void |sv_add_arena |NN char *const ptr|const U32 size|const U32 flags Apd |int |sv_backoff |NN SV *const sv -Apd |SV* |sv_bless |NN SV* sv|NN HV* stash +Apd |SV* |sv_bless |NN SV *const sv|NN HV *const stash Afpd |void |sv_catpvf |NN SV* sv|NN const char* pat|... Apd |void |sv_vcatpvf |NN SV* sv|NN const char* pat|NULLOK va_list* args Apd |void |sv_catpv |NN SV *const sv|NULLOK const char* ptr @@ -883,7 +883,7 @@ Apd |char* |sv_grow |NN SV *const sv|STRLEN newlen Apd |void |sv_inc |NULLOK SV *const sv Apd |void |sv_insert |NN SV *const bigstr|const STRLEN offset|const STRLEN len \ |NN const char *const little|const STRLEN littlelen -Apd |int |sv_isa |NULLOK SV* sv|NN const char* name +Apd |int |sv_isa |NULLOK SV* sv|NN const char *const name Apd |int |sv_isobject |NULLOK SV* sv Apd |STRLEN |sv_len |NULLOK SV *const sv Apd |STRLEN |sv_len_utf8 |NULLOK SV *const sv @@ -899,12 +899,12 @@ Ap |char* |sv_peek |NULLOK SV* sv Apd |void |sv_pos_u2b |NULLOK SV *const sv|NN I32 *const offsetp|NULLOK I32 *const lenp Apd |void |sv_pos_b2u |NULLOK SV *const sv|NN I32 *const offsetp Amdb |char* |sv_pvn_force |NN SV* sv|NULLOK STRLEN* lp -Apd |char* |sv_pvutf8n_force|NN SV* sv|NULLOK STRLEN* lp -Apd |char* |sv_pvbyten_force|NN SV* sv|NULLOK STRLEN* lp +Apd |char* |sv_pvutf8n_force|NN SV *const sv|NULLOK STRLEN *const lp +Apd |char* |sv_pvbyten_force|NN SV *const sv|NULLOK STRLEN *const lp Apd |char* |sv_recode_to_utf8 |NN SV* sv|NN SV *encoding Apd |bool |sv_cat_decode |NN SV* dsv|NN SV *encoding|NN SV *ssv|NN int *offset \ |NN char* tstr|int tlen -ApdR |const char* |sv_reftype |NN const SV* sv|int ob +ApdR |const char* |sv_reftype |NN const SV *const sv|const int ob Apd |void |sv_replace |NN SV *const sv|NN SV *const nsv Apd |void |sv_report_used Apd |void |sv_reset |NN const char* s|NULLOK HV *const stash @@ -914,11 +914,13 @@ Apd |void |sv_setiv |NN SV *const sv|const IV num Apdb |void |sv_setpviv |NN SV* sv|IV num Apd |void |sv_setuv |NN SV *const sv|const UV num Apd |void |sv_setnv |NN SV *const sv|const NV num -Apd |SV* |sv_setref_iv |NN SV* rv|NULLOK const char* classname|IV iv -Apd |SV* |sv_setref_uv |NN SV* rv|NULLOK const char* classname|UV uv -Apd |SV* |sv_setref_nv |NN SV* rv|NULLOK const char* classname|NV nv -Apd |SV* |sv_setref_pv |NN SV* rv|NULLOK const char* classname|NULLOK void* pv -Apd |SV* |sv_setref_pvn |NN SV* rv|NULLOK const char* classname|NN const char* pv|STRLEN n +Apd |SV* |sv_setref_iv |NN SV *const rv|NULLOK const char *const classname|const IV iv +Apd |SV* |sv_setref_uv |NN SV *const rv|NULLOK const char *const classname|const UV uv +Apd |SV* |sv_setref_nv |NN SV *const rv|NULLOK const char *const classname|const NV nv +Apd |SV* |sv_setref_pv |NN SV *const rv|NULLOK const char *const classname \ + |NULLOK void *const pv +Apd |SV* |sv_setref_pvn |NN SV *const rv|NULLOK const char *const classname \ + |NN const char *const pv|const STRLEN n Apd |void |sv_setpv |NN SV *const sv|NULLOK const char *const ptr Apd |void |sv_setpvn |NN SV *const sv|NULLOK const char *const ptr|const STRLEN len Amdb |void |sv_setsv |NN SV *dstr|NULLOK SV *sstr @@ -1673,7 +1675,7 @@ Apd |void |sv_catpvn_flags|NN SV *const dstr|NN const char *sstr|const STRLEN le |const I32 flags Apd |void |sv_catsv_flags |NN SV *const dsv|NULLOK SV *const ssv|const I32 flags Apd |STRLEN |sv_utf8_upgrade_flags|NN SV *const sv|const I32 flags -Apd |char* |sv_pvn_force_flags|NN SV* sv|NULLOK STRLEN* lp|I32 flags +Apd |char* |sv_pvn_force_flags|NN SV *const sv|NULLOK STRLEN *const lp|const I32 flags 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] diff --git a/pod/perlapi.pod b/pod/perlapi.pod index dc0401f..26420de 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5278,7 +5278,7 @@ it will be upgraded to one. If C is non-null then the new SV will be blessed in the specified package. The new SV is returned and its reference count is 1. - SV* newSVrv(SV* rv, const char* classname) + SV* newSVrv(SV *const rv, const char *const classname) =for hackers Found in file sv.c @@ -5460,7 +5460,7 @@ Blesses an SV into a specified package. The SV must be an RV. The package must be designated by its stash (see C). The reference count of the SV is unaffected. - SV* sv_bless(SV* sv, HV* stash) + SV* sv_bless(SV *const sv, HV *const stash) =for hackers Found in file sv.c @@ -5769,7 +5769,7 @@ Returns a boolean indicating whether the SV is blessed into the specified class. This does not check for subtypes; use C to verify an inheritance relationship. - int sv_isa(SV* sv, const char* name) + int sv_isa(SV* sv, const char *const name) =for hackers Found in file sv.c @@ -5915,7 +5915,7 @@ X The backend for the C macro. Always use the macro instead. - char* sv_pvbyten_force(SV* sv, STRLEN* lp) + char* sv_pvbyten_force(SV *const sv, STRLEN *const lp) =for hackers Found in file sv.c @@ -5942,7 +5942,7 @@ implemented in terms of this function. You normally want to use the various wrapper macros instead: see C and C - char* sv_pvn_force_flags(SV* sv, STRLEN* lp, I32 flags) + char* sv_pvn_force_flags(SV *const sv, STRLEN *const lp, const I32 flags) =for hackers Found in file sv.c @@ -5952,7 +5952,7 @@ X The backend for the C macro. Always use the macro instead. - char* sv_pvutf8n_force(SV* sv, STRLEN* lp) + char* sv_pvutf8n_force(SV *const sv, STRLEN *const lp) =for hackers Found in file sv.c @@ -5962,7 +5962,7 @@ X Returns a string describing what the SV is a reference to. - const char* sv_reftype(const SV* sv, int ob) + const char* sv_reftype(const SV *const sv, const int ob) =for hackers Found in file sv.c @@ -6153,7 +6153,7 @@ the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. - SV* sv_setref_iv(SV* rv, const char* classname, IV iv) + SV* sv_setref_iv(SV *const rv, const char *const classname, const IV iv) =for hackers Found in file sv.c @@ -6167,7 +6167,7 @@ the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. - SV* sv_setref_nv(SV* rv, const char* classname, NV nv) + SV* sv_setref_nv(SV *const rv, const char *const classname, const NV nv) =for hackers Found in file sv.c @@ -6187,7 +6187,7 @@ objects will become corrupted by the pointer copy process. Note that C copies the string while this copies the pointer. - SV* sv_setref_pv(SV* rv, const char* classname, void* pv) + SV* sv_setref_pv(SV *const rv, const char *const classname, void *const pv) =for hackers Found in file sv.c @@ -6204,7 +6204,7 @@ of 1, and the RV will be returned. Note that C copies the pointer while this copies the string. - SV* sv_setref_pvn(SV* rv, const char* classname, const char* pv, STRLEN n) + SV* sv_setref_pvn(SV *const rv, const char *const classname, const char *const pv, const STRLEN n) =for hackers Found in file sv.c @@ -6218,7 +6218,7 @@ the new SV. The C argument indicates the package for the blessing. Set C to C to avoid the blessing. The new SV will have a reference count of 1, and the RV will be returned. - SV* sv_setref_uv(SV* rv, const char* classname, UV uv) + SV* sv_setref_uv(SV *const rv, const char *const classname, const UV uv) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index 8545e08..7d80e39 100644 --- a/proto.h +++ b/proto.h @@ -2221,7 +2221,7 @@ PERL_CALLCONV SV* Perl_vnewSVpvf(pTHX_ const char *const pat, va_list *const arg #define PERL_ARGS_ASSERT_VNEWSVPVF \ assert(pat) -PERL_CALLCONV SV* Perl_newSVrv(pTHX_ SV* rv, const char* classname) +PERL_CALLCONV SV* Perl_newSVrv(pTHX_ SV *const rv, const char *const classname) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_NEWSVRV \ assert(rv) @@ -3069,7 +3069,7 @@ PERL_CALLCONV int Perl_sv_backoff(pTHX_ SV *const sv) #define PERL_ARGS_ASSERT_SV_BACKOFF \ assert(sv) -PERL_CALLCONV SV* Perl_sv_bless(pTHX_ SV* sv, HV* stash) +PERL_CALLCONV SV* Perl_sv_bless(pTHX_ SV *const sv, HV *const stash) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_BLESS \ @@ -3185,7 +3185,7 @@ PERL_CALLCONV void Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, c #define PERL_ARGS_ASSERT_SV_INSERT \ assert(bigstr); assert(little) -PERL_CALLCONV int Perl_sv_isa(pTHX_ SV* sv, const char* name) +PERL_CALLCONV int Perl_sv_isa(pTHX_ SV* sv, const char *const name) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_ISA \ assert(name) @@ -3227,12 +3227,12 @@ PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV *const sv, I32 *const offsetp) #define PERL_ARGS_ASSERT_SV_PVN_FORCE \ assert(sv) -PERL_CALLCONV char* Perl_sv_pvutf8n_force(pTHX_ SV* sv, STRLEN* lp) +PERL_CALLCONV char* Perl_sv_pvutf8n_force(pTHX_ SV *const sv, STRLEN *const lp) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_PVUTF8N_FORCE \ assert(sv) -PERL_CALLCONV char* Perl_sv_pvbyten_force(pTHX_ SV* sv, STRLEN* lp) +PERL_CALLCONV char* Perl_sv_pvbyten_force(pTHX_ SV *const sv, STRLEN *const lp) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_PVBYTEN_FORCE \ assert(sv) @@ -3252,7 +3252,7 @@ PERL_CALLCONV bool Perl_sv_cat_decode(pTHX_ SV* dsv, SV *encoding, SV *ssv, int #define PERL_ARGS_ASSERT_SV_CAT_DECODE \ assert(dsv); assert(encoding); assert(ssv); assert(offset); assert(tstr) -PERL_CALLCONV const char* Perl_sv_reftype(pTHX_ const SV* sv, int ob) +PERL_CALLCONV const char* Perl_sv_reftype(pTHX_ const SV *const sv, const int ob) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_REFTYPE \ @@ -3303,27 +3303,27 @@ PERL_CALLCONV void Perl_sv_setnv(pTHX_ SV *const sv, const NV num) #define PERL_ARGS_ASSERT_SV_SETNV \ assert(sv) -PERL_CALLCONV SV* Perl_sv_setref_iv(pTHX_ SV* rv, const char* classname, IV iv) +PERL_CALLCONV SV* Perl_sv_setref_iv(pTHX_ SV *const rv, const char *const classname, const IV iv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETREF_IV \ assert(rv) -PERL_CALLCONV SV* Perl_sv_setref_uv(pTHX_ SV* rv, const char* classname, UV uv) +PERL_CALLCONV SV* Perl_sv_setref_uv(pTHX_ SV *const rv, const char *const classname, const UV uv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETREF_UV \ assert(rv) -PERL_CALLCONV SV* Perl_sv_setref_nv(pTHX_ SV* rv, const char* classname, NV nv) +PERL_CALLCONV SV* Perl_sv_setref_nv(pTHX_ SV *const rv, const char *const classname, const NV nv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETREF_NV \ assert(rv) -PERL_CALLCONV SV* Perl_sv_setref_pv(pTHX_ SV* rv, const char* classname, void* pv) +PERL_CALLCONV SV* Perl_sv_setref_pv(pTHX_ SV *const rv, const char *const classname, void *const pv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETREF_PV \ assert(rv) -PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV* rv, const char* classname, const char* pv, STRLEN n) +PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV *const rv, const char *const classname, const char *const pv, const STRLEN n) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_3); #define PERL_ARGS_ASSERT_SV_SETREF_PVN \ @@ -5902,7 +5902,7 @@ PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade_flags(pTHX_ SV *const sv, const I32 fl #define PERL_ARGS_ASSERT_SV_UTF8_UPGRADE_FLAGS \ assert(sv) -PERL_CALLCONV char* Perl_sv_pvn_force_flags(pTHX_ SV* sv, STRLEN* lp, I32 flags) +PERL_CALLCONV char* Perl_sv_pvn_force_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_PVN_FORCE_FLAGS \ assert(sv) diff --git a/sv.c b/sv.c index 1142045..341463b 100644 --- a/sv.c +++ b/sv.c @@ -7972,7 +7972,7 @@ C and C */ char * -Perl_sv_pvn_force_flags(pTHX_ SV *sv, STRLEN *lp, I32 flags) +Perl_sv_pvn_force_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags) { dVAR; @@ -8033,7 +8033,7 @@ The backend for the C macro. Always use the macro instead. */ char * -Perl_sv_pvbyten_force(pTHX_ SV *sv, STRLEN *lp) +Perl_sv_pvbyten_force(pTHX_ SV *const sv, STRLEN *const lp) { PERL_ARGS_ASSERT_SV_PVBYTEN_FORCE; @@ -8052,7 +8052,7 @@ The backend for the C macro. Always use the macro instead. */ char * -Perl_sv_pvutf8n_force(pTHX_ SV *sv, STRLEN *lp) +Perl_sv_pvutf8n_force(pTHX_ SV *const sv, STRLEN *const lp) { PERL_ARGS_ASSERT_SV_PVUTF8N_FORCE; @@ -8071,7 +8071,7 @@ Returns a string describing what the SV is a reference to. */ const char * -Perl_sv_reftype(pTHX_ const SV *sv, int ob) +Perl_sv_reftype(pTHX_ const SV *const sv, const int ob) { PERL_ARGS_ASSERT_SV_REFTYPE; @@ -8150,7 +8150,7 @@ an inheritance relationship. */ int -Perl_sv_isa(pTHX_ SV *sv, const char *name) +Perl_sv_isa(pTHX_ SV *sv, const char *const name) { const char *hvname; @@ -8183,7 +8183,7 @@ reference count is 1. */ SV* -Perl_newSVrv(pTHX_ SV *rv, const char *classname) +Perl_newSVrv(pTHX_ SV *const rv, const char *const classname) { dVAR; SV *sv; @@ -8239,7 +8239,7 @@ Note that C copies the string while this copies the pointer. */ SV* -Perl_sv_setref_pv(pTHX_ SV *rv, const char *classname, void *pv) +Perl_sv_setref_pv(pTHX_ SV *const rv, const char *const classname, void *const pv) { dVAR; @@ -8267,7 +8267,7 @@ will have a reference count of 1, and the RV will be returned. */ SV* -Perl_sv_setref_iv(pTHX_ SV *rv, const char *classname, IV iv) +Perl_sv_setref_iv(pTHX_ SV *const rv, const char *const classname, const IV iv) { PERL_ARGS_ASSERT_SV_SETREF_IV; @@ -8288,7 +8288,7 @@ will have a reference count of 1, and the RV will be returned. */ SV* -Perl_sv_setref_uv(pTHX_ SV *rv, const char *classname, UV uv) +Perl_sv_setref_uv(pTHX_ SV *const rv, const char *const classname, const UV uv) { PERL_ARGS_ASSERT_SV_SETREF_UV; @@ -8309,7 +8309,7 @@ will have a reference count of 1, and the RV will be returned. */ SV* -Perl_sv_setref_nv(pTHX_ SV *rv, const char *classname, NV nv) +Perl_sv_setref_nv(pTHX_ SV *const rv, const char *const classname, const NV nv) { PERL_ARGS_ASSERT_SV_SETREF_NV; @@ -8333,7 +8333,8 @@ Note that C copies the pointer while this copies the string. */ SV* -Perl_sv_setref_pvn(pTHX_ SV *rv, const char *classname, const char *pv, STRLEN n) +Perl_sv_setref_pvn(pTHX_ SV *const rv, const char *const classname, + const char *const pv, const STRLEN n) { PERL_ARGS_ASSERT_SV_SETREF_PVN; @@ -8352,7 +8353,7 @@ of the SV is unaffected. */ SV* -Perl_sv_bless(pTHX_ SV *sv, HV *stash) +Perl_sv_bless(pTHX_ SV *const sv, HV *const stash) { dVAR; SV *tmpRef;