From: Steven Schubiger Date: Sun, 2 Mar 2008 22:09:51 +0000 (+0100) Subject: Re: [PATCH] sv.c: consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=23f13727cccc413356361bc2912b89c4e0603e5f;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] sv.c: consting Message-ID: <20080302210951.GD10705@refcnt.homeunix.org> p4raw-id: //depot/perl@33471 --- diff --git a/embed.fnc b/embed.fnc index 88e3db2..f37e51e 100644 --- a/embed.fnc +++ b/embed.fnc @@ -157,7 +157,7 @@ Anp |void |load_module_nocontext|U32 flags|NN SV* name|NULLOK SV* ver|... Afnp |SV* |mess_nocontext |NN const char* pat|... Afnp |void |warn_nocontext |NN const char* pat|... Afnp |void |warner_nocontext|U32 err|NN const char* pat|... -Afnp |SV* |newSVpvf_nocontext|NN const char* pat|... +Afnp |SV* |newSVpvf_nocontext|NN const char *const pat|... Afnp |void |sv_catpvf_nocontext|NN SV* sv|NN const char* pat|... Afnp |void |sv_setpvf_nocontext|NN SV* sv|NN const char* pat|... Afnp |void |sv_catpvf_mg_nocontext|NN SV* sv|NN const char* pat|... @@ -595,23 +595,23 @@ Apa |OP* |newPADOP |I32 type|I32 flags|NN SV* sv #endif Apa |OP* |newPMOP |I32 type|I32 flags Apa |OP* |newPVOP |I32 type|I32 flags|NULLOK char* pv -Apa |SV* |newRV |NN SV* sv -Apda |SV* |newRV_noinc |NN SV* sv +Apa |SV* |newRV |NN SV *const sv +Apda |SV* |newRV_noinc |NN SV *const sv Apda |SV* |newSV |const STRLEN len Apa |OP* |newSVREF |NN OP* o Apa |OP* |newSVOP |I32 type|I32 flags|NN SV* sv -Apda |SV* |newSViv |IV i -Apda |SV* |newSVuv |UV u -Apda |SV* |newSVnv |NV n -Apda |SV* |newSVpv |NULLOK const char* s|STRLEN len -Apda |SV* |newSVpvn |NULLOK const char* s|STRLEN len -Apda |SV* |newSVpvn_flags |NULLOK const char* s|STRLEN len|U32 flags -Apda |SV* |newSVhek |NULLOK const HEK *hek +Apda |SV* |newSViv |const IV i +Apda |SV* |newSVuv |const UV u +Apda |SV* |newSVnv |const NV n +Apda |SV* |newSVpv |NULLOK const char *const s|const STRLEN len +Apda |SV* |newSVpvn |NULLOK const char *const s|const STRLEN len +Apda |SV* |newSVpvn_flags |NULLOK const char *const s|const STRLEN len|const U32 flags +Apda |SV* |newSVhek |NULLOK const HEK *const hek Apda |SV* |newSVpvn_share |NULLOK const char* s|I32 len|U32 hash -Afpda |SV* |newSVpvf |NN const char* pat|... -Apa |SV* |vnewSVpvf |NN const char* pat|NULLOK va_list* args +Afpda |SV* |newSVpvf |NN const char *const pat|... +Apa |SV* |vnewSVpvf |NN const char *const pat|NULLOK va_list *const args Apd |SV* |newSVrv |NN SV* rv|NULLOK const char* classname -Apda |SV* |newSVsv |NULLOK SV* old +Apda |SV* |newSVsv |NULLOK SV *const old Apda |SV* |newSV_type |const svtype type Apa |OP* |newUNOP |I32 type|I32 flags|NULLOK OP* first Apa |OP* |newWHENOP |NULLOK OP* cond|NN OP* block @@ -824,15 +824,16 @@ 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 *const sv -Apd |CV* |sv_2cv |NULLOK SV* sv|NN HV** st|NN GV** gvp|I32 lref -Apd |IO* |sv_2io |NN SV* sv +Apd |CV* |sv_2cv |NULLOK SV* sv|NN HV **const st|NN GV **const gvp \ + |const I32 lref +Apd |IO* |sv_2io |NN SV *const sv #ifdef PERL_IN_SV_C s |bool |glob_2number |NN GV* const gv s |char* |glob_2pv |NN GV* const gv|NULLOK STRLEN * const len #endif Amb |IV |sv_2iv |NULLOK SV *sv Apd |IV |sv_2iv_flags |NULLOK SV *const sv|const I32 flags -Apd |SV* |sv_2mortal |NULLOK SV* sv +Apd |SV* |sv_2mortal |NULLOK SV *const sv 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 @@ -848,7 +849,7 @@ Apd |NV |sv_nv |NN SV* sv Apd |char* |sv_pvn |NN SV *sv|NN STRLEN *lp Apd |char* |sv_pvutf8n |NN SV *sv|NN STRLEN *lp Apd |char* |sv_pvbyten |NN SV *sv|NN STRLEN *lp -Apd |I32 |sv_true |NULLOK SV *sv +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* sv|NN HV* stash @@ -906,7 +907,7 @@ Apd |bool |sv_cat_decode |NN SV* dsv|NN SV *encoding|NN SV *ssv|NN int *offset \ ApdR |const char* |sv_reftype |NN const SV* sv|int ob Apd |void |sv_replace |NN SV *const sv|NN SV *const nsv Apd |void |sv_report_used -Apd |void |sv_reset |NN const char* s|NULLOK HV* stash +Apd |void |sv_reset |NN const char* s|NULLOK HV *const 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 *const sv|const IV num diff --git a/pod/perlapi.pod b/pod/perlapi.pod index c9ae52c..dc0401f 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -5108,7 +5108,7 @@ X Creates an RV wrapper for an SV. The reference count for the original SV is B incremented. - SV* newRV_noinc(SV* sv) + SV* newRV_noinc(SV *const sv) =for hackers Found in file sv.c @@ -5139,7 +5139,7 @@ Creates a new SV from the hash key structure. It will generate scalars that point to the shared string table where possible. Returns a new (undefined) SV if the hek is NULL. - SV* newSVhek(const HEK *hek) + SV* newSVhek(const HEK *const hek) =for hackers Found in file sv.c @@ -5150,7 +5150,7 @@ X Creates a new SV and copies an integer into it. The reference count for the SV is set to 1. - SV* newSViv(IV i) + SV* newSViv(const IV i) =for hackers Found in file sv.c @@ -5161,7 +5161,7 @@ X Creates a new SV and copies a floating point value into it. The reference count for the SV is set to 1. - SV* newSVnv(NV n) + SV* newSVnv(const NV n) =for hackers Found in file sv.c @@ -5173,7 +5173,7 @@ Creates a new SV and copies a string into it. The reference count for the SV is set to 1. If C is zero, Perl will compute the length using strlen(). For efficiency, consider using C instead. - SV* newSVpv(const char* s, STRLEN len) + SV* newSVpv(const char *const s, const STRLEN len) =for hackers Found in file sv.c @@ -5184,7 +5184,7 @@ X Creates a new SV and initializes it with the string formatted like C. - SV* newSVpvf(const char* pat, ...) + SV* newSVpvf(const char *const pat, ...) =for hackers Found in file sv.c @@ -5197,7 +5197,7 @@ SV is set to 1. Note that if C is zero, Perl will create a zero length string. You are responsible for ensuring that the source string is at least C bytes long. If the C argument is NULL the new SV will be undefined. - SV* newSVpvn(const char* s, STRLEN len) + SV* newSVpvn(const char *const s, const STRLEN len) =for hackers Found in file sv.c @@ -5217,7 +5217,7 @@ C is a convenience wrapper for this function, defined as #define newSVpvn_utf8(s, len, u) \ newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) - SV* newSVpvn_flags(const char* s, STRLEN len, U32 flags) + SV* newSVpvn_flags(const char *const s, const STRLEN len, const U32 flags) =for hackers Found in file sv.c @@ -5289,7 +5289,7 @@ X Creates a new SV which is an exact duplicate of the original SV. (Uses C). - SV* newSVsv(SV* old) + SV* newSVsv(SV *const old) =for hackers Found in file sv.c @@ -5300,7 +5300,7 @@ X Creates a new SV and copies an unsigned integer into it. The reference count for the SV is set to 1. - SV* newSVuv(UV u) + SV* newSVuv(const UV u) =for hackers Found in file sv.c @@ -5334,7 +5334,7 @@ Using various gambits, try to get a CV from an SV; in addition, try if possible to set C<*st> and C<*gvp> to the stash and GV associated with it. The flags in C are passed to sv_fetchsv. - CV* sv_2cv(SV* sv, HV** st, GV** gvp, I32 lref) + CV* sv_2cv(SV* sv, HV **const st, GV **const gvp, const I32 lref) =for hackers Found in file sv.c @@ -5346,7 +5346,7 @@ Using various gambits, try to get an IO from an SV: the IO slot if its a GV; or the recursive result if we're an RV; or the IO slot of the symbol named after the PV if we're a string. - IO* sv_2io(SV* sv) + IO* sv_2io(SV *const sv) =for hackers Found in file sv.c @@ -5372,7 +5372,7 @@ statement boundaries. SvTEMP() is turned on which means that the SV's string buffer can be "stolen" if this SV is copied. See also C and C. - SV* sv_2mortal(SV* sv) + SV* sv_2mortal(SV *const sv) =for hackers Found in file sv.c @@ -5988,7 +5988,7 @@ X Underlying implementation for the C Perl function. Note that the perl-level function is vaguely deprecated. - void sv_reset(const char* s, HV* stash) + void sv_reset(const char* s, HV *const stash) =for hackers Found in file sv.c @@ -6313,7 +6313,7 @@ Returns true if the SV has a true value by Perl's rules. Use the C macro instead, which may call C or may instead use an in-line version. - I32 sv_true(SV *sv) + I32 sv_true(SV *const sv) =for hackers Found in file sv.c diff --git a/proto.h b/proto.h index ef46817..8545e08 100644 --- a/proto.h +++ b/proto.h @@ -373,7 +373,7 @@ PERL_CALLCONV void Perl_warner_nocontext(U32 err, const char* pat, ...) #define PERL_ARGS_ASSERT_WARNER_NOCONTEXT \ assert(pat) -PERL_CALLCONV SV* Perl_newSVpvf_nocontext(const char* pat, ...) +PERL_CALLCONV SV* Perl_newSVpvf_nocontext(const char *const pat, ...) __attribute__format__(__printf__,1,2) __attribute__nonnull__(1); #define PERL_ARGS_ASSERT_NEWSVPVF_NOCONTEXT \ @@ -2142,14 +2142,14 @@ PERL_CALLCONV OP* Perl_newPVOP(pTHX_ I32 type, I32 flags, char* pv) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newRV(pTHX_ SV* sv) +PERL_CALLCONV SV* Perl_newRV(pTHX_ SV *const sv) __attribute__malloc__ __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_NEWRV \ assert(sv) -PERL_CALLCONV SV* Perl_newRV_noinc(pTHX_ SV* sv) +PERL_CALLCONV SV* Perl_newRV_noinc(pTHX_ SV *const sv) __attribute__malloc__ __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); @@ -2174,31 +2174,31 @@ PERL_CALLCONV OP* Perl_newSVOP(pTHX_ I32 type, I32 flags, SV* sv) #define PERL_ARGS_ASSERT_NEWSVOP \ assert(sv) -PERL_CALLCONV SV* Perl_newSViv(pTHX_ IV i) +PERL_CALLCONV SV* Perl_newSViv(pTHX_ const IV i) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVuv(pTHX_ UV u) +PERL_CALLCONV SV* Perl_newSVuv(pTHX_ const UV u) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVnv(pTHX_ NV n) +PERL_CALLCONV SV* Perl_newSVnv(pTHX_ const NV n) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVpv(pTHX_ const char* s, STRLEN len) +PERL_CALLCONV SV* Perl_newSVpv(pTHX_ const char *const s, const STRLEN len) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVpvn(pTHX_ const char* s, STRLEN len) +PERL_CALLCONV SV* Perl_newSVpvn(pTHX_ const char *const s, const STRLEN len) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVpvn_flags(pTHX_ const char* s, STRLEN len, U32 flags) +PERL_CALLCONV SV* Perl_newSVpvn_flags(pTHX_ const char *const s, const STRLEN len, const U32 flags) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVhek(pTHX_ const HEK *hek) +PERL_CALLCONV SV* Perl_newSVhek(pTHX_ const HEK *const hek) __attribute__malloc__ __attribute__warn_unused_result__; @@ -2206,7 +2206,7 @@ PERL_CALLCONV SV* Perl_newSVpvn_share(pTHX_ const char* s, I32 len, U32 hash) __attribute__malloc__ __attribute__warn_unused_result__; -PERL_CALLCONV SV* Perl_newSVpvf(pTHX_ const char* pat, ...) +PERL_CALLCONV SV* Perl_newSVpvf(pTHX_ const char *const pat, ...) __attribute__malloc__ __attribute__warn_unused_result__ __attribute__format__(__printf__,pTHX_1,pTHX_2) @@ -2214,7 +2214,7 @@ PERL_CALLCONV SV* Perl_newSVpvf(pTHX_ const char* pat, ...) #define PERL_ARGS_ASSERT_NEWSVPVF \ assert(pat) -PERL_CALLCONV SV* Perl_vnewSVpvf(pTHX_ const char* pat, va_list* args) +PERL_CALLCONV SV* Perl_vnewSVpvf(pTHX_ const char *const pat, va_list *const args) __attribute__malloc__ __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); @@ -2226,7 +2226,7 @@ PERL_CALLCONV SV* Perl_newSVrv(pTHX_ SV* rv, const char* classname) #define PERL_ARGS_ASSERT_NEWSVRV \ assert(rv) -PERL_CALLCONV SV* Perl_newSVsv(pTHX_ SV* old) +PERL_CALLCONV SV* Perl_newSVsv(pTHX_ SV *const old) __attribute__malloc__ __attribute__warn_unused_result__; @@ -2974,13 +2974,13 @@ PERL_CALLCONV bool Perl_sv_2bool(pTHX_ SV *const sv) #define PERL_ARGS_ASSERT_SV_2BOOL \ assert(sv) -PERL_CALLCONV CV* Perl_sv_2cv(pTHX_ SV* sv, HV** st, GV** gvp, I32 lref) +PERL_CALLCONV CV* Perl_sv_2cv(pTHX_ SV* sv, HV **const st, GV **const gvp, const I32 lref) __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3); #define PERL_ARGS_ASSERT_SV_2CV \ assert(st); assert(gvp) -PERL_CALLCONV IO* Perl_sv_2io(pTHX_ SV* sv) +PERL_CALLCONV IO* Perl_sv_2io(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_2IO \ assert(sv) @@ -2999,7 +2999,7 @@ STATIC char* S_glob_2pv(pTHX_ GV* const gv, STRLEN * const len) #endif /* PERL_CALLCONV IV Perl_sv_2iv(pTHX_ SV *sv); */ PERL_CALLCONV IV Perl_sv_2iv_flags(pTHX_ SV *const sv, const I32 flags); -PERL_CALLCONV SV* Perl_sv_2mortal(pTHX_ SV* sv); +PERL_CALLCONV SV* Perl_sv_2mortal(pTHX_ SV *const sv); PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV *const sv); PERL_CALLCONV SV* Perl_sv_2num(pTHX_ SV *const sv) __attribute__nonnull__(pTHX_1); @@ -3058,7 +3058,7 @@ PERL_CALLCONV char* Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *lp) #define PERL_ARGS_ASSERT_SV_PVBYTEN \ assert(sv); assert(lp) -PERL_CALLCONV I32 Perl_sv_true(pTHX_ SV *sv); +PERL_CALLCONV I32 Perl_sv_true(pTHX_ SV *const sv); PERL_CALLCONV void Perl_sv_add_arena(pTHX_ char *const ptr, const U32 size, const U32 flags) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_ADD_ARENA \ @@ -3265,7 +3265,7 @@ PERL_CALLCONV void Perl_sv_replace(pTHX_ SV *const sv, SV *const nsv) assert(sv); assert(nsv) PERL_CALLCONV void Perl_sv_report_used(pTHX); -PERL_CALLCONV void Perl_sv_reset(pTHX_ const char* s, HV* stash) +PERL_CALLCONV void Perl_sv_reset(pTHX_ const char* s, HV *const stash) __attribute__nonnull__(pTHX_1); #define PERL_ARGS_ASSERT_SV_RESET \ assert(s) diff --git a/sv.c b/sv.c index a96e00e..1142045 100644 --- a/sv.c +++ b/sv.c @@ -7265,7 +7265,7 @@ C is a convenience wrapper for this function, defined as */ SV * -Perl_newSVpvn_flags(pTHX_ const char *s, STRLEN len, U32 flags) +Perl_newSVpvn_flags(pTHX_ const char *const s, const STRLEN len, const U32 flags) { dVAR; register SV *sv; @@ -7292,7 +7292,7 @@ and C. */ SV * -Perl_sv_2mortal(pTHX_ register SV *sv) +Perl_sv_2mortal(pTHX_ register SV *const sv) { dVAR; if (!sv) @@ -7316,7 +7316,7 @@ strlen(). For efficiency, consider using C instead. */ SV * -Perl_newSVpv(pTHX_ const char *s, STRLEN len) +Perl_newSVpv(pTHX_ const char *const s, const STRLEN len) { dVAR; register SV *sv; @@ -7338,7 +7338,7 @@ C bytes long. If the C argument is NULL the new SV will be undefined. */ SV * -Perl_newSVpvn(pTHX_ const char *s, STRLEN len) +Perl_newSVpvn(pTHX_ const char *const s, const STRLEN len) { dVAR; register SV *sv; @@ -7359,7 +7359,7 @@ SV if the hek is NULL. */ SV * -Perl_newSVhek(pTHX_ const HEK *hek) +Perl_newSVhek(pTHX_ const HEK *const hek) { dVAR; if (!hek) { @@ -7475,7 +7475,7 @@ Perl_newSVpvn_share(pTHX_ const char *src, I32 len, U32 hash) */ SV * -Perl_newSVpvf_nocontext(const char* pat, ...) +Perl_newSVpvf_nocontext(const char *const pat, ...) { dTHX; register SV *sv; @@ -7500,7 +7500,7 @@ C. */ SV * -Perl_newSVpvf(pTHX_ const char* pat, ...) +Perl_newSVpvf(pTHX_ const char *const pat, ...) { register SV *sv; va_list args; @@ -7516,7 +7516,7 @@ Perl_newSVpvf(pTHX_ const char* pat, ...) /* backend for newSVpvf() and newSVpvf_nocontext() */ SV * -Perl_vnewSVpvf(pTHX_ const char* pat, va_list* args) +Perl_vnewSVpvf(pTHX_ const char *const pat, va_list *const args) { dVAR; register SV *sv; @@ -7538,7 +7538,7 @@ The reference count for the SV is set to 1. */ SV * -Perl_newSVnv(pTHX_ NV n) +Perl_newSVnv(pTHX_ const NV n) { dVAR; register SV *sv; @@ -7558,7 +7558,7 @@ SV is set to 1. */ SV * -Perl_newSViv(pTHX_ IV i) +Perl_newSViv(pTHX_ const IV i) { dVAR; register SV *sv; @@ -7578,7 +7578,7 @@ The reference count for the SV is set to 1. */ SV * -Perl_newSVuv(pTHX_ UV u) +Perl_newSVuv(pTHX_ const UV u) { dVAR; register SV *sv; @@ -7617,7 +7617,7 @@ SV is B incremented. */ SV * -Perl_newRV_noinc(pTHX_ SV *tmpRef) +Perl_newRV_noinc(pTHX_ SV *const tmpRef) { dVAR; register SV *sv = newSV_type(SVt_IV); @@ -7635,7 +7635,7 @@ Perl_newRV_noinc(pTHX_ SV *tmpRef) */ SV * -Perl_newRV(pTHX_ SV *sv) +Perl_newRV(pTHX_ SV *const sv) { dVAR; @@ -7654,7 +7654,7 @@ Creates a new SV which is an exact duplicate of the original SV. */ SV * -Perl_newSVsv(pTHX_ register SV *old) +Perl_newSVsv(pTHX_ register SV *const old) { dVAR; register SV *sv; @@ -7684,7 +7684,7 @@ Note that the perl-level function is vaguely deprecated. */ void -Perl_sv_reset(pTHX_ register const char *s, HV *stash) +Perl_sv_reset(pTHX_ register const char *s, HV *const stash) { dVAR; char todo[PERL_UCHAR_MAX+1]; @@ -7788,7 +7788,7 @@ named after the PV if we're a string. */ IO* -Perl_sv_2io(pTHX_ SV *sv) +Perl_sv_2io(pTHX_ SV *const sv) { IO* io; GV* gv; @@ -7833,7 +7833,7 @@ The flags in C are passed to sv_fetchsv. */ CV * -Perl_sv_2cv(pTHX_ SV *sv, HV **st, GV **gvp, I32 lref) +Perl_sv_2cv(pTHX_ SV *sv, HV **const st, GV **const gvp, const I32 lref) { dVAR; GV *gv = NULL; @@ -7927,7 +7927,7 @@ instead use an in-line version. */ I32 -Perl_sv_true(pTHX_ register SV *sv) +Perl_sv_true(pTHX_ register SV *const sv) { if (!sv) return 0;