From: Steven Schubiger Date: Sun, 2 Mar 2008 20:10:29 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac1e9476daed4b24851ae2c4ed3d43f92b6a1247;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080302191029.GC10705@refcnt.homeunix.org> Plus regen and additional tweaks to silence warnings from VC7 in sv.c from this patch and previous patches from same author. p4raw-id: //depot/perl@33411 --- diff --git a/embed.fnc b/embed.fnc index b5459e0..6c727bf 100644 --- a/embed.fnc +++ b/embed.fnc @@ -861,15 +861,15 @@ 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 *const sv -Apd |I32 |sv_cmp |NULLOK SV* sv1|NULLOK SV* sv2 -Apd |I32 |sv_cmp_locale |NULLOK SV* sv1|NULLOK SV* sv2 +Apd |I32 |sv_cmp |NULLOK SV *const sv1|NULLOK SV *const sv2 +Apd |I32 |sv_cmp_locale |NULLOK SV *const sv1|NULLOK SV *const sv2 #if defined(USE_LOCALE_COLLATE) -Apd |char* |sv_collxfrm |NN SV* sv|NN STRLEN* nxp +Apd |char* |sv_collxfrm |NN SV *const sv|NN STRLEN *const nxp #endif Ap |OP* |sv_compile_2op |NN SV *sv|NN OP **startop \ |NN const char *code|NN PAD **padp Apd |int |getcwd_sv |NN SV* sv -Apd |void |sv_dec |NULLOK SV* sv +Apd |void |sv_dec |NULLOK SV *const sv Ap |void |sv_dump |NN SV* sv ApdR |bool |sv_derived_from|NN SV* sv|NN const char *const name ApdR |bool |sv_does |NN SV* sv|NN const char *const name @@ -877,9 +877,9 @@ Apd |I32 |sv_eq |NULLOK SV* sv1|NULLOK SV* sv2 Apd |void |sv_free |NULLOK SV *const sv poMX |void |sv_free2 |NN SV *const sv pd |void |sv_free_arenas -Apd |char* |sv_gets |NN SV* sv|NN PerlIO* fp|I32 append +Apd |char* |sv_gets |NN SV *const sv|NN PerlIO *const fp|I32 append Apd |char* |sv_grow |NN SV *const sv|STRLEN newlen -Apd |void |sv_inc |NULLOK SV* sv +Apd |void |sv_inc |NULLOK SV *const sv Apd |void |sv_insert |NN SV *const bigstr|const STRLEN offset|const STRLEN len \ |NN const char *const little|const STRLEN littlelen Apd |int |sv_isa |NULLOK SV* sv|NN const char* name @@ -887,16 +887,16 @@ Apd |int |sv_isobject |NULLOK SV* sv Apd |STRLEN |sv_len |NULLOK SV *const sv Apd |STRLEN |sv_len_utf8 |NULLOK SV *const sv Apd |void |sv_magic |NN SV *const sv|NULLOK SV *const obj|const int how \ - |NULLOK const char *const name|I32 namlen + |NULLOK const char *const name|const I32 namlen Apd |MAGIC *|sv_magicext |NN SV *const sv|NULLOK SV *const obj|const int how \ |NULLOK const MGVTBL *const vtbl|NULLOK const char *const name \ |const I32 namlen -ApdaR |SV* |sv_mortalcopy |NULLOK SV* oldsv +ApdaR |SV* |sv_mortalcopy |NULLOK SV *const oldsv ApdR |SV* |sv_newmortal Apd |SV* |sv_newref |NULLOK SV *const sv Ap |char* |sv_peek |NULLOK SV* sv Apd |void |sv_pos_u2b |NULLOK SV *const sv|NN I32 *const offsetp|NULLOK I32 *const lenp -Apd |void |sv_pos_b2u |NULLOK SV* sv|NN I32* offsetp +Apd |void |sv_pos_b2u |NULLOK SV *const sv|NN I32 *const offsetp Amdb |char* |sv_pvn_force |NN SV* sv|NULLOK STRLEN* lp Apd |char* |sv_pvutf8n_force|NN SV* sv|NULLOK STRLEN* lp Apd |char* |sv_pvbyten_force|NN SV* sv|NULLOK STRLEN* lp @@ -1563,9 +1563,9 @@ sn |STRLEN |sv_pos_u2b_midway|NN const U8 *const start \ s |STRLEN |sv_pos_u2b_cached|NN SV *const sv|NN MAGIC **const mgp \ |NN const U8 *const start|NN const U8 *const send \ |const STRLEN uoffset|STRLEN uoffset0|STRLEN boffset0 -s |void |utf8_mg_pos_cache_update|NN SV *sv|NN MAGIC **mgp \ - |STRLEN byte|STRLEN utf8|STRLEN blen -s |STRLEN |sv_pos_b2u_midway|NN const U8 *s|NN const U8 *const target \ +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 # if defined(PERL_OLD_COPY_ON_WRITE) diff --git a/pod/perlapi.pod b/pod/perlapi.pod index cdad9de..c9ae52c 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5615,7 +5615,7 @@ string in C is less than, equal to, or greater than the string in C. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. See also C. - I32 sv_cmp(SV* sv1, SV* sv2) + I32 sv_cmp(SV *const sv1, SV *const sv2) =for hackers Found in file sv.c @@ -5627,7 +5627,7 @@ Compares the strings in two SVs in a locale-aware manner. Is UTF-8 and 'use bytes' aware, handles get magic, and will coerce its args to strings if necessary. See also C. - I32 sv_cmp_locale(SV* sv1, SV* sv2) + I32 sv_cmp_locale(SV *const sv1, SV *const sv2) =for hackers Found in file sv.c @@ -5642,7 +5642,7 @@ scalar data of the variable, but transformed to such a format that a normal memory comparison can be used to compare the data according to the locale settings. - char* sv_collxfrm(SV* sv, STRLEN* nxp) + char* sv_collxfrm(SV *const sv, STRLEN *const nxp) =for hackers Found in file sv.c @@ -5669,7 +5669,7 @@ X Auto-decrement of the value in the SV, doing string to numeric conversion if necessary. Handles 'get' magic. - void sv_dec(SV* sv) + void sv_dec(SV *const sv) =for hackers Found in file sv.c @@ -5723,7 +5723,7 @@ X Get a line from the filehandle and store it into the SV, optionally appending to the currently-stored string. - char* sv_gets(SV* sv, PerlIO* fp, I32 append) + char* sv_gets(SV *const sv, PerlIO *const fp, I32 append) =for hackers Found in file sv.c @@ -5746,7 +5746,7 @@ X Auto-increment of the value in the SV, doing string to numeric conversion if necessary. Handles 'get' magic. - void sv_inc(SV* sv) + void sv_inc(SV *const sv) =for hackers Found in file sv.c @@ -5820,7 +5820,7 @@ handling of the C and C arguments. You need to use C to add magic to SvREADONLY SVs and also to add more than one instance of the same 'how'. - void sv_magic(SV *const sv, SV *const obj, const int how, const char *const name, I32 namlen) + void sv_magic(SV *const sv, SV *const obj, const int how, const char *const name, const I32 namlen) =for hackers Found in file sv.c @@ -5855,7 +5855,7 @@ The new SV is marked as mortal. It will be destroyed "soon", either by an explicit call to FREETMPS, or by an implicit call at places such as statement boundaries. See also C and C. - SV* sv_mortalcopy(SV* oldsv) + SV* sv_mortalcopy(SV *const oldsv) =for hackers Found in file sv.c @@ -5891,7 +5891,7 @@ Converts the value pointed to by offsetp from a count of bytes from the start of the string, to a count of the equivalent number of UTF-8 chars. Handles magic and type coercion. - void sv_pos_b2u(SV* sv, I32* offsetp) + void sv_pos_b2u(SV *const sv, I32 *const offsetp) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index d6869ca..410b60a 100644 --- a/proto.h +++ b/proto.h @@ -3119,10 +3119,10 @@ PERL_CALLCONV void Perl_sv_clear(pTHX_ SV *const sv) #define PERL_ARGS_ASSERT_SV_CLEAR \ assert(sv) -PERL_CALLCONV I32 Perl_sv_cmp(pTHX_ SV* sv1, SV* sv2); -PERL_CALLCONV I32 Perl_sv_cmp_locale(pTHX_ SV* sv1, SV* sv2); +PERL_CALLCONV I32 Perl_sv_cmp(pTHX_ SV *const sv1, SV *const sv2); +PERL_CALLCONV I32 Perl_sv_cmp_locale(pTHX_ SV *const sv1, SV *const sv2); #if defined(USE_LOCALE_COLLATE) -PERL_CALLCONV char* Perl_sv_collxfrm(pTHX_ SV* sv, STRLEN* nxp) +PERL_CALLCONV char* Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_COLLXFRM \ @@ -3142,7 +3142,7 @@ PERL_CALLCONV int Perl_getcwd_sv(pTHX_ SV* sv) #define PERL_ARGS_ASSERT_GETCWD_SV \ assert(sv) -PERL_CALLCONV void Perl_sv_dec(pTHX_ SV* sv); +PERL_CALLCONV void Perl_sv_dec(pTHX_ SV *const sv); PERL_CALLCONV void Perl_sv_dump(pTHX_ SV* sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_DUMP \ @@ -3170,7 +3170,7 @@ PERL_CALLCONV void Perl_sv_free2(pTHX_ SV *const sv) assert(sv) PERL_CALLCONV void Perl_sv_free_arenas(pTHX); -PERL_CALLCONV char* Perl_sv_gets(pTHX_ SV* sv, PerlIO* fp, I32 append) +PERL_CALLCONV char* Perl_sv_gets(pTHX_ SV *const sv, PerlIO *const fp, I32 append) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_GETS \ @@ -3181,7 +3181,7 @@ PERL_CALLCONV char* Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen) #define PERL_ARGS_ASSERT_SV_GROW \ assert(sv) -PERL_CALLCONV void Perl_sv_inc(pTHX_ SV* sv); +PERL_CALLCONV void Perl_sv_inc(pTHX_ SV *const sv); PERL_CALLCONV void Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len, const char *const little, const STRLEN littlelen) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_4); @@ -3196,7 +3196,7 @@ PERL_CALLCONV int Perl_sv_isa(pTHX_ SV* sv, const char* name) PERL_CALLCONV int Perl_sv_isobject(pTHX_ SV* sv); PERL_CALLCONV STRLEN Perl_sv_len(pTHX_ SV *const sv); PERL_CALLCONV STRLEN Perl_sv_len_utf8(pTHX_ SV *const sv); -PERL_CALLCONV void Perl_sv_magic(pTHX_ SV *const sv, SV *const obj, const int how, const char *const name, I32 namlen) +PERL_CALLCONV void Perl_sv_magic(pTHX_ SV *const sv, SV *const obj, const int how, const char *const name, const I32 namlen) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_MAGIC \ assert(sv) @@ -3206,7 +3206,7 @@ PERL_CALLCONV MAGIC * Perl_sv_magicext(pTHX_ SV *const sv, SV *const obj, const #define PERL_ARGS_ASSERT_SV_MAGICEXT \ assert(sv) -PERL_CALLCONV SV* Perl_sv_mortalcopy(pTHX_ SV* oldsv) +PERL_CALLCONV SV* Perl_sv_mortalcopy(pTHX_ SV *const oldsv) __attribute__malloc__ __attribute__warn_unused_result__; @@ -3220,7 +3220,7 @@ PERL_CALLCONV void Perl_sv_pos_u2b(pTHX_ SV *const sv, I32 *const offsetp, I32 * #define PERL_ARGS_ASSERT_SV_POS_U2B \ assert(offsetp) -PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV* sv, I32* offsetp) +PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV *const sv, I32 *const offsetp) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_SV_POS_B2U \ assert(offsetp) @@ -5571,13 +5571,13 @@ STATIC STRLEN S_sv_pos_u2b_cached(pTHX_ SV *const sv, MAGIC **const mgp, const U #define PERL_ARGS_ASSERT_SV_POS_U2B_CACHED \ assert(sv); assert(mgp); assert(start); assert(send) -STATIC void S_utf8_mg_pos_cache_update(pTHX_ SV *sv, MAGIC **mgp, STRLEN byte, STRLEN utf8, STRLEN blen) +STATIC void S_utf8_mg_pos_cache_update(pTHX_ SV *const sv, MAGIC **const mgp, const STRLEN byte, const STRLEN utf8, const STRLEN blen) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_UTF8_MG_POS_CACHE_UPDATE \ assert(sv); assert(mgp) -STATIC STRLEN S_sv_pos_b2u_midway(pTHX_ const U8 *s, const U8 *const target, const U8 *end, STRLEN endu) +STATIC STRLEN S_sv_pos_b2u_midway(pTHX_ const U8 *const s, const U8 *const target, const U8 *end, STRLEN endu) __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3); diff --git a/sv.c b/sv.c index c621b2a..a96e00e 100644 --- a/sv.c +++ b/sv.c @@ -5970,8 +5970,8 @@ Perl_sv_pos_u2b(pTHX_ register SV *const sv, I32 *const offsetp, I32 *const lenp from. */ static void -S_utf8_mg_pos_cache_update(pTHX_ SV *sv, MAGIC **mgp, STRLEN byte, STRLEN utf8, - STRLEN blen) +S_utf8_mg_pos_cache_update(pTHX_ SV *const sv, MAGIC **const mgp, const STRLEN byte, + const STRLEN utf8, const STRLEN blen) { STRLEN *cache; @@ -6110,8 +6110,8 @@ S_utf8_mg_pos_cache_update(pTHX_ SV *sv, MAGIC **mgp, STRLEN byte, STRLEN utf8, assumption is made as in S_sv_pos_u2b_midway(), namely that walking backward is half the speed of walking forward. */ static STRLEN -S_sv_pos_b2u_midway(pTHX_ const U8 *s, const U8 *const target, const U8 *end, - STRLEN endu) +S_sv_pos_b2u_midway(pTHX_ const U8 *const s, const U8 *const target, + const U8 *end, STRLEN endu) { const STRLEN forw = target - s; STRLEN backw = end - target; @@ -6149,7 +6149,7 @@ Handles magic and type coercion. * */ void -Perl_sv_pos_b2u(pTHX_ register SV* sv, I32* offsetp) +Perl_sv_pos_b2u(pTHX_ register SV *const sv, I32 *const offsetp) { const U8* s; const STRLEN byte = *offsetp; @@ -6352,7 +6352,7 @@ coerce its args to strings if necessary. See also C. */ I32 -Perl_sv_cmp(pTHX_ register SV *sv1, register SV *sv2) +Perl_sv_cmp(pTHX_ register SV *const sv1, register SV *const sv2) { dVAR; STRLEN cur1, cur2; @@ -6434,7 +6434,7 @@ if necessary. See also C. */ I32 -Perl_sv_cmp_locale(pTHX_ register SV *sv1, register SV *sv2) +Perl_sv_cmp_locale(pTHX_ register SV *const sv1, register SV *const sv2) { dVAR; #ifdef USE_LOCALE_COLLATE @@ -6499,7 +6499,7 @@ settings. */ char * -Perl_sv_collxfrm(pTHX_ SV *sv, STRLEN *nxp) +Perl_sv_collxfrm(pTHX_ SV *const sv, STRLEN *const nxp) { dVAR; MAGIC *mg; @@ -6557,7 +6557,7 @@ appending to the currently-stored string. */ char * -Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) +Perl_sv_gets(pTHX_ register SV *const sv, register PerlIO *const fp, I32 append) { dVAR; const char *rsptr; @@ -6915,7 +6915,7 @@ if necessary. Handles 'get' magic. */ void -Perl_sv_inc(pTHX_ register SV *sv) +Perl_sv_inc(pTHX_ register SV *const sv) { dVAR; register char *d; @@ -7079,7 +7079,7 @@ if necessary. Handles 'get' magic. */ void -Perl_sv_dec(pTHX_ register SV *sv) +Perl_sv_dec(pTHX_ register SV *const sv) { dVAR; int flags; @@ -7208,7 +7208,7 @@ statement boundaries. See also C and C. * permanent location. */ SV * -Perl_sv_mortalcopy(pTHX_ SV *oldstr) +Perl_sv_mortalcopy(pTHX_ SV *const oldstr) { dVAR; register SV *sv;