From: Steven Schubiger Date: Fri, 29 Feb 2008 21:29:39 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2e000ff2937b88268058c207fe83724808b808a8;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080229202939.GA16742@refcnt.homeunix.org> Date: Fri, 29 Feb 2008 21:29:39 +0100 p4raw-id: //depot/perl@33403 --- diff --git a/embed.fnc b/embed.fnc index 70392b8..fa71e38 100644 --- a/embed.fnc +++ b/embed.fnc @@ -857,7 +857,7 @@ Apd |void |sv_vcatpvf |NN SV* sv|NN const char* pat|NULLOK va_list* args Apd |void |sv_catpv |NN SV* 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 -Apd |void |sv_chop |NN SV* sv|NULLOK const char* ptr +Apd |void |sv_chop |NN SV *const sv|NULLOK const char *const ptr pd |I32 |sv_clean_all pd |void |sv_clean_objs Apd |void |sv_clear |NN SV* sv @@ -917,8 +917,8 @@ 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 |void |sv_setpv |NN SV* sv|NULLOK const char* ptr -Apd |void |sv_setpvn |NN SV* sv|NULLOK const char* ptr|STRLEN len +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 @@ -928,8 +928,8 @@ Apd |void |sv_unref_flags |NN SV *ref|U32 flags Apd |void |sv_untaint |NN SV* 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* sv|NULLOK char* ptr|STRLEN len\ - |U32 flags +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 @@ -1039,8 +1039,8 @@ Apd |void |sv_setiv_mg |NN SV *const sv|const IV i Apdb |void |sv_setpviv_mg |NN SV *sv|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 *sv|NULLOK const char *ptr -Apd |void |sv_setpvn_mg |NN SV *sv|NN const char *ptr|STRLEN len +Apd |void |sv_setpv_mg |NN SV *const sv|NULLOK const char *const ptr +Apd |void |sv_setpvn_mg |NN SV *const sv|NN const char *const ptr|const STRLEN len Apd |void |sv_setsv_mg |NN SV *const dstr|NULLOK SV *const sstr Apdbm |void |sv_usepvn_mg |NN SV *sv|NULLOK char *ptr|STRLEN len ApR |MGVTBL*|get_vtbl |int vtbl_id @@ -1083,7 +1083,7 @@ ApdM |bool |sv_utf8_downgrade|NN SV *const sv|const bool fail_ok Apd |void |sv_utf8_encode |NN SV *const sv ApdM |bool |sv_utf8_decode |NN SV *const sv Apdmb |void |sv_force_normal|NN SV *sv -Apd |void |sv_force_normal_flags|NN SV *sv|U32 flags +Apd |void |sv_force_normal_flags|NN SV *const sv|const U32 flags Ap |void |tmps_grow |I32 n Apd |SV* |sv_rvweaken |NN SV *sv p |int |magic_killbackrefs|NN SV *sv|NN MAGIC *mg @@ -1667,9 +1667,9 @@ sR |SV* |swash_get |NN SV* swash|UV start|UV span START_EXTERN_C Apd |void |sv_setsv_flags |NN SV *dstr|NULLOK SV *sstr|const I32 flags -Apd |void |sv_catpvn_flags|NN SV *dstr|NN const char *sstr|STRLEN len \ - |I32 flags -Apd |void |sv_catsv_flags |NN SV* dsv|NULLOK SV* ssv|I32 flags +Apd |void |sv_catpvn_flags|NN SV *const dstr|NN const char *sstr|const STRLEN len \ + |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 |void |sv_copypv |NN SV *const dsv|NN SV *const ssv diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 191af89..3c68111 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5526,7 +5526,7 @@ If C has C bit set, will C on C if appropriate, else not. C and C are implemented in terms of this function. - void sv_catpvn_flags(SV *dstr, const char *sstr, STRLEN len, I32 flags) + void sv_catpvn_flags(SV *const dstr, const char *sstr, const STRLEN len, const I32 flags) =for hackers Found in file sv.c @@ -5571,7 +5571,7 @@ SV C. Modifies C but not C. If C has C bit set, will C on the SVs if appropriate, else not. C and C are implemented in terms of this function. - void sv_catsv_flags(SV* dsv, SV* ssv, I32 flags) + void sv_catsv_flags(SV *const dsv, SV *const ssv, const I32 flags) =for hackers Found in file sv.c @@ -5586,7 +5586,7 @@ string. Uses the "OOK hack". Beware: after this function returns, C and SvPVX_const(sv) may no longer refer to the same chunk of data. - void sv_chop(SV* sv, const char* ptr) + void sv_chop(SV *const sv, const char *const ptr) =for hackers Found in file sv.c @@ -5699,7 +5699,7 @@ set to some other value.) In addition, the C parameter gets passed to C when unrefing. C calls this function with flags set to 0. - void sv_force_normal_flags(SV *sv, U32 flags) + void sv_force_normal_flags(SV *const sv, const U32 flags) =for hackers Found in file sv.c @@ -6055,7 +6055,7 @@ X Copies a string into an SV. The string must be null-terminated. Does not handle 'set' magic. See C. - void sv_setpv(SV* sv, const char* ptr) + void sv_setpv(SV *const sv, const char *const ptr) =for hackers Found in file sv.c @@ -6109,7 +6109,7 @@ Copies a string into an SV. The C parameter indicates the number of bytes to be copied. If the C argument is NULL the SV will become undefined. Does not handle 'set' magic. See C. - void sv_setpvn(SV* sv, const char* ptr, STRLEN len) + void sv_setpvn(SV *const sv, const char *const ptr, const STRLEN len) =for hackers Found in file sv.c @@ -6119,7 +6119,7 @@ X Like C, but also handles 'set' magic. - void sv_setpvn_mg(SV *sv, const char *ptr, STRLEN len) + void sv_setpvn_mg(SV *const sv, const char *const ptr, const STRLEN len) =for hackers Found in file sv.c @@ -6139,7 +6139,7 @@ X Like C, but also handles 'set' magic. - void sv_setpv_mg(SV *sv, const char *ptr) + void sv_setpv_mg(SV *const sv, const char *const ptr) =for hackers Found in file sv.c @@ -6382,7 +6382,7 @@ SV_HAS_TRAILING_NUL is true, then C must be NUL, and the realloc will be skipped. (i.e. the buffer is actually at least 1 byte longer than C, and already meets the requirements for storing in C) - void sv_usepvn_flags(SV* sv, char* ptr, STRLEN len, U32 flags) + void sv_usepvn_flags(SV *const sv, char* ptr, const STRLEN len, const U32 flags) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index 501bcc5..ce47ac9 100644 --- a/proto.h +++ b/proto.h @@ -3107,7 +3107,7 @@ PERL_CALLCONV void Perl_sv_catpv(pTHX_ SV* sv, const char* ptr) #define PERL_ARGS_ASSERT_SV_CATSV \ assert(dstr) -PERL_CALLCONV void Perl_sv_chop(pTHX_ SV* sv, const char* ptr) +PERL_CALLCONV void Perl_sv_chop(pTHX_ SV *const sv, const char *const ptr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_CHOP \ assert(sv) @@ -3332,12 +3332,12 @@ PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV* rv, const char* classname, const #define PERL_ARGS_ASSERT_SV_SETREF_PVN \ assert(rv); assert(pv) -PERL_CALLCONV void Perl_sv_setpv(pTHX_ SV* sv, const char* ptr) +PERL_CALLCONV void Perl_sv_setpv(pTHX_ SV *const sv, const char *const ptr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETPV \ assert(sv) -PERL_CALLCONV void Perl_sv_setpvn(pTHX_ SV* sv, const char* ptr, STRLEN len) +PERL_CALLCONV void Perl_sv_setpvn(pTHX_ SV *const sv, const char *const ptr, const STRLEN len) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETPVN \ assert(sv) @@ -3388,7 +3388,7 @@ PERL_CALLCONV void Perl_sv_upgrade(pTHX_ SV *const sv, svtype new_type) #define PERL_ARGS_ASSERT_SV_USEPVN \ assert(sv) -PERL_CALLCONV void Perl_sv_usepvn_flags(pTHX_ SV* sv, char* ptr, STRLEN len, U32 flags) +PERL_CALLCONV void Perl_sv_usepvn_flags(pTHX_ SV *const sv, char* ptr, const STRLEN len, const U32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_USEPVN_FLAGS \ assert(sv) @@ -3807,12 +3807,12 @@ PERL_CALLCONV void Perl_sv_setnv_mg(pTHX_ SV *const sv, const NV num) #define PERL_ARGS_ASSERT_SV_SETNV_MG \ assert(sv) -PERL_CALLCONV void Perl_sv_setpv_mg(pTHX_ SV *sv, const char *ptr) +PERL_CALLCONV void Perl_sv_setpv_mg(pTHX_ SV *const sv, const char *const ptr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETPV_MG \ assert(sv) -PERL_CALLCONV void Perl_sv_setpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len) +PERL_CALLCONV void Perl_sv_setpvn_mg(pTHX_ SV *const sv, const char *const ptr, const STRLEN len) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_SETPVN_MG \ @@ -3964,7 +3964,7 @@ PERL_CALLCONV bool Perl_sv_utf8_decode(pTHX_ SV *const sv) #define PERL_ARGS_ASSERT_SV_FORCE_NORMAL \ assert(sv) -PERL_CALLCONV void Perl_sv_force_normal_flags(pTHX_ SV *sv, U32 flags) +PERL_CALLCONV void Perl_sv_force_normal_flags(pTHX_ SV *const sv, const U32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_FORCE_NORMAL_FLAGS \ assert(sv) @@ -5889,13 +5889,13 @@ PERL_CALLCONV void Perl_sv_setsv_flags(pTHX_ SV *dstr, SV *sstr, const I32 flags #define PERL_ARGS_ASSERT_SV_SETSV_FLAGS \ assert(dstr) -PERL_CALLCONV void Perl_sv_catpvn_flags(pTHX_ SV *dstr, const char *sstr, STRLEN len, I32 flags) +PERL_CALLCONV void Perl_sv_catpvn_flags(pTHX_ SV *const dstr, const char *sstr, const STRLEN len, const I32 flags) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_CATPVN_FLAGS \ assert(dstr); assert(sstr) -PERL_CALLCONV void Perl_sv_catsv_flags(pTHX_ SV* dsv, SV* ssv, I32 flags) +PERL_CALLCONV void Perl_sv_catsv_flags(pTHX_ SV *const dsv, SV *const ssv, const I32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_CATSV_FLAGS \ assert(dsv) diff --git a/sv.c b/sv.c index 5c3f306..932e9ce 100644 --- a/sv.c +++ b/sv.c @@ -4045,7 +4045,7 @@ undefined. Does not handle 'set' magic. See C. */ void -Perl_sv_setpvn(pTHX_ register SV *sv, register const char *ptr, register STRLEN len) +Perl_sv_setpvn(pTHX_ register SV *const sv, register const char *const ptr, register const STRLEN len) { dVAR; register char *dptr; @@ -4082,7 +4082,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setpvn_mg(pTHX_ register SV *sv, register const char *ptr, register STRLEN len) +Perl_sv_setpvn_mg(pTHX_ register SV *const sv, register const char *const ptr, register const STRLEN len) { PERL_ARGS_ASSERT_SV_SETPVN_MG; @@ -4100,7 +4100,7 @@ handle 'set' magic. See C. */ void -Perl_sv_setpv(pTHX_ register SV *sv, register const char *ptr) +Perl_sv_setpv(pTHX_ register SV *const sv, register const char *const ptr) { dVAR; register STRLEN len; @@ -4131,7 +4131,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setpv_mg(pTHX_ register SV *sv, register const char *ptr) +Perl_sv_setpv_mg(pTHX_ register SV *const sv, register const char *const ptr) { PERL_ARGS_ASSERT_SV_SETPV_MG; @@ -4160,7 +4160,7 @@ C, and already meets the requirements for storing in C) */ void -Perl_sv_usepvn_flags(pTHX_ SV *sv, char *ptr, STRLEN len, U32 flags) +Perl_sv_usepvn_flags(pTHX_ SV *const sv, char *ptr, const STRLEN len, const U32 flags) { dVAR; STRLEN allocate; @@ -4276,7 +4276,7 @@ with flags set to 0. */ void -Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) +Perl_sv_force_normal_flags(pTHX_ register SV *const sv, const U32 flags) { dVAR; @@ -4365,7 +4365,7 @@ refer to the same chunk of data. */ void -Perl_sv_chop(pTHX_ register SV *sv, register const char *ptr) +Perl_sv_chop(pTHX_ register SV *const sv, register const char *const ptr) { STRLEN delta; STRLEN old_delta; @@ -4451,7 +4451,7 @@ in terms of this function. */ void -Perl_sv_catpvn_flags(pTHX_ register SV *dsv, register const char *sstr, register STRLEN slen, I32 flags) +Perl_sv_catpvn_flags(pTHX_ register SV *const dsv, register const char *sstr, register const STRLEN slen, const I32 flags) { dVAR; STRLEN dlen; @@ -4488,7 +4488,7 @@ and C are implemented in terms of this function. =cut */ void -Perl_sv_catsv_flags(pTHX_ SV *dsv, register SV *ssv, I32 flags) +Perl_sv_catsv_flags(pTHX_ SV *const dsv, register SV *const ssv, const I32 flags) { dVAR;