From: Steven Schubiger Date: Fri, 8 Feb 2008 14:13:50 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7bc54ceabb946519c8e8183aeaf67cb19ae981c1;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080208131350.GB22321@refcnt.homeunix.org> Date: Fri, 8 Feb 2008 14:13:50 +0100 p4raw-id: //depot/perl@33400 --- diff --git a/embed.fnc b/embed.fnc index b48af1e..70392b8 100644 --- a/embed.fnc +++ b/embed.fnc @@ -823,7 +823,7 @@ Anp |Signal_t |csighandler |int sig Ap |SV** |stack_grow |NN SV** sp|NN SV** p|int n Ap |I32 |start_subparse |I32 is_format|U32 flags p |void |sub_crush_depth|NN CV* cv -Apd |bool |sv_2bool |NN SV* sv +Apd |bool |sv_2bool |NN SV *const sv Apd |CV* |sv_2cv |NULLOK SV* sv|NN HV** st|NN GV** gvp|I32 lref Apd |IO* |sv_2io |NN SV* sv #ifdef PERL_IN_SV_C @@ -837,7 +837,7 @@ Apd |NV |sv_2nv |NULLOK SV *const sv pMd |SV* |sv_2num |NN SV *const sv Amb |char* |sv_2pv |NULLOK SV *sv|NULLOK STRLEN *lp Apd |char* |sv_2pv_flags |NULLOK SV *const sv|NULLOK STRLEN *const lp|const I32 flags -Apd |char* |sv_2pvutf8 |NN SV* sv|NULLOK STRLEN* lp +Apd |char* |sv_2pvutf8 |NN SV *const sv|NULLOK STRLEN *const 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 |NULLOK SV *sv @@ -1041,7 +1041,7 @@ 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_setsv_mg |NN SV *dstr|NULLOK SV *sstr +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 Apd |char* |pv_display |NN SV *dsv|NN const char *pv|STRLEN cur|STRLEN len \ @@ -1079,9 +1079,9 @@ AmdbR |char* |sv_pv |NN SV *sv AmdbR |char* |sv_pvutf8 |NN SV *sv AmdbR |char* |sv_pvbyte |NN SV *sv Amdb |STRLEN |sv_utf8_upgrade|NN SV *sv -ApdM |bool |sv_utf8_downgrade|NN SV *sv|bool fail_ok -Apd |void |sv_utf8_encode |NN SV *sv -ApdM |bool |sv_utf8_decode |NN SV *sv +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 Ap |void |tmps_grow |I32 n @@ -1573,8 +1573,9 @@ sM |void |sv_release_COW |NN SV *sv|NN const char *pvx|NN SV *after s |SV * |more_sv s |void * |more_bodies |const svtype sv_type 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 +s |void |glob_assign_glob|NN SV *const dstr|NN SV *const sstr \ + |const int dtype +s |void |glob_assign_ref|NN SV *const dstr|NN SV *const sstr sRn |PTR_TBL_ENT_t *|ptr_table_find|NN PTR_TBL_t *tbl|NULLOK const void *sv #endif @@ -1665,11 +1666,11 @@ 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|I32 flags +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 |STRLEN |sv_utf8_upgrade_flags|NN SV *sv|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 Ap |char* |my_atof2 |NN const char *s|NN NV* value diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 18619e5..191af89 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5322,7 +5322,7 @@ X This function is only called on magical items, and is only used by sv_true() or its macro equivalent. - bool sv_2bool(SV* sv) + bool sv_2bool(SV *const sv) =for hackers Found in file sv.c @@ -5411,7 +5411,7 @@ to its length. May cause the SV to be upgraded to UTF-8 as a side-effect. Usually accessed via the C macro. - char* sv_2pvutf8(SV* sv, STRLEN* lp) + char* sv_2pvutf8(SV *const sv, STRLEN *const lp) =for hackers Found in file sv.c @@ -6261,7 +6261,7 @@ C. This is the primary function for copying scalars, and most other copy-ish functions and macros use this underneath. - void sv_setsv_flags(SV *dstr, SV *sstr, I32 flags) + void sv_setsv_flags(SV *dstr, SV *sstr, const I32 flags) =for hackers Found in file sv.c @@ -6271,7 +6271,7 @@ X Like C, but also handles 'set' magic. - void sv_setsv_mg(SV *dstr, SV *sstr) + void sv_setsv_mg(SV *const dstr, SV *const sstr) =for hackers Found in file sv.c @@ -6399,7 +6399,7 @@ Scans PV for validity and returns false if the PV is invalid UTF-8. NOTE: this function is experimental and may change or be removed without notice. - bool sv_utf8_decode(SV *sv) + bool sv_utf8_decode(SV *const sv) =for hackers Found in file sv.c @@ -6418,7 +6418,7 @@ use the Encode extension for that. NOTE: this function is experimental and may change or be removed without notice. - bool sv_utf8_downgrade(SV *sv, bool fail_ok) + bool sv_utf8_downgrade(SV *const sv, const bool fail_ok) =for hackers Found in file sv.c @@ -6429,7 +6429,7 @@ X Converts the PV of an SV to UTF-8, but then turns the C flag off so that it looks like octets again. - void sv_utf8_encode(SV *sv) + void sv_utf8_encode(SV *const sv) =for hackers Found in file sv.c @@ -6463,7 +6463,7 @@ C are implemented in terms of this function. This is not as a general purpose byte encoding to Unicode interface: use the Encode extension for that. - STRLEN sv_utf8_upgrade_flags(SV *sv, I32 flags) + STRLEN sv_utf8_upgrade_flags(SV *const sv, const I32 flags) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index f764d5c..501bcc5 100644 --- a/proto.h +++ b/proto.h @@ -2972,7 +2972,7 @@ PERL_CALLCONV void Perl_sub_crush_depth(pTHX_ CV* cv) #define PERL_ARGS_ASSERT_SUB_CRUSH_DEPTH \ assert(cv) -PERL_CALLCONV bool Perl_sv_2bool(pTHX_ SV* sv) +PERL_CALLCONV bool Perl_sv_2bool(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_2BOOL \ assert(sv) @@ -3011,7 +3011,7 @@ PERL_CALLCONV SV* Perl_sv_2num(pTHX_ SV *const sv) /* PERL_CALLCONV char* Perl_sv_2pv(pTHX_ SV *sv, STRLEN *lp); */ PERL_CALLCONV char* Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags); -PERL_CALLCONV char* Perl_sv_2pvutf8(pTHX_ SV* sv, STRLEN* lp) +PERL_CALLCONV char* Perl_sv_2pvutf8(pTHX_ SV *const sv, STRLEN *const lp) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_2PVUTF8 \ assert(sv) @@ -3818,7 +3818,7 @@ PERL_CALLCONV void Perl_sv_setpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len) #define PERL_ARGS_ASSERT_SV_SETPVN_MG \ assert(sv); assert(ptr) -PERL_CALLCONV void Perl_sv_setsv_mg(pTHX_ SV *dstr, SV *sstr) +PERL_CALLCONV void Perl_sv_setsv_mg(pTHX_ SV *const dstr, SV *const sstr) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETSV_MG \ assert(dstr) @@ -3944,17 +3944,17 @@ PERL_CALLCONV void Perl_reginitcolors(pTHX); #define PERL_ARGS_ASSERT_SV_UTF8_UPGRADE \ assert(sv) -PERL_CALLCONV bool Perl_sv_utf8_downgrade(pTHX_ SV *sv, bool fail_ok) +PERL_CALLCONV bool Perl_sv_utf8_downgrade(pTHX_ SV *const sv, const bool fail_ok) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UTF8_DOWNGRADE \ assert(sv) -PERL_CALLCONV void Perl_sv_utf8_encode(pTHX_ SV *sv) +PERL_CALLCONV void Perl_sv_utf8_encode(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UTF8_ENCODE \ assert(sv) -PERL_CALLCONV bool Perl_sv_utf8_decode(pTHX_ SV *sv) +PERL_CALLCONV bool Perl_sv_utf8_decode(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UTF8_DECODE \ assert(sv) @@ -5606,13 +5606,13 @@ STATIC bool S_sv_2iuv_common(pTHX_ SV *const sv) #define PERL_ARGS_ASSERT_SV_2IUV_COMMON \ assert(sv) -STATIC void S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype) +STATIC void S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_GLOB_ASSIGN_GLOB \ assert(dstr); assert(sstr) -STATIC void S_glob_assign_ref(pTHX_ SV *dstr, SV *sstr) +STATIC void S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_GLOB_ASSIGN_REF \ @@ -5884,7 +5884,7 @@ STATIC SV* S_swash_get(pTHX_ SV* swash, UV start, UV span) START_EXTERN_C -PERL_CALLCONV void Perl_sv_setsv_flags(pTHX_ SV *dstr, SV *sstr, I32 flags) +PERL_CALLCONV void Perl_sv_setsv_flags(pTHX_ SV *dstr, SV *sstr, const I32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_SETSV_FLAGS \ assert(dstr) @@ -5900,7 +5900,7 @@ PERL_CALLCONV void Perl_sv_catsv_flags(pTHX_ SV* dsv, SV* ssv, I32 flags) #define PERL_ARGS_ASSERT_SV_CATSV_FLAGS \ assert(dsv) -PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade_flags(pTHX_ SV *sv, I32 flags) +PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade_flags(pTHX_ SV *const sv, const I32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_UTF8_UPGRADE_FLAGS \ assert(sv) diff --git a/sv.c b/sv.c index 1db4b92..5c3f306 100644 --- a/sv.c +++ b/sv.c @@ -3027,7 +3027,7 @@ Usually accessed via the C macro. */ char * -Perl_sv_2pvutf8(pTHX_ register SV *sv, STRLEN *lp) +Perl_sv_2pvutf8(pTHX_ register SV *const sv, STRLEN *const lp) { PERL_ARGS_ASSERT_SV_2PVUTF8; @@ -3046,7 +3046,7 @@ sv_true() or its macro equivalent. */ bool -Perl_sv_2bool(pTHX_ register SV *sv) +Perl_sv_2bool(pTHX_ register SV *const sv) { dVAR; @@ -3117,7 +3117,7 @@ use the Encode extension for that. */ STRLEN -Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags) +Perl_sv_utf8_upgrade_flags(pTHX_ register SV *const sv, const I32 flags) { dVAR; @@ -3190,7 +3190,7 @@ use the Encode extension for that. */ bool -Perl_sv_utf8_downgrade(pTHX_ register SV* sv, bool fail_ok) +Perl_sv_utf8_downgrade(pTHX_ register SV *const sv, const bool fail_ok) { dVAR; @@ -3233,7 +3233,7 @@ flag off so that it looks like octets again. */ void -Perl_sv_utf8_encode(pTHX_ register SV *sv) +Perl_sv_utf8_encode(pTHX_ register SV *const sv) { PERL_ARGS_ASSERT_SV_UTF8_ENCODE; @@ -3260,7 +3260,7 @@ Scans PV for validity and returns false if the PV is invalid UTF-8. */ bool -Perl_sv_utf8_decode(pTHX_ register SV *sv) +Perl_sv_utf8_decode(pTHX_ register SV *const sv) { PERL_ARGS_ASSERT_SV_UTF8_DECODE; @@ -3328,7 +3328,7 @@ copy-ish functions and macros use this underneath. */ static void -S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype) +S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype) { I32 mro_changes = 0; /* 1 = method, 2 = isa */ @@ -3405,7 +3405,7 @@ S_glob_assign_glob(pTHX_ SV *dstr, SV *sstr, const int dtype) } static void -S_glob_assign_ref(pTHX_ SV *dstr, SV *sstr) +S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr) { SV * const sref = SvREFCNT_inc(SvRV(sstr)); SV *dref = NULL; @@ -3518,7 +3518,7 @@ S_glob_assign_ref(pTHX_ SV *dstr, SV *sstr) } void -Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) +Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV* sstr, const I32 flags) { dVAR; register U32 sflags; @@ -3955,7 +3955,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setsv_mg(pTHX_ SV *dstr, register SV *sstr) +Perl_sv_setsv_mg(pTHX_ SV *const dstr, register SV *const sstr) { PERL_ARGS_ASSERT_SV_SETSV_MG;