From: Steven Schubiger Date: Wed, 12 Mar 2008 12:38:46 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=66ceb5325074bc0232dc5b60ccb414245562ce2b;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080312113846.GB31102@refcnt.homeunix.org> p4raw-id: //depot/perl@33507 --- diff --git a/embed.fnc b/embed.fnc index ff29a11..1a2e827 100644 --- a/embed.fnc +++ b/embed.fnc @@ -853,8 +853,9 @@ 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 *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 +Afpd |void |sv_catpvf |NN SV *const sv|NN const char *const pat|... +Apd |void |sv_vcatpvf |NN SV *const sv|NN const char *const pat \ + |NULLOK va_list *const args Apd |void |sv_catpv |NN SV *const sv|NULLOK const char* ptr Amdb |void |sv_catpvn |NN SV *dsv|NN const char *sstr|STRLEN len Amdb |void |sv_catsv |NN SV *dstr|NULLOK SV *sstr @@ -934,12 +935,12 @@ 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\ |const U32 flags -Apd |void |sv_vcatpvfn |NN SV* sv|NN const char* pat|STRLEN patlen \ - |NULLOK va_list* args|NULLOK SV** svargs|I32 svmax \ - |NULLOK bool *maybe_tainted -Apd |void |sv_vsetpvfn |NN SV* sv|NN const char* pat|STRLEN patlen \ - |NULLOK va_list* args|NULLOK SV** svargs|I32 svmax \ - |NULLOK bool *maybe_tainted +Apd |void |sv_vcatpvfn |NN SV *const sv|NN const char *const pat|const STRLEN patlen \ + |NULLOK va_list *const args|NULLOK SV **const svargs|const I32 svmax \ + |NULLOK bool *const maybe_tainted +Apd |void |sv_vsetpvfn |NN SV *const sv|NN const char *const pat|const STRLEN patlen \ + |NULLOK va_list *const args|NULLOK SV **const svargs \ + |const I32 svmax|NULLOK bool *const maybe_tainted ApR |NV |str_to_version |NN SV *sv Ap |SV* |swash_init |NN const char* pkg|NN const char* name|NN SV* listsv|I32 minbits|I32 none Ap |UV |swash_fetch |NN SV *swash|NN const U8 *ptr|bool do_utf8 @@ -1032,8 +1033,9 @@ Ap |void |free_global_struct|NN struct perl_vars *plvarsp #endif Ap |int |runops_standard Ap |int |runops_debug -Afpd |void |sv_catpvf_mg |NN SV *sv|NN const char* pat|... -Apd |void |sv_vcatpvf_mg |NN SV* sv|NN const char* pat|NULLOK va_list* args +Afpd |void |sv_catpvf_mg |NN SV *const sv|NN const char *const pat|... +Apd |void |sv_vcatpvf_mg |NN SV *const sv|NN const char *const pat \ + |NULLOK va_list *const 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 @@ -1111,13 +1113,13 @@ ApR |HE* |he_dup |NULLOK const HE* e|bool shared|NN CLONE_PARAMS* param ApR |HEK* |hek_dup |NULLOK HEK* e|NN CLONE_PARAMS* param Ap |void |re_dup_guts |NN const REGEXP *sstr|NN REGEXP *dstr \ |NN CLONE_PARAMS* param -Ap |PerlIO*|fp_dup |NULLOK PerlIO* fp|char type|NN CLONE_PARAMS* param -ApR |DIR* |dirp_dup |NULLOK DIR* dp -ApR |GP* |gp_dup |NULLOK GP* gp|NN CLONE_PARAMS* param -ApR |MAGIC* |mg_dup |NULLOK MAGIC* mg|NN CLONE_PARAMS* param +Ap |PerlIO*|fp_dup |NULLOK PerlIO *const fp|const char type|NN CLONE_PARAMS *const param +ApR |DIR* |dirp_dup |NULLOK DIR *const dp +ApR |GP* |gp_dup |NULLOK GP *const gp|NN CLONE_PARAMS *const param +ApR |MAGIC* |mg_dup |NULLOK MAGIC *const mg|NN CLONE_PARAMS *const param ApR |SV* |sv_dup |NULLOK const SV* sstr|NN CLONE_PARAMS* param Ap |void |rvpv_dup |NN SV* dstr|NN const SV *sstr|NN CLONE_PARAMS* param -Ap |yy_parser*|parser_dup |NULLOK const yy_parser *proto|NN CLONE_PARAMS* param +Ap |yy_parser*|parser_dup |NULLOK const yy_parser *const proto|NN CLONE_PARAMS *const param #endif Apa |PTR_TBL_t*|ptr_table_new ApR |void* |ptr_table_fetch|NN PTR_TBL_t *tbl|NULLOK const void *sv @@ -1558,7 +1560,7 @@ s |int |sv_2iuv_non_preserve |NN SV *const sv|I32 numtype s |int |sv_2iuv_non_preserve |NN SV *const sv # endif # endif -sR |I32 |expect_number |NN char** pattern +sR |I32 |expect_number |NN char **const pattern # sn |STRLEN |sv_pos_u2b_forwards|NN const U8 *const start \ |NN const U8 *const send|STRLEN uoffset @@ -1571,7 +1573,7 @@ s |void |utf8_mg_pos_cache_update|NN SV *const sv|NN MAGIC **const mgp \ |const STRLEN byte|const STRLEN utf8|const STRLEN blen s |STRLEN |sv_pos_b2u_midway|NN const U8 *const s|NN const U8 *const target \ |NN const U8 *end|STRLEN endu -sn |char * |F0convert |NV nv|NN char *endbuf|NN STRLEN *len +sn |char * |F0convert |NV nv|NN char *const endbuf|NN STRLEN *const len # if defined(PERL_OLD_COPY_ON_WRITE) sM |void |sv_release_COW |NN SV *sv|NN const char *pvx|NN SV *after # endif diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 309a00d..b3a23bc 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5488,7 +5488,7 @@ upgraded to UTF-8. Handles 'get' magic, but not 'set' magic. See C. If the original SV was UTF-8, the pattern should be valid UTF-8; if the original SV was bytes, the pattern should be too. - void sv_catpvf(SV* sv, const char* pat, ...) + void sv_catpvf(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c @@ -5498,7 +5498,7 @@ X Like C, but also handles 'set' magic. - void sv_catpvf_mg(SV *sv, const char* pat, ...) + void sv_catpvf_mg(SV *const sv, const char *const pat, ...) =for hackers Found in file sv.c @@ -6476,7 +6476,7 @@ to an SV. Does not handle 'set' magic. See C. Usually used via its frontend C. - void sv_vcatpvf(SV* sv, const char* pat, va_list* args) + void sv_vcatpvf(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c @@ -6492,7 +6492,7 @@ locales). Usually used via one of its frontends C and C. - void sv_vcatpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted) + void sv_vcatpvfn(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) =for hackers Found in file sv.c @@ -6504,7 +6504,7 @@ Like C, but also handles 'set' magic. Usually used via its frontend C. - void sv_vcatpvf_mg(SV* sv, const char* pat, va_list* args) + void sv_vcatpvf_mg(SV *const sv, const char *const pat, va_list *const args) =for hackers Found in file sv.c @@ -6530,7 +6530,7 @@ appending it. Usually used via one of its frontends C and C. - void sv_vsetpvfn(SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted) + void sv_vsetpvfn(SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index bd515f4..928f34b 100644 --- a/proto.h +++ b/proto.h @@ -3075,14 +3075,14 @@ PERL_CALLCONV SV* Perl_sv_bless(pTHX_ SV *const sv, HV *const stash) #define PERL_ARGS_ASSERT_SV_BLESS \ assert(sv); assert(stash) -PERL_CALLCONV void Perl_sv_catpvf(pTHX_ SV* sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_catpvf(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_CATPVF \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_vcatpvf(pTHX_ SV* sv, const char* pat, va_list* args) +PERL_CALLCONV void Perl_sv_vcatpvf(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_VCATPVF \ @@ -3390,13 +3390,13 @@ PERL_CALLCONV void Perl_sv_usepvn_flags(pTHX_ SV *const sv, char* ptr, const STR #define PERL_ARGS_ASSERT_SV_USEPVN_FLAGS \ assert(sv) -PERL_CALLCONV void Perl_sv_vcatpvfn(pTHX_ SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted) +PERL_CALLCONV void Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_VCATPVFN \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_vsetpvfn(pTHX_ SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted) +PERL_CALLCONV void Perl_sv_vsetpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_VSETPVFN \ @@ -3742,14 +3742,14 @@ PERL_CALLCONV void Perl_free_global_struct(pTHX_ struct perl_vars *plvarsp) #endif PERL_CALLCONV int Perl_runops_standard(pTHX); PERL_CALLCONV int Perl_runops_debug(pTHX); -PERL_CALLCONV void Perl_sv_catpvf_mg(pTHX_ SV *sv, const char* pat, ...) +PERL_CALLCONV void Perl_sv_catpvf_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_CATPVF_MG \ assert(sv); assert(pat) -PERL_CALLCONV void Perl_sv_vcatpvf_mg(pTHX_ SV* sv, const char* pat, va_list* args) +PERL_CALLCONV void Perl_sv_vcatpvf_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_VCATPVF_MG \ @@ -4041,21 +4041,21 @@ PERL_CALLCONV void Perl_re_dup_guts(pTHX_ const REGEXP *sstr, REGEXP *dstr, CLON #define PERL_ARGS_ASSERT_RE_DUP_GUTS \ assert(sstr); assert(dstr); assert(param) -PERL_CALLCONV PerlIO* Perl_fp_dup(pTHX_ PerlIO* fp, char type, CLONE_PARAMS* param) +PERL_CALLCONV PerlIO* Perl_fp_dup(pTHX_ PerlIO *const fp, const char type, CLONE_PARAMS *const param) __attribute__nonnull__(pTHX_3); #define PERL_ARGS_ASSERT_FP_DUP \ assert(param) -PERL_CALLCONV DIR* Perl_dirp_dup(pTHX_ DIR* dp) +PERL_CALLCONV DIR* Perl_dirp_dup(pTHX_ DIR *const dp) __attribute__warn_unused_result__; -PERL_CALLCONV GP* Perl_gp_dup(pTHX_ GP* gp, CLONE_PARAMS* param) +PERL_CALLCONV GP* Perl_gp_dup(pTHX_ GP *const gp, CLONE_PARAMS *const param) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_GP_DUP \ assert(param) -PERL_CALLCONV MAGIC* Perl_mg_dup(pTHX_ MAGIC* mg, CLONE_PARAMS* param) +PERL_CALLCONV MAGIC* Perl_mg_dup(pTHX_ MAGIC *const mg, CLONE_PARAMS *const param) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_MG_DUP \ @@ -4074,7 +4074,7 @@ PERL_CALLCONV void Perl_rvpv_dup(pTHX_ SV* dstr, const SV *sstr, CLONE_PARAMS* p #define PERL_ARGS_ASSERT_RVPV_DUP \ assert(dstr); assert(sstr); assert(param) -PERL_CALLCONV yy_parser* Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param) +PERL_CALLCONV yy_parser* Perl_parser_dup(pTHX_ const yy_parser *const proto, CLONE_PARAMS *const param) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_PARSER_DUP \ assert(param) @@ -5541,7 +5541,7 @@ STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *const sv) # endif # endif -STATIC I32 S_expect_number(pTHX_ char** pattern) +STATIC I32 S_expect_number(pTHX_ char **const pattern) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_EXPECT_NUMBER \ @@ -5581,7 +5581,7 @@ STATIC STRLEN S_sv_pos_b2u_midway(pTHX_ const U8 *const s, const U8 *const targe #define PERL_ARGS_ASSERT_SV_POS_B2U_MIDWAY \ assert(s); assert(target); assert(end) -STATIC char * S_F0convert(NV nv, char *endbuf, STRLEN *len) +STATIC char * S_F0convert(NV nv, char *const endbuf, STRLEN *const len) __attribute__nonnull__(2) __attribute__nonnull__(3); #define PERL_ARGS_ASSERT_F0CONVERT \ diff --git a/sv.c b/sv.c index 8c13a90..d3fed89 100644 --- a/sv.c +++ b/sv.c @@ -8725,7 +8725,7 @@ valid UTF-8; if the original SV was bytes, the pattern should be too. =cut */ void -Perl_sv_catpvf(pTHX_ SV *sv, const char* pat, ...) +Perl_sv_catpvf(pTHX_ SV *const sv, const char *const pat, ...) { va_list args; @@ -8748,7 +8748,7 @@ Usually used via its frontend C. */ void -Perl_sv_vcatpvf(pTHX_ SV *sv, const char* pat, va_list* args) +Perl_sv_vcatpvf(pTHX_ SV *const sv, const char *const pat, va_list *const args) { PERL_ARGS_ASSERT_SV_VCATPVF; @@ -8764,7 +8764,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_catpvf_mg(pTHX_ SV *sv, const char* pat, ...) +Perl_sv_catpvf_mg(pTHX_ SV *const sv, const char *const pat, ...) { va_list args; @@ -8786,7 +8786,7 @@ Usually used via its frontend C. */ void -Perl_sv_vcatpvf_mg(pTHX_ SV *sv, const char* pat, va_list* args) +Perl_sv_vcatpvf_mg(pTHX_ SV *const sv, const char *const pat, va_list *const args) { PERL_ARGS_ASSERT_SV_VCATPVF_MG; @@ -8806,7 +8806,8 @@ Usually used via one of its frontends C and C. */ void -Perl_sv_vsetpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV **svargs, I32 svmax, bool *maybe_tainted) +Perl_sv_vsetpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, + va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) { PERL_ARGS_ASSERT_SV_VSETPVFN; @@ -8815,7 +8816,7 @@ Perl_sv_vsetpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV } STATIC I32 -S_expect_number(pTHX_ char** pattern) +S_expect_number(pTHX_ char **const pattern) { dVAR; I32 var = 0; @@ -8838,7 +8839,7 @@ S_expect_number(pTHX_ char** pattern) } STATIC char * -S_F0convert(NV nv, char *endbuf, STRLEN *len) +S_F0convert(NV nv, char *const endbuf, STRLEN *const len) { const int neg = nv < 0; UV uv; @@ -8888,7 +8889,8 @@ Usually used via one of its frontends C and C. /* XXX maybe_tainted is never assigned to, so the doc above is lying. */ void -Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV **svargs, I32 svmax, bool *maybe_tainted) +Perl_sv_vcatpvfn(pTHX_ SV *const sv, const char *const pat, const STRLEN patlen, + va_list *const args, SV **const svargs, const I32 svmax, bool *const maybe_tainted) { dVAR; char *p; @@ -9997,7 +9999,7 @@ ptr_table_* functions. /* clone a parser */ yy_parser * -Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param) +Perl_parser_dup(pTHX_ const yy_parser *const proto, CLONE_PARAMS *const param) { yy_parser *parser; @@ -10140,7 +10142,7 @@ Perl_fp_dup(pTHX_ PerlIO *fp, char type, CLONE_PARAMS *param) /* duplicate a directory handle */ DIR * -Perl_dirp_dup(pTHX_ DIR *dp) +Perl_dirp_dup(pTHX_ DIR *const dp) { PERL_UNUSED_CONTEXT; if (!dp) @@ -10152,7 +10154,7 @@ Perl_dirp_dup(pTHX_ DIR *dp) /* duplicate a typeglob */ GP * -Perl_gp_dup(pTHX_ GP *gp, CLONE_PARAMS* param) +Perl_gp_dup(pTHX_ GP *const gp, CLONE_PARAMS *const param) { GP *ret; @@ -10187,7 +10189,7 @@ Perl_gp_dup(pTHX_ GP *gp, CLONE_PARAMS* param) /* duplicate a chain of magic */ MAGIC * -Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS* param) +Perl_mg_dup(pTHX_ MAGIC *const mg, CLONE_PARAMS *const param) { MAGIC *mgprev = (MAGIC*)NULL; MAGIC *mgret;