From: Steven Schubiger Date: Tue, 11 Mar 2008 19:59:37 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=89e382121886b3fe97bf9b7381d1b1849bea6bda;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080311185937.GA18713@refcnt.homeunix.org> p4raw-id: //depot/perl@33489 --- diff --git a/embed.fnc b/embed.fnc index 1dd81d5..ff29a11 100644 --- a/embed.fnc +++ b/embed.fnc @@ -158,10 +158,10 @@ Afnp |SV* |mess_nocontext |NN const char* pat|... Afnp |void |warn_nocontext |NN const char* pat|... Afnp |void |warner_nocontext|U32 err|NN const char* pat|... Afnp |SV* |newSVpvf_nocontext|NN const char *const pat|... -Afnp |void |sv_catpvf_nocontext|NN SV* sv|NN const char* pat|... -Afnp |void |sv_setpvf_nocontext|NN SV* sv|NN const char* pat|... -Afnp |void |sv_catpvf_mg_nocontext|NN SV* sv|NN const char* pat|... -Afnp |void |sv_setpvf_mg_nocontext|NN SV* sv|NN const char* pat|... +Afnp |void |sv_catpvf_nocontext|NN SV *const sv|NN const char *const pat|... +Afnp |void |sv_setpvf_nocontext|NN SV *const sv|NN const char *const pat|... +Afnp |void |sv_catpvf_mg_nocontext|NN SV *const sv|NN const char *const pat|... +Afnp |void |sv_setpvf_mg_nocontext|NN SV *const sv|NN const char *const pat|... Afnp |int |fprintf_nocontext|NN PerlIO *stream|NN const char *format|... Afnp |int |printf_nocontext|NN const char *format|... #endif @@ -908,10 +908,10 @@ 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 -Afpd |void |sv_setpvf |NN SV* sv|NN const char* pat|... -Apd |void |sv_vsetpvf |NN SV* sv|NN const char* pat|NULLOK va_list* args +Afpd |void |sv_setpvf |NN SV *const sv|NN const char *const pat|... +Apd |void |sv_vsetpvf |NN SV *const sv|NN const char *const pat|NULLOK va_list *const args Apd |void |sv_setiv |NN SV *const sv|const IV num -Apdb |void |sv_setpviv |NN SV* sv|IV num +Apdb |void |sv_setpviv |NN SV *const sv|const 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 *const rv|NULLOK const char *const classname|const IV iv @@ -925,11 +925,11 @@ 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 Amdb |void |sv_taint |NN SV* sv -ApdR |bool |sv_tainted |NN SV* sv +ApdR |bool |sv_tainted |NN SV *const sv Apd |int |sv_unmagic |NN SV *const sv|const int type Apdmb |void |sv_unref |NN SV* sv -Apd |void |sv_unref_flags |NN SV *ref|U32 flags -Apd |void |sv_untaint |NN SV* sv +Apd |void |sv_unref_flags |NN SV *const ref|const U32 flags +Apd |void |sv_untaint |NN SV *const sv Apd |void |sv_upgrade |NN SV *const sv|svtype new_type Apdmb |void |sv_usepvn |NN SV* sv|NULLOK char* ptr|STRLEN len Apd |void |sv_usepvn_flags|NN SV *const sv|NULLOK char* ptr|const STRLEN len\ @@ -1037,10 +1037,11 @@ Apd |void |sv_vcatpvf_mg |NN SV* sv|NN const char* pat|NULLOK va_list* args Apd |void |sv_catpv_mg |NN SV *const sv|NULLOK const char *const ptr Apdbm |void |sv_catpvn_mg |NN SV *sv|NN const char *ptr|STRLEN len Apdbm |void |sv_catsv_mg |NN SV *dsv|NULLOK SV *ssv -Afpd |void |sv_setpvf_mg |NN SV *sv|NN const char* pat|... -Apd |void |sv_vsetpvf_mg |NN SV* sv|NN const char* pat|NULLOK va_list* args +Afpd |void |sv_setpvf_mg |NN SV *const sv|NN const char *const pat|... +Apd |void |sv_vsetpvf_mg |NN SV *const sv|NN const char *const pat \ + |NULLOK va_list *const args Apd |void |sv_setiv_mg |NN SV *const sv|const IV i -Apdb |void |sv_setpviv_mg |NN SV *sv|IV iv +Apdb |void |sv_setpviv_mg |NN SV *const sv|const IV iv Apd |void |sv_setuv_mg |NN SV *const sv|const UV u Apd |void |sv_setnv_mg |NN SV *const sv|const NV num Apd |void |sv_setpv_mg |NN SV *const sv|NULLOK const char *const ptr @@ -1541,7 +1542,7 @@ poM |int |sv_kill_backrefs |NN SV *const sv|NN AV *const av #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) 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 |sv_unglob |NN SV *const sv s |void |not_a_number |NN SV *const sv s |I32 |visit |NN SVFUNC_t f|const U32 flags|const U32 mask s |void |sv_del_backref |NN SV *const tsv|NN SV *const sv diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 26420de..309a00d 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -6066,7 +6066,7 @@ X Works like C but copies the text into the SV instead of appending it. Does not handle 'set' magic. See C. - void sv_setpvf(SV* sv, const char* pat, ...) + void sv_setpvf(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c @@ -6076,7 +6076,7 @@ X Like C, but also handles 'set' magic. - void sv_setpvf_mg(SV *sv, const char* pat, ...) + void sv_setpvf_mg(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c @@ -6087,7 +6087,7 @@ X Copies an integer into the given SV, also updating its string value. Does not handle 'set' magic. See C. - void sv_setpviv(SV* sv, IV num) + void sv_setpviv(SV *const sv, const IV num) =for hackers Found in file sv.c @@ -6097,7 +6097,7 @@ X Like C, but also handles 'set' magic. - void sv_setpviv_mg(SV *sv, IV iv) + void sv_setpviv_mg(SV *const sv, const IV iv) =for hackers Found in file sv.c @@ -6301,7 +6301,7 @@ Found in file sv.c X Test an SV for taintedness. Use C instead. - bool sv_tainted(SV* sv) + bool sv_tainted(SV *const sv) =for hackers Found in file sv.c @@ -6339,7 +6339,7 @@ C to force the reference count to be decremented different from one or the reference being a readonly SV). See C. - void sv_unref_flags(SV *ref, U32 flags) + void sv_unref_flags(SV *const ref, const U32 flags) =for hackers Found in file sv.c @@ -6348,7 +6348,7 @@ Found in file sv.c X Untaint an SV. Use C instead. - void sv_untaint(SV* sv) + void sv_untaint(SV *const sv) =for hackers Found in file sv.c @@ -6517,7 +6517,7 @@ appending it. Does not handle 'set' magic. See C. Usually used via its frontend C. - void sv_vsetpvf(SV* sv, const char* pat, va_list* args) + void sv_vsetpvf(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c @@ -6542,7 +6542,7 @@ Like C, but also handles 'set' magic. Usually used via its frontend C. - void sv_vsetpvf_mg(SV* sv, const char* pat, va_list* args) + void sv_vsetpvf_mg(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index 7d80e39..bd515f4 100644 --- a/proto.h +++ b/proto.h @@ -379,28 +379,28 @@ PERL_CALLCONV SV* Perl_newSVpvf_nocontext(const char *const pat, ...) #define PERL_ARGS_ASSERT_NEWSVPVF_NOCONTEXT \ assert(pat) -PERL_CALLCONV void Perl_sv_catpvf_nocontext(SV* sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_catpvf_nocontext(SV *const sv, const char *const pat, ...) __attribute__format__(__printf__,2,3) __attribute__nonnull__(1) __attribute__nonnull__(2); #define PERL_ARGS_ASSERT_SV_CATPVF_NOCONTEXT \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_setpvf_nocontext(SV* sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_setpvf_nocontext(SV *const sv, const char *const pat, ...) __attribute__format__(__printf__,2,3) __attribute__nonnull__(1) __attribute__nonnull__(2); #define PERL_ARGS_ASSERT_SV_SETPVF_NOCONTEXT \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_catpvf_mg_nocontext(SV* sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_catpvf_mg_nocontext(SV *const sv, const char *const pat, ...) __attribute__format__(__printf__,2,3) __attribute__nonnull__(1) __attribute__nonnull__(2); #define PERL_ARGS_ASSERT_SV_CATPVF_MG_NOCONTEXT \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_setpvf_mg_nocontext(SV* sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_setpvf_mg_nocontext(SV *const sv, const char *const pat, ...) __attribute__format__(__printf__,2,3) __attribute__nonnull__(1) __attribute__nonnull__(2); @@ -3270,14 +3270,14 @@ PERL_CALLCONV void Perl_sv_reset(pTHX_ const char* s, HV *const stash) #define PERL_ARGS_ASSERT_SV_RESET \ assert(s) -PERL_CALLCONV void Perl_sv_setpvf(pTHX_ SV* sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_setpvf(pTHX_ SV *const sv, const char *const pat, ...) __attribute__format__(__printf__,pTHX_2,pTHX_3) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_SETPVF \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_vsetpvf(pTHX_ SV* sv, const char* pat, va_list* args) +PERL_CALLCONV void Perl_sv_vsetpvf(pTHX_ SV *const sv, const char *const pat, va_list *const args) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_VSETPVF \ @@ -3288,7 +3288,7 @@ PERL_CALLCONV void Perl_sv_setiv(pTHX_ SV *const sv, const IV num) #define PERL_ARGS_ASSERT_SV_SETIV \ assert(sv) -PERL_CALLCONV void Perl_sv_setpviv(pTHX_ SV* sv, IV num) +PERL_CALLCONV void Perl_sv_setpviv(pTHX_ SV *const sv, const IV num) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETPVIV \ assert(sv) @@ -3349,7 +3349,7 @@ PERL_CALLCONV void Perl_sv_setpvn(pTHX_ SV *const sv, const char *const ptr, con #define PERL_ARGS_ASSERT_SV_TAINT \ assert(sv) -PERL_CALLCONV bool Perl_sv_tainted(pTHX_ SV* sv) +PERL_CALLCONV bool Perl_sv_tainted(pTHX_ SV *const sv) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_TAINTED \ @@ -3365,12 +3365,12 @@ PERL_CALLCONV int Perl_sv_unmagic(pTHX_ SV *const sv, const int type) #define PERL_ARGS_ASSERT_SV_UNREF \ assert(sv) -PERL_CALLCONV void Perl_sv_unref_flags(pTHX_ SV *ref, U32 flags) +PERL_CALLCONV void Perl_sv_unref_flags(pTHX_ SV *const ref, const U32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UNREF_FLAGS \ assert(ref) -PERL_CALLCONV void Perl_sv_untaint(pTHX_ SV* sv) +PERL_CALLCONV void Perl_sv_untaint(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UNTAINT \ assert(sv) @@ -3771,14 +3771,14 @@ PERL_CALLCONV void Perl_sv_catpv_mg(pTHX_ SV *const sv, const char *const ptr) #define PERL_ARGS_ASSERT_SV_CATSV_MG \ assert(dsv) -PERL_CALLCONV void Perl_sv_setpvf_mg(pTHX_ SV *sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_setpvf_mg(pTHX_ SV *const sv, const char *const pat, ...) __attribute__format__(__printf__,pTHX_2,pTHX_3) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_SETPVF_MG \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_vsetpvf_mg(pTHX_ SV* sv, const char* pat, va_list* args) +PERL_CALLCONV void Perl_sv_vsetpvf_mg(pTHX_ SV *const sv, const char *const pat, va_list *const args) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_VSETPVF_MG \ @@ -3789,7 +3789,7 @@ PERL_CALLCONV void Perl_sv_setiv_mg(pTHX_ SV *const sv, const IV i) #define PERL_ARGS_ASSERT_SV_SETIV_MG \ assert(sv) -PERL_CALLCONV void Perl_sv_setpviv_mg(pTHX_ SV *sv, IV iv) +PERL_CALLCONV void Perl_sv_setpviv_mg(pTHX_ SV *const sv, const IV iv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETPVIV_MG \ assert(sv) @@ -5495,7 +5495,7 @@ STATIC char * S_uiv_2buf(char *const buf, const IV iv, UV uv, const int is_uv, c #define PERL_ARGS_ASSERT_UIV_2BUF \ assert(buf); assert(peob) -STATIC void S_sv_unglob(pTHX_ SV* sv) +STATIC void S_sv_unglob(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UNGLOB \ assert(sv) diff --git a/sv.c b/sv.c index 341463b..8c13a90 100644 --- a/sv.c +++ b/sv.c @@ -8398,7 +8398,7 @@ Perl_sv_bless(pTHX_ SV *const sv, HV *const stash) */ STATIC void -S_sv_unglob(pTHX_ SV *sv) +S_sv_unglob(pTHX_ SV *const sv) { dVAR; void *xpvmg; @@ -8455,7 +8455,7 @@ See C. */ void -Perl_sv_unref_flags(pTHX_ SV *ref, U32 flags) +Perl_sv_unref_flags(pTHX_ SV *const ref, const U32 flags) { SV* const target = SvRV(ref); @@ -8485,7 +8485,7 @@ Untaint an SV. Use C instead. */ void -Perl_sv_untaint(pTHX_ SV *sv) +Perl_sv_untaint(pTHX_ SV *const sv) { PERL_ARGS_ASSERT_SV_UNTAINT; @@ -8504,7 +8504,7 @@ Test an SV for taintedness. Use C instead. */ bool -Perl_sv_tainted(pTHX_ SV *sv) +Perl_sv_tainted(pTHX_ SV *const sv) { PERL_ARGS_ASSERT_SV_TAINTED; @@ -8526,7 +8526,7 @@ Does not handle 'set' magic. See C. */ void -Perl_sv_setpviv(pTHX_ SV *sv, IV iv) +Perl_sv_setpviv(pTHX_ SV *const sv, const IV iv) { char buf[TYPE_CHARS(UV)]; char *ebuf; @@ -8546,7 +8546,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setpviv_mg(pTHX_ SV *sv, IV iv) +Perl_sv_setpviv_mg(pTHX_ SV *const sv, const IV iv) { PERL_ARGS_ASSERT_SV_SETPVIV_MG; @@ -8562,7 +8562,7 @@ Perl_sv_setpviv_mg(pTHX_ SV *sv, IV iv) */ void -Perl_sv_setpvf_nocontext(SV *sv, const char* pat, ...) +Perl_sv_setpvf_nocontext(SV *const sv, const char *const pat, ...) { dTHX; va_list args; @@ -8580,7 +8580,7 @@ Perl_sv_setpvf_nocontext(SV *sv, const char* pat, ...) */ void -Perl_sv_setpvf_mg_nocontext(SV *sv, const char* pat, ...) +Perl_sv_setpvf_mg_nocontext(SV *const sv, const char *const pat, ...) { dTHX; va_list args; @@ -8603,7 +8603,7 @@ appending it. Does not handle 'set' magic. See C. */ void -Perl_sv_setpvf(pTHX_ SV *sv, const char* pat, ...) +Perl_sv_setpvf(pTHX_ SV *const sv, const char *const pat, ...) { va_list args; @@ -8626,7 +8626,7 @@ Usually used via its frontend C. */ void -Perl_sv_vsetpvf(pTHX_ SV *sv, const char* pat, va_list* args) +Perl_sv_vsetpvf(pTHX_ SV *const sv, const char *const pat, va_list *const args) { PERL_ARGS_ASSERT_SV_VSETPVF; @@ -8642,7 +8642,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setpvf_mg(pTHX_ SV *sv, const char* pat, ...) +Perl_sv_setpvf_mg(pTHX_ SV *const sv, const char *const pat, ...) { va_list args; @@ -8664,7 +8664,7 @@ Usually used via its frontend C. */ void -Perl_sv_vsetpvf_mg(pTHX_ SV *sv, const char* pat, va_list* args) +Perl_sv_vsetpvf_mg(pTHX_ SV *const sv, const char *const pat, va_list *const args) { PERL_ARGS_ASSERT_SV_VSETPVF_MG; @@ -8680,7 +8680,7 @@ Perl_sv_vsetpvf_mg(pTHX_ SV *sv, const char* pat, va_list* args) */ void -Perl_sv_catpvf_nocontext(SV *sv, const char* pat, ...) +Perl_sv_catpvf_nocontext(SV *const sv, const char *const pat, ...) { dTHX; va_list args; @@ -8698,7 +8698,7 @@ Perl_sv_catpvf_nocontext(SV *sv, const char* pat, ...) */ void -Perl_sv_catpvf_mg_nocontext(SV *sv, const char* pat, ...) +Perl_sv_catpvf_mg_nocontext(SV *const sv, const char *const pat, ...) { dTHX; va_list args;