From: Steven Schubiger Date: Mon, 4 Feb 2008 15:44:19 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aad570aaa63ce05413f1e93d9aaa533614bb7901;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080204144419.GB20276@refcnt.homeunix.org> p4raw-id: //depot/perl@33245 --- diff --git a/embed.fnc b/embed.fnc index f0f2ca6..2cc3250 100644 --- a/embed.fnc +++ b/embed.fnc @@ -424,7 +424,7 @@ p |OP* |listkids |NULLOK OP* o Apd |void |load_module|U32 flags|NN SV* name|NULLOK SV* ver|... Ap |void |vload_module|U32 flags|NN SV* name|NULLOK SV* ver|NULLOK va_list* args p |OP* |localize |NN OP* arg|I32 lexical -ApdR |I32 |looks_like_number|NN SV* sv +ApdR |I32 |looks_like_number|NN SV *const sv Apd |UV |grok_bin |NN const char* start|NN STRLEN* len_p|NN I32* flags|NULLOK NV *result Apd |UV |grok_hex |NN const char* start|NN STRLEN* len_p|NN I32* flags|NULLOK NV *result Apd |int |grok_number |NN const char *pv|STRLEN len|NULLOK UV *valuep @@ -832,7 +832,7 @@ Apd |char* |sv_pvutf8n |NN SV *sv|NN STRLEN *len Apd |char* |sv_pvbyten |NN SV *sv|NN STRLEN *len Apd |I32 |sv_true |NULLOK SV *sv pd |void |sv_add_arena |NN char *const ptr|const U32 size|const U32 flags -Apd |int |sv_backoff |NN SV* sv +Apd |int |sv_backoff |NN SV *const sv Apd |SV* |sv_bless |NN SV* sv|NN HV* 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 @@ -859,7 +859,7 @@ Apd |void |sv_free |NULLOK SV* sv poMX |void |sv_free2 |NN SV* sv pd |void |sv_free_arenas Apd |char* |sv_gets |NN SV* sv|NN PerlIO* fp|I32 append -Apd |char* |sv_grow |NN SV* sv|STRLEN newlen +Apd |char* |sv_grow |NN SV *const sv|STRLEN newlen Apd |void |sv_inc |NN SV* sv Apd |void |sv_insert |NN SV* bigsv|STRLEN offset|STRLEN len \ |NN const char* little|STRLEN littlelen @@ -889,10 +889,10 @@ Apd |void |sv_report_used Apd |void |sv_reset |NN const char* s|NULLOK HV* 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 -Apd |void |sv_setiv |NN SV* sv|IV num +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* sv|UV num -Apd |void |sv_setnv |NN SV* sv|NV 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 @@ -907,7 +907,7 @@ Apd |int |sv_unmagic |NN SV* sv|int type Apdmb |void |sv_unref |NN SV* sv Apd |void |sv_unref_flags |NN SV* sv|U32 flags Apd |void |sv_untaint |NN SV* sv -Apd |void |sv_upgrade |NN SV* sv|svtype new_type +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 @@ -1016,10 +1016,10 @@ Apdbm |void |sv_catpvn_mg |NN SV *sv|NN const char *ptr|STRLEN len Apdbm |void |sv_catsv_mg |NN SV *dstr|NULLOK SV *sstr 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 -Apd |void |sv_setiv_mg |NN SV *sv|IV i +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 *sv|UV u -Apd |void |sv_setnv_mg |NN SV *sv|NV num +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 @@ -1494,7 +1494,7 @@ poM |int |sv_kill_backrefs |NN SV *sv|NN AV *av #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) nsR |char * |uiv_2buf |NN char *buf|IV iv|UV uv|int is_uv|NN char **peob s |void |sv_unglob |NN SV* sv -s |void |not_a_number |NN SV *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 *target|NN SV *ref sR |SV * |varname |NULLOK GV *gv|const char gvtype|PADOFFSET targ \ diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 34de5fe..6cf527c 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5097,7 +5097,7 @@ Test if the content of an SV looks like a number (or is a number). C and C are treated as numbers (so will not issue a non-numeric warning), even if your atof() doesn't grok them. - I32 looks_like_number(SV* sv) + I32 looks_like_number(SV *const sv) =for hackers Found in file sv.c @@ -5448,7 +5448,7 @@ X Remove any string offset. You should normally use the C macro wrapper instead. - int sv_backoff(SV* sv) + int sv_backoff(SV *const sv) =for hackers Found in file sv.c @@ -5735,7 +5735,7 @@ Expands the character buffer in the SV. If necessary, uses C and upgrades the SV to C. Returns a pointer to the character buffer. Use the C wrapper instead. - char* sv_grow(SV* sv, STRLEN newlen) + char* sv_grow(SV *const sv, STRLEN newlen) =for hackers Found in file sv.c @@ -6013,7 +6013,7 @@ X Copies an integer into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also C. - void sv_setiv(SV* sv, IV num) + void sv_setiv(SV *const sv, const IV num) =for hackers Found in file sv.c @@ -6023,7 +6023,7 @@ X Like C, but also handles 'set' magic. - void sv_setiv_mg(SV *sv, IV i) + void sv_setiv_mg(SV *const sv, const IV i) =for hackers Found in file sv.c @@ -6034,7 +6034,7 @@ X Copies a double into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also C. - void sv_setnv(SV* sv, NV num) + void sv_setnv(SV *const sv, const NV num) =for hackers Found in file sv.c @@ -6044,7 +6044,7 @@ X Like C, but also handles 'set' magic. - void sv_setnv_mg(SV *sv, NV num) + void sv_setnv_mg(SV *const sv, const NV num) =for hackers Found in file sv.c @@ -6282,7 +6282,7 @@ X Copies an unsigned integer into the given SV, upgrading first if necessary. Does not handle 'set' magic. See also C. - void sv_setuv(SV* sv, UV num) + void sv_setuv(SV *const sv, const UV num) =for hackers Found in file sv.c @@ -6292,7 +6292,7 @@ X Like C, but also handles 'set' magic. - void sv_setuv_mg(SV *sv, UV u) + void sv_setuv_mg(SV *const sv, const UV u) =for hackers Found in file sv.c @@ -6360,7 +6360,7 @@ Upgrade an SV to a more complex form. Generally adds a new body type to the SV, then copies across as much information as possible from the old body. You generally want to use the C macro wrapper. See also C. - void sv_upgrade(SV* sv, svtype new_type) + void sv_upgrade(SV *const sv, svtype new_type) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index eac3dd3..37ee797 100644 --- a/proto.h +++ b/proto.h @@ -1057,7 +1057,7 @@ PERL_CALLCONV void Perl_vload_module(pTHX_ U32 flags, SV* name, SV* ver, va_list PERL_CALLCONV OP* Perl_localize(pTHX_ OP* arg, I32 lexical) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV I32 Perl_looks_like_number(pTHX_ SV* sv) +PERL_CALLCONV I32 Perl_looks_like_number(pTHX_ SV *const sv) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); @@ -2226,7 +2226,7 @@ PERL_CALLCONV I32 Perl_sv_true(pTHX_ SV *sv); PERL_CALLCONV void Perl_sv_add_arena(pTHX_ char *const ptr, const U32 size, const U32 flags) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV int Perl_sv_backoff(pTHX_ SV* sv) +PERL_CALLCONV int Perl_sv_backoff(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); PERL_CALLCONV SV* Perl_sv_bless(pTHX_ SV* sv, HV* stash) @@ -2310,7 +2310,7 @@ PERL_CALLCONV char* Perl_sv_gets(pTHX_ SV* sv, PerlIO* fp, I32 append) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); -PERL_CALLCONV char* Perl_sv_grow(pTHX_ SV* sv, STRLEN newlen) +PERL_CALLCONV char* Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen) __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_sv_inc(pTHX_ SV* sv) @@ -2388,16 +2388,16 @@ PERL_CALLCONV void Perl_sv_vsetpvf(pTHX_ SV* sv, const char* pat, va_list* args) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); -PERL_CALLCONV void Perl_sv_setiv(pTHX_ SV* sv, IV num) +PERL_CALLCONV void Perl_sv_setiv(pTHX_ SV *const sv, const IV num) __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_sv_setpviv(pTHX_ SV* sv, IV num) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_setuv(pTHX_ SV* sv, UV num) +PERL_CALLCONV void Perl_sv_setuv(pTHX_ SV *const sv, const UV num) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_setnv(pTHX_ SV* sv, NV num) +PERL_CALLCONV void Perl_sv_setnv(pTHX_ SV *const sv, const NV num) __attribute__nonnull__(pTHX_1); PERL_CALLCONV SV* Perl_sv_setref_iv(pTHX_ SV* rv, const char* classname, IV iv) @@ -2444,7 +2444,7 @@ PERL_CALLCONV void Perl_sv_unref_flags(pTHX_ SV* sv, U32 flags) PERL_CALLCONV void Perl_sv_untaint(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_upgrade(pTHX_ SV* sv, svtype new_type) +PERL_CALLCONV void Perl_sv_upgrade(pTHX_ SV *const sv, svtype new_type) __attribute__nonnull__(pTHX_1); /* PERL_CALLCONV void Perl_sv_usepvn(pTHX_ SV* sv, char* ptr, STRLEN len) @@ -2728,16 +2728,16 @@ PERL_CALLCONV void Perl_sv_vsetpvf_mg(pTHX_ SV* sv, const char* pat, va_list* ar __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); -PERL_CALLCONV void Perl_sv_setiv_mg(pTHX_ SV *sv, IV i) +PERL_CALLCONV void Perl_sv_setiv_mg(pTHX_ SV *const sv, const IV i) __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_sv_setpviv_mg(pTHX_ SV *sv, IV iv) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_setuv_mg(pTHX_ SV *sv, UV u) +PERL_CALLCONV void Perl_sv_setuv_mg(pTHX_ SV *const sv, const UV u) __attribute__nonnull__(pTHX_1); -PERL_CALLCONV void Perl_sv_setnv_mg(pTHX_ SV *sv, NV num) +PERL_CALLCONV void Perl_sv_setnv_mg(pTHX_ SV *const sv, const NV num) __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_sv_setpv_mg(pTHX_ SV *sv, const char *ptr) @@ -3953,7 +3953,7 @@ STATIC char * S_uiv_2buf(char *buf, IV iv, UV uv, int is_uv, char **peob) STATIC void S_sv_unglob(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); -STATIC void S_not_a_number(pTHX_ SV *sv) +STATIC void S_not_a_number(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); STATIC I32 S_visit(pTHX_ SVFUNC_t f, const U32 flags, const U32 mask) diff --git a/sv.c b/sv.c index 9ef94dc..59fc604 100644 --- a/sv.c +++ b/sv.c @@ -1114,7 +1114,7 @@ You generally want to use the C macro wrapper. See also C. */ void -Perl_sv_upgrade(pTHX_ register SV *sv, svtype new_type) +Perl_sv_upgrade(pTHX_ register SV *const sv, svtype new_type) { dVAR; void* old_body; @@ -1398,7 +1398,7 @@ wrapper instead. */ int -Perl_sv_backoff(pTHX_ register SV *sv) +Perl_sv_backoff(pTHX_ register SV *const sv) { STRLEN delta; const char * const s = SvPVX_const(sv); @@ -1427,7 +1427,7 @@ Use the C wrapper instead. */ char * -Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen) +Perl_sv_grow(pTHX_ register SV *const sv, register STRLEN newlen) { register char *s; @@ -1495,7 +1495,7 @@ Does not handle 'set' magic. See also C. */ void -Perl_sv_setiv(pTHX_ register SV *sv, IV i) +Perl_sv_setiv(pTHX_ register SV *const sv, const IV i) { dVAR; SV_CHECK_THINKFIRST_COW_DROP(sv); @@ -1532,7 +1532,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setiv_mg(pTHX_ register SV *sv, IV i) +Perl_sv_setiv_mg(pTHX_ register SV *const sv, const IV i) { sv_setiv(sv,i); SvSETMAGIC(sv); @@ -1548,7 +1548,7 @@ Does not handle 'set' magic. See also C. */ void -Perl_sv_setuv(pTHX_ register SV *sv, UV u) +Perl_sv_setuv(pTHX_ register SV *const sv, const UV u) { /* With these two if statements: u=1.49 s=0.52 cu=72.49 cs=10.64 scripts=270 tests=20865 @@ -1576,7 +1576,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setuv_mg(pTHX_ register SV *sv, UV u) +Perl_sv_setuv_mg(pTHX_ register SV *const sv, const UV u) { sv_setuv(sv,u); SvSETMAGIC(sv); @@ -1592,7 +1592,7 @@ Does not handle 'set' magic. See also C. */ void -Perl_sv_setnv(pTHX_ register SV *sv, NV num) +Perl_sv_setnv(pTHX_ register SV *const sv, const NV num) { dVAR; SV_CHECK_THINKFIRST_COW_DROP(sv); @@ -1630,7 +1630,7 @@ Like C, but also handles 'set' magic. */ void -Perl_sv_setnv_mg(pTHX_ register SV *sv, NV num) +Perl_sv_setnv_mg(pTHX_ register SV *const sv, const NV num) { sv_setnv(sv,num); SvSETMAGIC(sv); @@ -1641,7 +1641,7 @@ Perl_sv_setnv_mg(pTHX_ register SV *sv, NV num) */ STATIC void -S_not_a_number(pTHX_ SV *sv) +S_not_a_number(pTHX_ SV *const sv) { dVAR; SV *dsv; @@ -1722,7 +1722,7 @@ non-numeric warning), even if your atof() doesn't grok them. */ I32 -Perl_looks_like_number(pTHX_ SV *sv) +Perl_looks_like_number(pTHX_ SV *const sv) { register const char *sbegin; STRLEN len;