diff options
-rw-r--r-- | autodoc.pl | 2 | ||||
-rw-r--r-- | embed.fnc | 69 | ||||
-rwxr-xr-x | embed.pl | 3 | ||||
-rw-r--r-- | hv.c | 7 | ||||
-rw-r--r-- | perl.c | 16 | ||||
-rw-r--r-- | perlio.c | 7 | ||||
-rw-r--r-- | pod/perlapi.pod | 2 | ||||
-rw-r--r-- | pp.c | 449 | ||||
-rw-r--r-- | pp.h | 16 | ||||
-rw-r--r-- | pp_ctl.c | 7 | ||||
-rw-r--r-- | pp_sys.c | 80 | ||||
-rw-r--r-- | proto.h | 91 | ||||
-rw-r--r-- | sv.c | 48 | ||||
-rw-r--r-- | util.c | 4 |
14 files changed, 405 insertions, 396 deletions
diff --git a/autodoc.pl b/autodoc.pl index 4c5c60ff0d..d347e4c95e 100644 --- a/autodoc.pl +++ b/autodoc.pl @@ -53,7 +53,7 @@ sub walk_table (&@) { else { @args = split /\s*\|\s*/, $_; } - s/\bNN\b\s+// for @args; + s/\b(NN|NULLOK)\b\s+//g for @args; print $F $function->(@args); } print $F $trailer if $trailer; @@ -31,6 +31,11 @@ : : Pointer parameters that must not be passed NULLs should be prefixed with NN. : +: Pointer parameters that may be NULL should be prefixed with NULLOK. This has +: no effect on output yet. It's a notation for the maintainers to know "I have +: defined whether NULL is OK or not" rather than having neither NULL or NULLOK, +: which is ambiguous. +: : Individual flags may be separated by whitespace. : : New global functions should be added at the end for binary compatibility @@ -90,7 +95,7 @@ p |OP* |append_list |I32 optype|LISTOP* first|LISTOP* last p |I32 |apply |I32 type|SV** mark|SV** sp ApM |void |apply_attrs_string|const char *stashpv|CV *cv|const char *attrstr|STRLEN len Apd |void |av_clear |AV* ar -ApdR |SV* |av_delete |AV* ar|I32 key|I32 flags +Apd |SV* |av_delete |AV* ar|I32 key|I32 flags ApdR |bool |av_exists |AV* ar|I32 key Apd |void |av_extend |NN AV* ar|I32 key pR |AV* |av_fake |I32 size|NN SV** svp @@ -98,7 +103,7 @@ ApdR |SV** |av_fetch |AV* ar|I32 key|I32 lval Apd |void |av_fill |AV* ar|I32 fill ApdR |I32 |av_len |const AV* ar ApdR |AV* |av_make |I32 size|NN SV** svp -ApdR |SV* |av_pop |AV* ar +Apd |SV* |av_pop |AV* ar Apd |void |av_push |AV* ar|SV* val p |void |av_reify |AV* ar ApdR |SV* |av_shift |AV* ar @@ -265,8 +270,7 @@ Ap |GV* |gv_fetchpv |const char* name|I32 add|I32 sv_type Ap |void |gv_fullname |SV* sv|const GV* gv Apmb |void |gv_fullname3 |SV* sv|const GV* gv|const char* prefix Ap |void |gv_fullname4 |SV* sv|const GV* gv|const char* prefix|bool keepmain -Ap |void |gv_init |NN GV* gv|NN HV* stash|NN const char* name \ - |STRLEN len|int multi +Ap |void |gv_init |NN GV* gv|HV* stash|NN const char* name|STRLEN len|int multi Apd |HV* |gv_stashpv |const char* name|I32 create Apd |HV* |gv_stashpvn |const char* name|U32 namelen|I32 create Apd |HV* |gv_stashsv |SV* sv|I32 create @@ -539,8 +543,8 @@ Apda |SV* |newSVhek |const HEK *hek Apda |SV* |newSVpvn_share |const char* s|I32 len|U32 hash Afpda |SV* |newSVpvf |const char* pat|... Ap |SV* |vnewSVpvf |const char* pat|va_list* args -Apda |SV* |newSVrv |SV* rv|const char* classname -Apda |SV* |newSVsv |SV* old +Apda |SV* |newSVrv |NN SV* rv|NULLOK const char* classname +Apda |SV* |newSVsv |NULLOK SV* old Apa |OP* |newUNOP |I32 type|I32 flags|OP* first Apa |OP* |newWHILEOP |I32 flags|I32 debuggable|LOOP* loop \ |I32 whileline|OP* expr|OP* block|OP* cont \ @@ -767,9 +771,9 @@ Apd |void |sv_magic |NN SV* sv|SV* obj|int how|const char* name \ |I32 namlen Apd |MAGIC *|sv_magicext |NN SV* sv|SV* obj|int how|const MGVTBL *vtbl \ |const char* name|I32 namlen -Apd |SV* |sv_mortalcopy |NN SV* oldsv +ApdaR |SV* |sv_mortalcopy |NULLOK SV* oldsv ApdR |SV* |sv_newmortal -Apd |SV* |sv_newref |SV* sv +Apd |SV* |sv_newref |NULLOK SV* sv Ap |char* |sv_peek |SV* sv Apd |void |sv_pos_u2b |SV* sv|NN I32* offsetp|I32* lenp Apd |void |sv_pos_b2u |SV* sv|NN I32* offsetp @@ -792,9 +796,8 @@ Apd |void |sv_setnv |SV* sv|NV num Apd |SV* |sv_setref_iv |SV* rv|const char* classname|IV iv Apd |SV* |sv_setref_uv |SV* rv|const char* classname|UV uv Apd |SV* |sv_setref_nv |SV* rv|const char* classname|NV nv -Apd |SV* |sv_setref_pv |SV* rv|const char* classname|void* pv -Apd |SV* |sv_setref_pvn |SV* rv|const char* classname|char* pv \ - |STRLEN n +Apd |SV* |sv_setref_pv |SV* rv|const char* classname|NULLOK void* pv +Apd |SV* |sv_setref_pvn |SV* rv|const char* classname|NN const char* pv|STRLEN n Apd |void |sv_setpv |SV* sv|const char* ptr Apd |void |sv_setpvn |NN SV* sv|const char* ptr|STRLEN len Amdb |void |sv_setsv |SV* dsv|SV* ssv @@ -901,19 +904,19 @@ Apd |void |sv_usepvn_mg |SV *sv|char *ptr|STRLEN len Ap |MGVTBL*|get_vtbl |int vtbl_id Ap |char* |pv_display |SV *dsv|const char *pv|STRLEN cur|STRLEN len \ |STRLEN pvlim -Afp |void |dump_indent |I32 level|PerlIO *file|const char* pat|... -Ap |void |dump_vindent |I32 level|PerlIO *file|const char* pat \ +Afp |void |dump_indent |I32 level|NN PerlIO *file|const char* pat|... +Ap |void |dump_vindent |I32 level|NN PerlIO *file|const char* pat \ |va_list *args -Ap |void |do_gv_dump |I32 level|PerlIO *file|const char *name|GV *sv -Ap |void |do_gvgv_dump |I32 level|PerlIO *file|const char *name|GV *sv -Ap |void |do_hv_dump |I32 level|PerlIO *file|const char *name|HV *sv -Ap |void |do_magic_dump |I32 level|PerlIO *file|const MAGIC *mg|I32 nest \ +Ap |void |do_gv_dump |I32 level|NN PerlIO *file|const char *name|GV *sv +Ap |void |do_gvgv_dump |I32 level|NN PerlIO *file|const char *name|GV *sv +Ap |void |do_hv_dump |I32 level|NN PerlIO *file|const char *name|HV *sv +Ap |void |do_magic_dump |I32 level|NN PerlIO *file|const MAGIC *mg|I32 nest \ |I32 maxnest|bool dumpops|STRLEN pvlim -Ap |void |do_op_dump |I32 level|PerlIO *file|const OP *o -Ap |void |do_pmop_dump |I32 level|PerlIO *file|const PMOP *pm -Ap |void |do_sv_dump |I32 level|PerlIO *file|SV *sv|I32 nest \ +Ap |void |do_op_dump |I32 level|NN PerlIO *file|const OP *o +Ap |void |do_pmop_dump |I32 level|NN PerlIO *file|const PMOP *pm +Ap |void |do_sv_dump |I32 level|NN PerlIO *file|NULLOK SV *sv|I32 nest \ |I32 maxnest|bool dumpops|STRLEN pvlim -Ap |void |magic_dump |const MAGIC *mg +Ap |void |magic_dump |NULLOK const MAGIC *mg Ap |void |reginitcolors Apd |char* |sv_2pv_nolen |SV* sv Apd |char* |sv_2pvutf8_nolen|SV* sv @@ -999,8 +1002,8 @@ sa |HE* |new_he s |void |del_he |NN HE *p sa |HEK* |save_hek_flags |NN const char *str|I32 len|U32 hash|int flags s |void |hv_magic_check |NN HV *hv|NN bool *needs_copy|NN bool *needs_store -s |void |unshare_hek_or_pvn|const HEK* hek|const char* str|I32 len|U32 hash -sR |HEK* |share_hek_flags|const char* sv|I32 len|U32 hash|int flags +s |void |unshare_hek_or_pvn|NULLOK const HEK* hek|NULLOK const char* str|I32 len|U32 hash +sR |HEK* |share_hek_flags|NN const char* sv|I32 len|U32 hash|int flags rs |void |hv_notallowed |int flags|NN const char *key|I32 klen|NN const char *msg s |struct xpvhv_aux*|hv_auxinit|NN HV *hv sM |SV* |hv_delete_common|HV* tb|SV* key_sv|const char* key|STRLEN klen|int k_flags|I32 d_flags|U32 hash @@ -1224,15 +1227,15 @@ s |SV* |save_scalar_at |SV **sptr #endif #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) -s |IV |asIV |SV* sv -s |UV |asUV |SV* sv -s |void |sv_unglob |SV* sv -s |void |not_a_number |SV *sv -s |I32 |visit |SVFUNC_t f|U32 flags|U32 mask -s |void |sv_add_backref |SV *tsv|SV *sv -s |void |sv_del_backref |SV *sv -s |SV * |varname |GV *gv|NN const char *gvtype|PADOFFSET targ \ - |SV *keyname|I32 aindex|int subscript_type +sR |IV |asIV |NN SV* sv +sR |UV |asUV |NN SV* sv +s |void |sv_unglob |NN SV* sv +s |void |not_a_number |NN SV *sv +s |I32 |visit |NN SVFUNC_t f|U32 flags|U32 mask +s |void |sv_add_backref |NN SV *tsv|NN SV *sv +s |void |sv_del_backref |NN SV *sv +sR |SV * |varname |NULLOK GV *gv|NN const char *gvtype|PADOFFSET targ \ + |NULLOK SV *keyname|I32 aindex|int subscript_type # ifdef DEBUGGING s |void |del_sv |SV *p # endif @@ -1334,7 +1337,7 @@ s |STRLEN |is_utf8_char_slow|NN const U8 *s|const STRLEN len START_EXTERN_C -Apd |void |sv_setsv_flags |NN SV* dsv|SV* ssv|I32 flags +Apd |void |sv_setsv_flags |NN SV* dsv|NULLOK SV* ssv|I32 flags Apd |void |sv_catpvn_flags|NN SV* sv|NN const char* ptr|STRLEN len|I32 flags Apd |void |sv_catsv_flags |NN SV* dsv|SV* ssv|I32 flags Apd |STRLEN |sv_utf8_upgrade_flags|NN SV *sv|I32 flags @@ -195,6 +195,7 @@ sub write_protos { for my $arg ( @args ) { ++$n; push( @nonnull, $n ) if ( $arg =~ s/\s*\bNN\b\s+// ); + $arg =~ s/\s*\bNULLOK\b\s+//; # strip NULLOK with no effect } $ret .= join ", ", @args; } @@ -953,3 +954,5 @@ my %vfuncs = qw( Perl_dump_indent Perl_dump_vindent Perl_default_protect Perl_vdefault_protect ); + +# ex: set ts=8 sts=4 sw=4 noet: @@ -171,7 +171,7 @@ Perl_he_dup(pTHX_ HE *e, bool shared, CLONE_PARAMS* param) else if (shared) { /* This is hek_dup inlined, which seems to be important for speed reasons. */ - HEK *source = HeKEY_hek(e); + HEK * const source = HeKEY_hek(e); HEK *shared = (HEK*)ptr_table_fetch(PL_ptr_table, source); if (shared) { @@ -198,7 +198,7 @@ static void S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg) { - SV *sv = sv_newmortal(); + SV * const sv = sv_newmortal(); if (!(flags & HVhek_FREEKEY)) { sv_setpvn(sv, key, klen); } @@ -2309,7 +2309,6 @@ Perl_share_hek(pTHX_ const char *str, I32 len, register U32 hash) STATIC HEK * S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags) { - register XPVHV* xhv; register HE *entry; register HE **oentry; I32 found = 0; @@ -2323,7 +2322,7 @@ S_share_hek_flags(pTHX_ const char *str, I32 len, register U32 hash, int flags) Can't rehash the shared string table, so not sure if it's worth counting the number of entries in the linked list */ - xhv = (XPVHV*)SvANY(PL_strtab); + register XPVHV * const xhv = (XPVHV*)SvANY(PL_strtab); /* assert(xhv_array != 0) */ LOCK_STRTAB_MUTEX; oentry = &(HvARRAY(PL_strtab))[hash & (I32) HvMAX(PL_strtab)]; @@ -428,6 +428,7 @@ perl_destruct(pTHXx) int x = 0; JMPENV_PUSH(x); + PERL_UNUSED_VAR(x); if (PL_endav && !PL_minus_c) call_list(PL_scopestack_ix, PL_endav); JMPENV_POP; @@ -1231,15 +1232,10 @@ setuid perl scripts securely.\n"); if (!PL_rehash_seed_set) PL_rehash_seed = get_hash_seed(); { - char *s = PerlEnv_getenv("PERL_HASH_SEED_DEBUG"); + const char *s = PerlEnv_getenv("PERL_HASH_SEED_DEBUG"); - if (s) { - int i = atoi(s); - - if (i == 1) - PerlIO_printf(Perl_debug_log, "HASH_SEED = %"UVuf"\n", - PL_rehash_seed); - } + if (s && (atoi(s) == 1)) + PerlIO_printf(Perl_debug_log, "HASH_SEED = %"UVuf"\n", PL_rehash_seed); } #endif /* #if defined(USE_HASH_SEED) || defined(USE_HASH_SEED_EXPLICIT) */ @@ -1256,10 +1252,10 @@ setuid perl scripts securely.\n"); * --jhi */ const char *s = NULL; int i; - UV mask = + const UV mask = ~(UV)(PTRSIZE == 4 ? 3 : PTRSIZE == 8 ? 7 : PTRSIZE == 16 ? 15 : 0); /* Do the mask check only if the args seem like aligned. */ - UV aligned = + const UV aligned = (mask < ~(UV)0) && ((PTR2UV(argv[0]) & mask) == PTR2UV(argv[0])); /* See if all the arguments are contiguous in memory. Note @@ -650,6 +650,9 @@ PerlIO_clone(pTHX_ PerlInterpreter *proto, CLONE_PARAMS *param) f++; } } +#else + PERL_UNUSED_ARG(proto); + PERL_UNUSED_ARG(param); #endif } @@ -2178,6 +2181,7 @@ PerlIO_sv_dup(pTHX_ SV *arg, CLONE_PARAMS *param) return newSVsv(arg); } #else + PERL_UNUSED_ARG(param); return newSVsv(arg); #endif } @@ -2185,7 +2189,7 @@ PerlIO_sv_dup(pTHX_ SV *arg, CLONE_PARAMS *param) PerlIO * PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags) { - PerlIO *nexto = PerlIONext(o); + PerlIO * const nexto = PerlIONext(o); if (PerlIOValid(nexto)) { const PerlIO_funcs * const tab = PerlIOBase(nexto)->tab; if (tab && tab->Dup) @@ -2545,6 +2549,7 @@ PerlIOUnix_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count) } PERL_ASYNC_CHECK(); } + /*NOTREACHED*/ } Off_t diff --git a/pod/perlapi.pod b/pod/perlapi.pod index c27e4e2dc3..6b603bf774 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -4873,7 +4873,7 @@ of 1, and the RV will be returned. Note that C<sv_setref_pv> copies the pointer while this copies the string. - SV* sv_setref_pvn(SV* rv, const char* classname, char* pv, STRLEN n) + SV* sv_setref_pvn(SV* rv, const char* classname, const char* pv, STRLEN n) =for hackers Found in file sv.c @@ -83,7 +83,7 @@ PP(pp_padav) if (SvMAGICAL(TARG)) { U32 i; for (i=0; i < (U32)maxarg; i++) { - SV **svp = av_fetch((AV*)TARG, i, FALSE); + SV ** const svp = av_fetch((AV*)TARG, i, FALSE); SP[i+1] = (svp) ? *svp : &PL_sv_undef; } } @@ -93,7 +93,7 @@ PP(pp_padav) SP += maxarg; } else if (gimme == G_SCALAR) { - SV* sv = sv_newmortal(); + SV* const sv = sv_newmortal(); const I32 maxarg = AvFILL((AV*)TARG) + 1; sv_setiv(sv, maxarg); PUSHs(sv); @@ -121,7 +121,7 @@ PP(pp_padhv) RETURNOP(do_kv()); } else if (gimme == G_SCALAR) { - SV* sv = Perl_hv_scalar(aTHX_ (HV*)TARG); + SV* const sv = Perl_hv_scalar(aTHX_ (HV*)TARG); SETs(sv); } RETURN; @@ -144,7 +144,7 @@ PP(pp_rv2gv) sv = SvRV(sv); if (SvTYPE(sv) == SVt_PVIO) { - GV *gv = (GV*) sv_newmortal(); + GV * const gv = (GV*) sv_newmortal(); gv_init(gv, 0, "", 0, 0); GvIOp(gv) = (IO *)sv; (void)SvREFCNT_inc(sv); @@ -201,7 +201,7 @@ PP(pp_rv2gv) if ((PL_op->op_flags & OPf_SPECIAL) && !(PL_op->op_flags & OPf_MOD)) { - SV * temp = (SV*)gv_fetchsv(sv, FALSE, SVt_PVGV); + SV * const temp = (SV*)gv_fetchsv(sv, FALSE, SVt_PVGV); if (!temp && (!is_gv_magical_sv(sv,0) || !(sv = (SV*)gv_fetchsv(sv, TRUE, SVt_PVGV)))) { @@ -294,8 +294,8 @@ PP(pp_rv2sv) PP(pp_av2arylen) { dSP; - AV *av = (AV*)TOPs; - SV **sv = Perl_av_arylen_p(aTHX_ (AV*)av); + AV * const av = (AV*)TOPs; + SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av); if (!*sv) { *sv = NEWSV(0,0); sv_upgrade(*sv, SVt_PVMG); @@ -325,10 +325,8 @@ PP(pp_pos) RETURN; } else { - MAGIC* mg; - if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) { - mg = mg_find(sv, PERL_MAGIC_regex_global); + const MAGIC * const mg = mg_find(sv, PERL_MAGIC_regex_global); if (mg && mg->mg_len >= 0) { I32 i = mg->mg_len; if (DO_UTF8(sv)) @@ -504,10 +502,8 @@ S_refto(pTHX_ SV *sv) PP(pp_ref) { dSP; dTARGET; - SV *sv; const char *pv; - - sv = POPs; + SV * const sv = POPs; if (sv && SvGMAGICAL(sv)) mg_get(sv); @@ -515,8 +511,7 @@ PP(pp_ref) if (!sv || !SvROK(sv)) RETPUSHNO; - sv = SvRV(sv); - pv = sv_reftype(sv,TRUE); + pv = sv_reftype(SvRV(sv),TRUE); PUSHp(pv, strlen(pv)); RETURN; } @@ -529,7 +524,7 @@ PP(pp_bless) if (MAXARG == 1) stash = CopSTASH(PL_curcop); else { - SV *ssv = POPs; + SV * const ssv = POPs; STRLEN len; const char *ptr; @@ -548,63 +543,60 @@ PP(pp_bless) PP(pp_gelem) { - GV *gv; - SV *sv; - SV *tmpRef; - const char *elem; dSP; - sv = POPs; - elem = SvPV_nolen_const(sv); - gv = (GV*)POPs; - tmpRef = Nullsv; + SV *sv = POPs; + const char * const elem = SvPV_nolen_const(sv); + GV * const gv = (GV*)POPs; + SV * tmpRef = Nullsv; + sv = Nullsv; if (elem) { /* elem will always be NUL terminated. */ - const char *elem2 = elem + 1; + const char * const second_letter = elem + 1; switch (*elem) { case 'A': - if (strEQ(elem2, "RRAY")) + if (strEQ(second_letter, "RRAY")) tmpRef = (SV*)GvAV(gv); break; case 'C': - if (strEQ(elem2, "ODE")) + if (strEQ(second_letter, "ODE")) tmpRef = (SV*)GvCVu(gv); break; case 'F': - if (strEQ(elem2, "ILEHANDLE")) { + if (strEQ(second_letter, "ILEHANDLE")) { /* finally deprecated in 5.8.0 */ deprecate("*glob{FILEHANDLE}"); tmpRef = (SV*)GvIOp(gv); } else - if (strEQ(elem2, "ORMAT")) + if (strEQ(second_letter, "ORMAT")) tmpRef = (SV*)GvFORM(gv); break; case 'G': - if (strEQ(elem2, "LOB")) + if (strEQ(second_letter, "LOB")) tmpRef = (SV*)gv; break; case 'H': - if (strEQ(elem2, "ASH")) + if (strEQ(second_letter, "ASH")) tmpRef = (SV*)GvHV(gv); break; case 'I': - if (*elem2 == 'O' && !elem[2]) + if (*second_letter == 'O' && !elem[2]) tmpRef = (SV*)GvIOp(gv); break; case 'N': - if (strEQ(elem2, "AME")) + if (strEQ(second_letter, "AME")) sv = newSVpvn(GvNAME(gv), GvNAMELEN(gv)); break; case 'P': - if (strEQ(elem2, "ACKAGE")) { + if (strEQ(second_letter, "ACKAGE")) { const HEK *hek = HvNAME_HEK(GvSTASH(gv)); sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8); } break; case 'S': - if (strEQ(elem2, "CALAR")) + if (strEQ(second_letter, "CALAR")) tmpRef = GvSV(gv); break; } @@ -670,7 +662,7 @@ PP(pp_study) sfirst -= 256; while (--pos >= 0) { - ch = s[pos]; + register const I32 ch = s[pos]; if (sfirst[ch] >= 0) snext[pos] = sfirst[ch] - pos; else @@ -743,9 +735,8 @@ PP(pp_chomp) PP(pp_defined) { dSP; - register SV* sv; + register SV* const sv = POPs; - sv = POPs; if (!sv || !SvANY(sv)) RETPUSHNO; switch (SvTYPE(sv)) { @@ -917,7 +908,7 @@ PP(pp_pow) if (baseuok) { baseuv = SvUVX(TOPm1s); } else { - IV iv = SvIVX(TOPm1s); + const IV iv = SvIVX(TOPm1s); if (iv >= 0) { baseuv = iv; baseuok = TRUE; /* effectively it's a UV now */ @@ -959,7 +950,7 @@ PP(pp_pow) for (; power; base *= base, n++) { /* Do I look like I trust gcc with long longs here? Do I hell. */ - UV bit = (UV)1 << (UV)n; + const UV bit = (UV)1 << (UV)n; if (power & bit) { result *= base; /* Only bother to clear the bit if it is set. */ @@ -991,7 +982,7 @@ PP(pp_pow) register UV base = baseuv; register int n = 0; for (; power; base *= base, n++) { - register UV bit = (UV)1 << (UV)n; + register const UV bit = (UV)1 << (UV)n; if (power & bit) { result *= base; power -= bit; @@ -1054,7 +1045,7 @@ PP(pp_multiply) if (auvok) { alow = SvUVX(TOPm1s); } else { - IV aiv = SvIVX(TOPm1s); + const IV aiv = SvIVX(TOPm1s); if (aiv >= 0) { alow = aiv; auvok = TRUE; /* effectively it's a UV now */ @@ -1065,7 +1056,7 @@ PP(pp_multiply) if (buvok) { blow = SvUVX(TOPs); } else { - IV biv = SvIVX(TOPs); + const IV biv = SvIVX(TOPs); if (biv >= 0) { blow = biv; buvok = TRUE; /* effectively it's a UV now */ @@ -1186,7 +1177,7 @@ PP(pp_divide) right = SvUVX(TOPs); } else { - IV biv = SvIVX(TOPs); + const IV biv = SvIVX(TOPs); if (biv >= 0) { right = biv; right_non_neg = TRUE; /* effectively it's a UV now */ @@ -1207,7 +1198,7 @@ PP(pp_divide) left = SvUVX(TOPm1s); } else { - IV aiv = SvIVX(TOPm1s); + const IV aiv = SvIVX(TOPm1s); if (aiv >= 0) { left = aiv; left_non_neg = TRUE; /* effectively it's a UV now */ @@ -1233,7 +1224,7 @@ PP(pp_divide) #endif ) { /* Integer division can't overflow, but it can be imprecise. */ - UV result = left / right; + const UV result = left / right; if (result * right == left) { SP--; /* result is valid */ if (left_non_neg == right_non_neg) { @@ -1282,7 +1273,7 @@ PP(pp_modulo) if (!right_neg) { right = SvUVX(POPs); } else { - IV biv = SvIVX(POPs); + const IV biv = SvIVX(POPs); if (biv >= 0) { right = biv; right_neg = FALSE; /* effectively it's a UV now */ @@ -1401,7 +1392,7 @@ PP(pp_repeat) mg_get(sv); if (SvIOKp(sv)) { if (SvUOK(sv)) { - UV uv = SvUV(sv); + const UV uv = SvUV(sv); if (uv > IV_MAX) count = IV_MAX; /* The best we can do? */ else @@ -1415,7 +1406,7 @@ PP(pp_repeat) } } else if (SvNOKp(sv)) { - NV nv = SvNV(sv); + const NV nv = SvNV(sv); if (nv < 0.0) count = 0; else @@ -1546,7 +1537,7 @@ PP(pp_subtract) if ((auvok = SvUOK(TOPm1s))) auv = SvUVX(TOPm1s); else { - register IV aiv = SvIVX(TOPm1s); + register const IV aiv = SvIVX(TOPm1s); if (aiv >= 0) { auv = aiv; auvok = 1; /* Now acting as a sign flag. */ @@ -1566,7 +1557,7 @@ PP(pp_subtract) if (buvok) buv = SvUVX(TOPs); else { - register IV biv = SvIVX(TOPs); + register const IV biv = SvIVX(TOPs); if (biv >= 0) { buv = biv; buvok = 1; @@ -1640,7 +1631,7 @@ PP(pp_left_shift) { dSP; dATARGET; tryAMAGICbin(lshift,opASSIGN); { - IV shift = POPi; + const IV shift = POPi; if (PL_op->op_private & HINT_INTEGER) { IV i = TOPi; SETi(i << shift); @@ -1657,7 +1648,7 @@ PP(pp_right_shift) { dSP; dATARGET; tryAMAGICbin(rshift,opASSIGN); { - IV shift = POPi; + const IV shift = POPi; if (PL_op->op_private & HINT_INTEGER) { IV i = TOPi; SETi(i >> shift); @@ -1682,16 +1673,16 @@ PP(pp_lt) bool buvok = SvUOK(TOPs); if (!auvok && !buvok) { /* ## IV < IV ## */ - IV aiv = SvIVX(TOPm1s); - IV biv = SvIVX(TOPs); + const IV aiv = SvIVX(TOPm1s); + const IV biv = SvIVX(TOPs); SP--; SETs(boolSV(aiv < biv)); RETURN; } if (auvok && buvok) { /* ## UV < UV ## */ - UV auv = SvUVX(TOPm1s); - UV buv = SvUVX(TOPs); + const UV auv = SvUVX(TOPm1s); + const UV buv = SvUVX(TOPs); SP--; SETs(boolSV(auv < buv)); @@ -1699,9 +1690,7 @@ PP(pp_lt) } if (auvok) { /* ## UV < IV ## */ UV auv; - IV biv; - - biv = SvIVX(TOPs); + const IV biv = SvIVX(TOPs); SP--; if (biv < 0) { /* As (a) is a UV, it's >=0, so it cannot be < */ @@ -1713,10 +1702,9 @@ PP(pp_lt) RETURN; } { /* ## IV < UV ## */ - IV aiv; + const IV aiv = SvIVX(TOPm1s); UV buv; - aiv = SvIVX(TOPm1s); if (aiv < 0) { /* As (b) is a UV, it's >=0, so it must be < */ SP--; @@ -1760,16 +1748,16 @@ PP(pp_gt) bool buvok = SvUOK(TOPs); if (!auvok && !buvok) { /* ## IV > IV ## */ - IV aiv = SvIVX(TOPm1s); - IV biv = SvIVX(TOPs); - + const IV aiv = SvIVX(TOPm1s); + const IV biv = SvIVX(TOPs); + SP--; SETs(boolSV(aiv > biv)); RETURN; } if (auvok && buvok) { /* ## UV > UV ## */ - UV auv = SvUVX(TOPm1s); - UV buv = SvUVX(TOPs); + const UV auv = SvUVX(TOPm1s); + const UV buv = SvUVX(TOPs); SP--; SETs(boolSV(auv > buv)); @@ -1777,9 +1765,8 @@ PP(pp_gt) } if (auvok) { /* ## UV > IV ## */ UV auv; - IV biv; - - biv = SvIVX(TOPs); + const IV biv = SvIVX(TOPs); + SP--; if (biv < 0) { /* As (a) is a UV, it's >=0, so it must be > */ @@ -1791,10 +1778,9 @@ PP(pp_gt) RETURN; } { /* ## IV > UV ## */ - IV aiv; + const IV aiv = SvIVX(TOPm1s); UV buv; - aiv = SvIVX(TOPm1s); if (aiv < 0) { /* As (b) is a UV, it's >=0, so it cannot be > */ SP--; @@ -1838,8 +1824,8 @@ PP(pp_le) bool buvok = SvUOK(TOPs); if (!auvok && !buvok) { /* ## IV <= IV ## */ - IV aiv = SvIVX(TOPm1s); - IV biv = SvIVX(TOPs); + const IV aiv = SvIVX(TOPm1s); + const IV biv = SvIVX(TOPs); SP--; SETs(boolSV(aiv <= biv)); @@ -1855,9 +1841,8 @@ PP(pp_le) } if (auvok) { /* ## UV <= IV ## */ UV auv; - IV biv; - - biv = SvIVX(TOPs); + const IV biv = SvIVX(TOPs); + SP--; if (biv < 0) { /* As (a) is a UV, it's >=0, so a cannot be <= */ @@ -1869,10 +1854,9 @@ PP(pp_le) RETURN; } { /* ## IV <= UV ## */ - IV aiv; + const IV aiv = SvIVX(TOPm1s); UV buv; - - aiv = SvIVX(TOPm1s); + if (aiv < 0) { /* As (b) is a UV, it's >=0, so a must be <= */ SP--; @@ -1916,26 +1900,25 @@ PP(pp_ge) bool buvok = SvUOK(TOPs); if (!auvok && !buvok) { /* ## IV >= IV ## */ - IV aiv = SvIVX(TOPm1s); - IV biv = SvIVX(TOPs); - + const IV aiv = SvIVX(TOPm1s); + const IV biv = SvIVX(TOPs); + SP--; SETs(boolSV(aiv >= biv)); RETURN; } if (auvok && buvok) { /* ## UV >= UV ## */ - UV auv = SvUVX(TOPm1s); - UV buv = SvUVX(TOPs); - + const UV auv = SvUVX(TOPm1s); + const UV buv = SvUVX(TOPs); + SP--; SETs(boolSV(auv >= buv)); RETURN; } if (auvok) { /* ## UV >= IV ## */ UV auv; - IV biv; - - biv = SvIVX(TOPs); + const IV biv = SvIVX(TOPs); + SP--; if (biv < 0) { /* As (a) is a UV, it's >=0, so it must be >= */ @@ -1947,10 +1930,9 @@ PP(pp_ge) RETURN; } { /* ## IV >= UV ## */ - IV aiv; + const IV aiv = SvIVX(TOPm1s); UV buv; - - aiv = SvIVX(TOPm1s); + if (aiv < 0) { /* As (b) is a UV, it's >=0, so a cannot be >= */ SP--; @@ -2007,9 +1989,9 @@ PP(pp_ne) differ from normal zero. As I understand it. (Need to check - is negative zero implementation defined behaviour anyway?). NWC */ - UV buv = SvUVX(POPs); - UV auv = SvUVX(TOPs); - + const UV buv = SvUVX(POPs); + const UV auv = SvUVX(TOPs); + SETs(boolSV(auv != buv)); RETURN; } @@ -2068,12 +2050,12 @@ PP(pp_ncmp) if (SvIOK(TOPs)) { SvIV_please(TOPm1s); if (SvIOK(TOPm1s)) { - bool leftuvok = SvUOK(TOPm1s); - bool rightuvok = SvUOK(TOPs); + const bool leftuvok = SvUOK(TOPm1s); + const bool rightuvok = SvUOK(TOPs); I32 value; if (!leftuvok && !rightuvok) { /* ## IV <=> IV ## */ - IV leftiv = SvIVX(TOPm1s); - IV rightiv = SvIVX(TOPs); + const IV leftiv = SvIVX(TOPm1s); + const IV rightiv = SvIVX(TOPs); if (leftiv > rightiv) value = 1; @@ -2082,8 +2064,8 @@ PP(pp_ncmp) else value = 0; } else if (leftuvok && rightuvok) { /* ## UV <=> UV ## */ - UV leftuv = SvUVX(TOPm1s); - UV rightuv = SvUVX(TOPs); + const UV leftuv = SvUVX(TOPm1s); + const UV rightuv = SvUVX(TOPs); if (leftuv > rightuv) value = 1; @@ -2092,15 +2074,12 @@ PP(pp_ncmp) else value = 0; } else if (leftuvok) { /* ## UV <=> IV ## */ - UV leftuv; - IV rightiv; - - rightiv = SvIVX(TOPs); + const IV rightiv = SvIVX(TOPs); if (rightiv < 0) { /* As (a) is a UV, it's >=0, so it cannot be < */ value = 1; } else { - leftuv = SvUVX(TOPm1s); + const UV leftuv = SvUVX(TOPm1s); if (leftuv > (UV)rightiv) { value = 1; } else if (leftuv < (UV)rightiv) { @@ -2110,15 +2089,12 @@ PP(pp_ncmp) } } } else { /* ## IV <=> UV ## */ - IV leftiv; - UV rightuv; - - leftiv = SvIVX(TOPm1s); + const IV leftiv = SvIVX(TOPm1s); if (leftiv < 0) { /* As (b) is a UV, it's >=0, so it must be < */ value = -1; } else { - rightuv = SvUVX(TOPs); + const UV rightuv = SvUVX(TOPs); if ((UV)leftiv > rightuv) { value = 1; } else if ((UV)leftiv < rightuv) { @@ -2166,7 +2142,7 @@ PP(pp_slt) dSP; tryAMAGICbinSET(slt,0); { dPOPTOPssrl; - int cmp = (IN_LOCALE_RUNTIME + const int cmp = (IN_LOCALE_RUNTIME ? sv_cmp_locale(left, right) : sv_cmp(left, right)); SETs(boolSV(cmp < 0)); @@ -2179,7 +2155,7 @@ PP(pp_sgt) dSP; tryAMAGICbinSET(sgt,0); { dPOPTOPssrl; - int cmp = (IN_LOCALE_RUNTIME + const int cmp = (IN_LOCALE_RUNTIME ? sv_cmp_locale(left, right) : sv_cmp(left, right)); SETs(boolSV(cmp > 0)); @@ -2192,7 +2168,7 @@ PP(pp_sle) dSP; tryAMAGICbinSET(sle,0); { dPOPTOPssrl; - int cmp = (IN_LOCALE_RUNTIME + const int cmp = (IN_LOCALE_RUNTIME ? sv_cmp_locale(left, right) : sv_cmp(left, right)); SETs(boolSV(cmp <= 0)); @@ -2205,7 +2181,7 @@ PP(pp_sge) dSP; tryAMAGICbinSET(sge,0); { dPOPTOPssrl; - int cmp = (IN_LOCALE_RUNTIME + const int cmp = (IN_LOCALE_RUNTIME ? sv_cmp_locale(left, right) : sv_cmp(left, right)); SETs(boolSV(cmp >= 0)); @@ -2238,7 +2214,7 @@ PP(pp_scmp) dSP; dTARGET; tryAMAGICbin(scmp,0); { dPOPTOPssrl; - int cmp = (IN_LOCALE_RUNTIME + const int cmp = (IN_LOCALE_RUNTIME ? sv_cmp_locale(left, right) : sv_cmp(left, right)); SETi( cmp ); @@ -2255,11 +2231,11 @@ PP(pp_bit_and) if (SvGMAGICAL(right)) mg_get(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - IV i = SvIV_nomg(left) & SvIV_nomg(right); + const IV i = SvIV_nomg(left) & SvIV_nomg(right); SETi(i); } else { - UV u = SvUV_nomg(left) & SvUV_nomg(right); + const UV u = SvUV_nomg(left) & SvUV_nomg(right); SETu(u); } } @@ -2280,11 +2256,11 @@ PP(pp_bit_xor) if (SvGMAGICAL(right)) mg_get(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right); + const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right); SETi(i); } else { - UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) ^ SvUV_nomg(right); + const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) ^ SvUV_nomg(right); SETu(u); } } @@ -2305,11 +2281,11 @@ PP(pp_bit_or) if (SvGMAGICAL(right)) mg_get(right); if (SvNIOKp(left) || SvNIOKp(right)) { if (PL_op->op_private & HINT_INTEGER) { - IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right); + const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right); SETi(i); } else { - UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) | SvUV_nomg(right); + const UV u = (USE_LEFT(left) ? SvUV_nomg(left) : 0) | SvUV_nomg(right); SETu(u); } } @@ -2326,7 +2302,7 @@ PP(pp_negate) dSP; dTARGET; tryAMAGICun(neg); { dTOPss; - int flags = SvFLAGS(sv); + const int flags = SvFLAGS(sv); if (SvGMAGICAL(sv)) mg_get(sv); if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) { @@ -2408,11 +2384,11 @@ PP(pp_complement) mg_get(sv); if (SvNIOKp(sv)) { if (PL_op->op_private & HINT_INTEGER) { - IV i = ~SvIV_nomg(sv); + const IV i = ~SvIV_nomg(sv); SETi(i); } else { - UV u = ~SvUV_nomg(sv); + const UV u = ~SvUV_nomg(sv); SETu(u); } } @@ -2436,7 +2412,7 @@ PP(pp_complement) send = tmps + len; while (tmps < send) { - UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV); + const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV); tmps += UTF8SKIP(tmps); targlen += UNISKIP(~c); nchar++; @@ -2450,7 +2426,7 @@ PP(pp_complement) if (nwide) { Newz(0, result, targlen + 1, U8); while (tmps < send) { - UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV); + const UV c = utf8n_to_uvchr(tmps, send-tmps, &l, UTF8_ALLOW_ANYUV); tmps += UTF8SKIP(tmps); result = uvchr_to_utf8_flags(result, ~c, UNICODE_ALLOW_ANY); } @@ -2462,7 +2438,7 @@ PP(pp_complement) else { Newz(0, result, nchar + 1, U8); while (tmps < send) { - U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY); + const U8 c = (U8)utf8n_to_uvchr(tmps, 0, &l, UTF8_ALLOW_ANY); tmps += UTF8SKIP(tmps); *result++ = ~c; } @@ -2713,10 +2689,8 @@ PP(pp_sin) { dSP; dTARGET; tryAMAGICun(sin); { - NV value; - value = POPn; - value = Perl_sin(value); - XPUSHn(value); + const NV value = POPn; + XPUSHn(Perl_sin(value)); RETURN; } } @@ -2725,10 +2699,8 @@ PP(pp_cos) { dSP; dTARGET; tryAMAGICun(cos); { - NV value; - value = POPn; - value = Perl_cos(value); - XPUSHn(value); + const NV value = POPn; + XPUSHn(Perl_cos(value)); RETURN; } } @@ -2797,14 +2769,12 @@ PP(pp_log) { dSP; dTARGET; tryAMAGICun(log); { - NV value; - value = POPn; + const NV value = POPn; if (value <= 0.0) { SET_NUMERIC_STANDARD(); DIE(aTHX_ "Can't take log of %"NVgf, value); } - value = Perl_log(value); - XPUSHn(value); + XPUSHn(Perl_log(value)); RETURN; } } @@ -2813,14 +2783,12 @@ PP(pp_sqrt) { dSP; dTARGET; tryAMAGICun(sqrt); { - NV value; - value = POPn; + const NV value = POPn; if (value < 0.0) { SET_NUMERIC_STANDARD(); DIE(aTHX_ "Can't take sqrt of %"NVgf, value); } - value = Perl_sqrt(value); - XPUSHn(value); + XPUSHn(Perl_sqrt(value)); RETURN; } } @@ -2829,8 +2797,7 @@ PP(pp_int) { dSP; dTARGET; tryAMAGICun(int); { - NV value; - IV iv = TOPi; /* attempt to convert to IV if possible. */ + const IV iv = TOPi; /* attempt to convert to IV if possible. */ /* XXX it's arguable that compiler casting to IV might be subtly different from modf (for numbers inside (IV_MIN,UV_MAX)) in which else preferring IV has introduced a subtle behaviour change bug. OTOH @@ -2840,12 +2807,12 @@ PP(pp_int) SETu(0); else if (SvIOK(TOPs)) { if (SvIsUV(TOPs)) { - UV uv = TOPu; + const UV uv = TOPu; SETu(uv); } else SETi(iv); } else { - value = TOPn; + const NV value = TOPn; if (value >= 0.0) { if (value < (NV)UV_MAX + 0.5) { SETu(U_V(value)); @@ -2870,7 +2837,7 @@ PP(pp_abs) dSP; dTARGET; tryAMAGICun(abs); { /* This will cache the NV value if string isn't actually integer */ - IV iv = TOPi; + const IV iv = TOPi; if (!SvOK(TOPs)) SETu(0); @@ -2892,10 +2859,11 @@ PP(pp_abs) } } } else{ - NV value = TOPn; + const NV value = TOPn; if (value < 0.0) - value = -value; - SETn(value); + SETn(value); + else + SETn(-value); } } RETURN; @@ -2910,13 +2878,13 @@ PP(pp_hex) STRLEN len; NV result_nv; UV result_uv; - SV* sv = POPs; + SV* const sv = POPs; tmps = (SvPV_const(sv, len)); if (DO_UTF8(sv)) { /* If Unicode, try to downgrade * If not possible, croak. */ - SV* tsv = sv_2mortal(newSVsv(sv)); + SV* const tsv = sv_2mortal(newSVsv(sv)); SvUTF8_on(tsv); sv_utf8_downgrade(tsv, FALSE); @@ -2940,13 +2908,13 @@ PP(pp_oct) STRLEN len; NV result_nv; UV result_uv; - SV* sv = POPs; + SV* const sv = POPs; tmps = (SvPV_const(sv, len)); if (DO_UTF8(sv)) { /* If Unicode, try to downgrade * If not possible, croak. */ - SV* tsv = sv_2mortal(newSVsv(sv)); + SV* const tsv = sv_2mortal(newSVsv(sv)); SvUTF8_on(tsv); sv_utf8_downgrade(tsv, FALSE); @@ -3002,7 +2970,7 @@ PP(pp_substr) SV *repl_sv = NULL; const char *repl = 0; STRLEN repl_len; - int num_args = PL_op->op_private & 7; + const int num_args = PL_op->op_private & 7; bool repl_need_utf8_upgrade = FALSE; bool repl_is_utf8 = FALSE; @@ -3079,8 +3047,8 @@ PP(pp_substr) RETPUSHUNDEF; } else { - I32 upos = pos; - I32 urem = rem; + const I32 upos = pos; + const I32 urem = rem; if (utf8_curlen) sv_pos_u2b(sv, &pos, &rem); tmps += pos; @@ -3157,10 +3125,10 @@ PP(pp_substr) PP(pp_vec) { dSP; dTARGET; - register IV size = POPi; - register IV offset = POPi; - register SV *src = POPs; - I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET; + register const IV size = POPi; + register const IV offset = POPi; + register SV * const src = POPs; + const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET; SvTAINTED_off(TARG); /* decontaminate */ if (lvalue) { /* it's an lvalue! */ @@ -3196,7 +3164,7 @@ PP(pp_index) const char *tmps; const char *tmps2; STRLEN biglen; - I32 arybase = PL_curcop->cop_arybase; + const I32 arybase = PL_curcop->cop_arybase; int big_utf8; int little_utf8; @@ -3210,9 +3178,9 @@ PP(pp_index) little_utf8 = DO_UTF8(little); if (big_utf8 ^ little_utf8) { /* One needs to be upgraded. */ - SV *bytes = little_utf8 ? big : little; + SV * const bytes = little_utf8 ? big : little; STRLEN len; - const char *p = SvPV_const(bytes, len); + const char * const p = SvPV_const(bytes, len); temp = newSVpvn(p, len); @@ -3260,7 +3228,7 @@ PP(pp_rindex) I32 retval; const char *tmps; const char *tmps2; - I32 arybase = PL_curcop->cop_arybase; + const I32 arybase = PL_curcop->cop_arybase; int big_utf8; int little_utf8; @@ -3272,7 +3240,7 @@ PP(pp_rindex) little_utf8 = DO_UTF8(little); if (big_utf8 ^ little_utf8) { /* One needs to be upgraded. */ - SV *bytes = little_utf8 ? big : little; + SV * const bytes = little_utf8 ? big : little; STRLEN len; const char *p = SvPV_const(bytes, len); @@ -3418,7 +3386,7 @@ PP(pp_crypt) /* If Unicode, try to downgrade. * If not possible, croak. * Yes, we made this up. */ - SV* tsv = sv_2mortal(newSVsv(left)); + SV* const tsv = sv_2mortal(newSVsv(left)); SvUTF8_on(tsv); sv_utf8_downgrade(tsv, FALSE); @@ -3689,8 +3657,8 @@ PP(pp_lc) d = (U8*)SvPVX(TARG); send = s + len; while (s < send) { - STRLEN u = UTF8SKIP(s); - UV uv = toLOWER_utf8(s, tmpbuf, &ulen); + const STRLEN u = UTF8SKIP(s); + const UV uv = toLOWER_utf8(s, tmpbuf, &ulen); #define GREEK_CAPITAL_LETTER_SIGMA 0x03A3 /* Unicode U+03A3 */ if (uv == GREEK_CAPITAL_LETTER_SIGMA) { @@ -3745,7 +3713,7 @@ PP(pp_lc) s = (U8*)SvPV_force_nomg(sv, len); if (len) { - register U8 *send = s + len; + register const U8 * const send = s + len; if (IN_LOCALE_RUNTIME) { TAINT; @@ -3766,13 +3734,13 @@ PP(pp_lc) PP(pp_quotemeta) { dSP; dTARGET; - SV *sv = TOPs; + SV * const sv = TOPs; STRLEN len; const register char *s = SvPV_const(sv,len); - register char *d; SvUTF8_off(TARG); /* decontaminate */ if (len) { + register char *d; SvUPGRADE(TARG, SVt_PV); SvGROW(TARG, (len * 2) + 1); d = SvPVX(TARG); @@ -3819,17 +3787,16 @@ PP(pp_quotemeta) PP(pp_aslice) { dSP; dMARK; dORIGMARK; - register SV** svp; - register AV* av = (AV*)POPs; - register I32 lval = (PL_op->op_flags & OPf_MOD || LVRET); - I32 arybase = PL_curcop->cop_arybase; - I32 elem; + register AV* const av = (AV*)POPs; + register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET); if (SvTYPE(av) == SVt_PVAV) { + const I32 arybase = PL_curcop->cop_arybase; if (lval && PL_op->op_private & OPpLVAL_INTRO) { + register SV **svp; I32 max = -1; for (svp = MARK + 1; svp <= SP; svp++) { - elem = SvIVx(*svp); + const I32 elem = SvIVx(*svp); if (elem > max) max = elem; } @@ -3837,7 +3804,8 @@ PP(pp_aslice) av_extend(av, max); } while (++MARK <= SP) { - elem = SvIVx(*MARK); + register SV **svp; + I32 elem = SvIVx(*MARK); if (elem > 0) elem -= arybase; @@ -3864,7 +3832,7 @@ PP(pp_aslice) PP(pp_each) { dSP; - HV *hash = (HV*)POPs; + HV * const hash = (HV*)POPs; HE *entry; const I32 gimme = GIMME_V; @@ -3875,7 +3843,7 @@ PP(pp_each) EXTEND(SP, 2); if (entry) { - SV* sv = hv_iterkeysv(entry); + SV* const sv = hv_iterkeysv(entry); PUSHs(sv); /* won't clobber stack_sp */ if (gimme == G_ARRAY) { SV *val; @@ -3907,24 +3875,21 @@ PP(pp_delete) dSP; const I32 gimme = GIMME_V; const I32 discard = (gimme == G_VOID) ? G_DISCARD : 0; - SV *sv; - HV *hv; if (PL_op->op_private & OPpSLICE) { dMARK; dORIGMARK; - U32 hvtype; - hv = (HV*)POPs; - hvtype = SvTYPE(hv); + HV * const hv = (HV*)POPs; + const U32 hvtype = SvTYPE(hv); if (hvtype == SVt_PVHV) { /* hash element */ while (++MARK <= SP) { - sv = hv_delete_ent(hv, *MARK, discard, 0); + SV * const sv = hv_delete_ent(hv, *MARK, discard, 0); *MARK = sv ? sv : &PL_sv_undef; } } else if (hvtype == SVt_PVAV) { /* array element */ if (PL_op->op_flags & OPf_SPECIAL) { while (++MARK <= SP) { - sv = av_delete((AV*)hv, SvIV(*MARK), discard); + SV * const sv = av_delete((AV*)hv, SvIV(*MARK), discard); *MARK = sv ? sv : &PL_sv_undef; } } @@ -3944,7 +3909,8 @@ PP(pp_delete) } else { SV *keysv = POPs; - hv = (HV*)POPs; + HV * const hv = (HV*)POPs; + SV *sv; if (SvTYPE(hv) == SVt_PVHV) sv = hv_delete_ent(hv, keysv, discard, 0); else if (SvTYPE(hv) == SVt_PVAV) { @@ -3971,9 +3937,8 @@ PP(pp_exists) if (PL_op->op_private & OPpEXISTS_SUB) { GV *gv; - CV *cv; SV *sv = POPs; - cv = sv_2cv(sv, &hv, &gv, FALSE); + CV * const cv = sv_2cv(sv, &hv, &gv, FALSE); if (cv) RETPUSHYES; if (gv && isGV(gv) && GvCV(gv) && !GvCVGEN(gv)) @@ -4001,9 +3966,9 @@ PP(pp_exists) PP(pp_hslice) { dSP; dMARK; dORIGMARK; - register HV *hv = (HV*)POPs; - register I32 lval = (PL_op->op_flags & OPf_MOD || LVRET); - bool localizing = PL_op->op_private & OPpLVAL_INTRO ? TRUE : FALSE; + register HV * const hv = (HV*)POPs; + register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET); + const bool localizing = PL_op->op_private & OPpLVAL_INTRO; bool other_magic = FALSE; if (localizing) { @@ -4021,7 +3986,7 @@ PP(pp_hslice) } while (++MARK <= SP) { - SV *keysv = *MARK; + SV * const keysv = *MARK; SV **svp; HE *he; bool preeminent = FALSE; @@ -4076,20 +4041,18 @@ PP(pp_list) PP(pp_lslice) { dSP; - SV **lastrelem = PL_stack_sp; - SV **lastlelem = PL_stack_base + POPMARK; - SV **firstlelem = PL_stack_base + POPMARK + 1; - register SV **firstrelem = lastlelem + 1; - I32 arybase = PL_curcop->cop_arybase; - I32 lval = PL_op->op_flags & OPf_MOD; - I32 is_something_there = lval; - - register I32 max = lastrelem - lastlelem; + SV ** const lastrelem = PL_stack_sp; + SV ** const lastlelem = PL_stack_base + POPMARK; + SV ** const firstlelem = PL_stack_base + POPMARK + 1; + register SV ** const firstrelem = lastlelem + 1; + const I32 arybase = PL_curcop->cop_arybase; + I32 is_something_there = PL_op->op_flags & OPf_MOD; + + register const I32 max = lastrelem - lastlelem; register SV **lelem; - register I32 ix; if (GIMME != G_ARRAY) { - ix = SvIVx(*lastlelem); + I32 ix = SvIVx(*lastlelem); if (ix < 0) ix += max; else @@ -4108,7 +4071,7 @@ PP(pp_lslice) } for (lelem = firstlelem; lelem <= lastlelem; lelem++) { - ix = SvIVx(*lelem); + I32 ix = SvIVx(*lelem); if (ix < 0) ix += max; else @@ -4131,8 +4094,8 @@ PP(pp_lslice) PP(pp_anonlist) { dSP; dMARK; dORIGMARK; - I32 items = SP - MARK; - SV *av = sv_2mortal((SV*)av_make(items, MARK+1)); + const I32 items = SP - MARK; + SV * const av = sv_2mortal((SV*)av_make(items, MARK+1)); SP = ORIGMARK; /* av_make() might realloc stack_sp */ XPUSHs(av); RETURN; @@ -4141,11 +4104,11 @@ PP(pp_anonlist) PP(pp_anonhash) { dSP; dMARK; dORIGMARK; - HV* hv = (HV*)sv_2mortal((SV*)newHV()); + HV* const hv = (HV*)sv_2mortal((SV*)newHV()); while (MARK < SP) { - SV* key = *++MARK; - SV *val = NEWSV(46, 0); + SV * const key = *++MARK; + SV * const val = NEWSV(46, 0); if (MARK < SP) sv_setsv(val, *++MARK); else if (ckWARN(WARN_MISC)) @@ -4170,9 +4133,9 @@ PP(pp_splice) I32 after; I32 diff; SV **tmparyval = 0; - MAGIC *mg; + const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); - if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) { + if (mg) { *MARK-- = SvTIED_obj((SV*)ary, mg); PUSHMARK(MARK); PUTBACK; @@ -4230,7 +4193,7 @@ PP(pp_splice) /* make new elements SVs now: avoid problems if they're from the array */ for (dst = MARK, i = newlen; i; i--) { - SV *h = *dst; + SV * const h = *dst; *dst++ = newSVsv(h); } @@ -4368,10 +4331,9 @@ PP(pp_push) { dVAR; dSP; dMARK; dORIGMARK; dTARGET; register AV *ary = (AV*)*++MARK; - register SV *sv = &PL_sv_undef; - MAGIC *mg; + const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); - if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) { + if (mg) { *MARK-- = SvTIED_obj((SV*)ary, mg); PUSHMARK(MARK); PUTBACK; @@ -4383,7 +4345,7 @@ PP(pp_push) else { /* Why no pre-extend of ary here ? */ for (++MARK; MARK <= SP; MARK++) { - sv = NEWSV(51, 0); + SV * const sv = NEWSV(51, 0); if (*MARK) sv_setsv(sv, *MARK); av_push(ary, sv); @@ -4397,8 +4359,8 @@ PP(pp_push) PP(pp_pop) { dSP; - AV *av = (AV*)POPs; - SV *sv = av_pop(av); + AV * const av = (AV*)POPs; + SV * const sv = av_pop(av); if (AvREAL(av)) (void)sv_2mortal(sv); PUSHs(sv); @@ -4408,8 +4370,8 @@ PP(pp_pop) PP(pp_shift) { dSP; - AV *av = (AV*)POPs; - SV *sv = av_shift(av); + AV * const av = (AV*)POPs; + SV * const sv = av_shift(av); EXTEND(SP, 1); if (!sv) RETPUSHUNDEF; @@ -4423,11 +4385,9 @@ PP(pp_unshift) { dVAR; dSP; dMARK; dORIGMARK; dTARGET; register AV *ary = (AV*)*++MARK; - register SV *sv; - register I32 i = 0; - MAGIC *mg; + const MAGIC * const mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied); - if ((mg = SvTIED_mg((SV*)ary, PERL_MAGIC_tied))) { + if (mg) { *MARK-- = SvTIED_obj((SV*)ary, mg); PUSHMARK(MARK); PUTBACK; @@ -4437,9 +4397,10 @@ PP(pp_unshift) SPAGAIN; } else { + register I32 i = 0; av_unshift(ary, SP - MARK); while (MARK < SP) { - sv = newSVsv(*++MARK); + SV * const sv = newSVsv(*++MARK); (void)av_store(ary, i++, sv); } } @@ -4451,13 +4412,12 @@ PP(pp_unshift) PP(pp_reverse) { dSP; dMARK; - register SV *tmp; - SV **oldsp = SP; + SV ** const oldsp = SP; if (GIMME == G_ARRAY) { MARK++; while (MARK < SP) { - tmp = *MARK; + register SV * const tmp = *MARK; *MARK++ = *SP; *SP-- = tmp; } @@ -4526,10 +4486,10 @@ PP(pp_split) dVAR; dSP; dTARG; AV *ary; register IV limit = POPi; /* note, negative is forever */ - SV *sv = POPs; + SV * const sv = POPs; STRLEN len; register const char *s = SvPV_const(sv, len); - bool do_utf8 = DO_UTF8(sv); + const bool do_utf8 = DO_UTF8(sv); const char *strend = s + len; register PMOP *pm; register REGEXP *rx; @@ -4538,9 +4498,8 @@ PP(pp_split) I32 iters = 0; const STRLEN slen = do_utf8 ? utf8_length((U8*)s, (U8*)strend) : (strend - s); I32 maxiters = slen + 10; - I32 i; const char *orig; - I32 origlimit = limit; + const I32 origlimit = limit; I32 realarray = 0; I32 base; const I32 gimme = GIMME_V; @@ -4586,6 +4545,7 @@ PP(pp_split) } else { if (!AvREAL(ary)) { + I32 i; AvREAL_on(ary); AvREIFY_off(ary); for (i = AvFILLp(ary); i >= 0; i--) @@ -4658,12 +4618,12 @@ PP(pp_split) (rx->reganch & RE_USE_INTUIT) && !rx->nparens && (rx->reganch & ROPT_CHECK_ALL) && !(rx->reganch & ROPT_ANCH)) { - int tail = (rx->reganch & RE_INTUIT_TAIL); - SV *csv = CALLREG_INTUIT_STRING(aTHX_ rx); + const int tail = (rx->reganch & RE_INTUIT_TAIL); + SV * const csv = CALLREG_INTUIT_STRING(aTHX_ rx); len = rx->minlen; if (len == 1 && !(rx->reganch & ROPT_UTF8) && !tail) { - char c = *SvPV_nolen_const(csv); + const char c = *SvPV_nolen_const(csv); while (--limit) { for (m = s; m < strend && *m != c; m++) ; @@ -4707,11 +4667,12 @@ PP(pp_split) maxiters += slen * rx->nparens; while (s < strend && --limit) { + I32 rex_return; PUTBACK; - i = CALLREGEXEC(aTHX_ rx, (char*)s, (char*)strend, (char*)orig, 1 , + rex_return = CALLREGEXEC(aTHX_ rx, (char*)s, (char*)strend, (char*)orig, 1 , sv, NULL, 0); SPAGAIN; - if (i == 0) + if (rex_return == 0) break; TAINT_IF(RX_MATCH_TAINTED(rx)); if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) { @@ -4729,6 +4690,7 @@ PP(pp_split) (void)SvUTF8_on(dstr); XPUSHs(dstr); if (rx->nparens) { + I32 i; for (i = 1; i <= (I32)rx->nparens; i++) { s = rx->startp[i] + orig; m = rx->endp[i] + orig; @@ -4758,7 +4720,7 @@ PP(pp_split) /* keep field after final delim? */ if (s < strend || (iters && origlimit)) { - STRLEN l = strend - s; + const STRLEN l = strend - s; dstr = newSVpvn(s, l); if (make_mortal) sv_2mortal(dstr); @@ -4800,6 +4762,7 @@ PP(pp_split) LEAVE; SPAGAIN; if (gimme == G_ARRAY) { + I32 i; /* EXTEND should not be needed - we just popped them */ EXTEND(SP, iters); for (i=0; i < iters; i++) { @@ -283,8 +283,8 @@ and C<PUSHu>. } } STMT_END /* Same thing, but update mark register too. */ -#define MEXTEND(p,n) STMT_START {if (PL_stack_max - p < (int)(n)) { \ - int markoff = mark - PL_stack_base; \ +#define MEXTEND(p,n) STMT_START {if (PL_stack_max - p < (int)(n)) { \ + const int markoff = mark - PL_stack_base; \ sp = stack_grow(sp,p,(int) (n)); \ mark = PL_stack_base + markoff; \ } } STMT_END @@ -401,7 +401,7 @@ and C<PUSHu>. #define tryAMAGICbinW(meth,assign,set) STMT_START { \ if (PL_amagic_generation) { \ SV* tmpsv; \ - SV* right= *(sp); SV* left= *(sp-1);\ + SV* const right= *(sp); SV* const left= *(sp-1);\ if ((SvAMAGIC(left)||SvAMAGIC(right))&&\ (tmpsv=amagic_call(left, \ right, \ @@ -483,3 +483,13 @@ True if this op will be the return value of an lvalue subroutine =cut */ #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub()) + +/* + * Local variables: + * c-indentation-style: bsd + * c-basic-offset: 4 + * indent-tabs-mode: t + * End: + * + * ex: set ts=8 sts=4 sw=4 noet: + */ @@ -1374,6 +1374,7 @@ Perl_dounwind(pTHX_ I32 cxix) } cxstack_ix--; } + PERL_UNUSED_VAR(optype); } void @@ -2068,6 +2069,7 @@ PP(pp_last) dounwind(cxix); POPBLOCK(cx,newpm); + PERL_UNUSED_VAR(optype); cxstack_ix++; /* temporarily protect top context */ mark = newsp; switch (CxTYPE(cx)) { @@ -2380,6 +2382,9 @@ PP(pp_goto) PUSHMARK(mark); PUTBACK; (void)(*CvXSUB(cv))(aTHX_ cv); + /* Put these at the bottom since the vars are set but not used */ + PERL_UNUSED_VAR(newsp); + PERL_UNUSED_VAR(gimme); } LEAVE; return retop; @@ -2857,7 +2862,7 @@ Perl_find_runcv(pTHX_ U32 *db_seqp) for (ix = si->si_cxix; ix >= 0; ix--) { const PERL_CONTEXT *cx = &(si->si_cxstack[ix]); if (CxTYPE(cx) == CXt_SUB || CxTYPE(cx) == CXt_FORMAT) { - CV *cv = cx->blk_sub.cv; + CV * const cv = cx->blk_sub.cv; /* skip DB:: code */ if (db_seqp && PL_debstash && CvSTASH(cv) == PL_debstash) { *db_seqp = cx->blk_oldcop->cop_seq; @@ -321,7 +321,7 @@ PP(pp_backtick) { dSP; dTARGET; PerlIO *fp; - const char *tmps = POPpconstx; + const char * const tmps = POPpconstx; const I32 gimme = GIMME_V; const char *mode = "r"; @@ -356,10 +356,8 @@ PP(pp_backtick) SvTAINTED_on(TARG); } else { - SV *sv; - for (;;) { - sv = NEWSV(56, 79); + SV * const sv = NEWSV(56, 79); if (sv_gets(sv, fp, 0) == Nullch) { SvREFCNT_dec(sv); break; @@ -445,7 +443,7 @@ PP(pp_warn) } tmps = SvPV_const(tmpsv, len); if ((!tmps || !len) && PL_errgv) { - SV *error = ERRSV; + SV * const error = ERRSV; SvUPGRADE(error, SVt_PV); if (SvPOK(error) && SvCUR(error)) sv_catpv(error, "\t...caught"); @@ -882,7 +880,7 @@ PP(pp_untie) RETPUSHYES; if ((mg = SvTIED_mg(sv, how))) { - SV *obj = SvRV(SvTIED_obj(sv, mg)); + SV * const obj = SvRV(SvTIED_obj(sv, mg)); GV *gv; CV *cv = NULL; if (obj) { @@ -912,7 +910,7 @@ PP(pp_untie) PP(pp_tied) { dSP; - MAGIC *mg; + const MAGIC *mg; SV *sv = POPs; const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) ? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar; @@ -933,13 +931,12 @@ PP(pp_tied) PP(pp_dbmopen) { dVAR; dSP; - HV *hv; dPOPPOPssrl; HV* stash; GV *gv; SV *sv; - hv = (HV*)POPs; + HV * const hv = (HV*)POPs; sv = sv_mortalcopy(&PL_sv_no); sv_setpv(sv, "AnyDBM_File"); @@ -1181,7 +1178,7 @@ PP(pp_select) if (! hv) XPUSHs(&PL_sv_undef); else { - GV **gvp = (GV**)hv_fetch(hv, GvNAME(egv), GvNAMELEN(egv), FALSE); + GV ** const gvp = (GV**)hv_fetch(hv, GvNAME(egv), GvNAMELEN(egv), FALSE); if (gvp && *gvp == egv) { gv_efullname4(TARG, PL_defoutgv, Nullch, TRUE); XPUSHTARG; @@ -1203,14 +1200,9 @@ PP(pp_select) PP(pp_getc) { dVAR; dSP; dTARGET; - GV *gv; IO *io = NULL; MAGIC *mg; - - if (MAXARG == 0) - gv = PL_stdingv; - else - gv = (GV*)POPs; + GV * const gv = (MAXARG==0) ? PL_stdingv : (GV*)POPs; if (gv && (io = GvIO(gv)) && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) @@ -1322,13 +1314,15 @@ PP(pp_enterwrite) PP(pp_leavewrite) { dVAR; dSP; - GV *gv = cxstack[cxstack_ix].blk_sub.gv; - register IO *io = GvIOp(gv); - PerlIO *ofp = IoOFP(io); + GV * const gv = cxstack[cxstack_ix].blk_sub.gv; + register IO * const io = GvIOp(gv); + PerlIO * const ofp = IoOFP(io); PerlIO *fp; SV **newsp; I32 gimme; register PERL_CONTEXT *cx; + PERL_UNUSED_VAR(newsp); + PERL_UNUSED_VAR(gimme); DEBUG_f(PerlIO_printf(Perl_debug_log, "left=%ld, todo=%ld\n", (long)IoLINES_LEFT(io), (long)FmLINES(PL_formtarget))); @@ -1341,9 +1335,9 @@ PP(pp_leavewrite) CV *cv; if (!IoTOP_GV(io)) { GV *topgv; - SV *topname; if (!IoTOP_NAME(io)) { + SV *topname; if (!IoFMT_NAME(io)) IoFMT_NAME(io) = savepv(GvNAME(gv)); topname = sv_2mortal(Perl_newSVpvf(aTHX_ "%s_TOP", GvNAME(gv))); @@ -1522,19 +1516,14 @@ PP(pp_prtf) PP(pp_sysopen) { dSP; - GV *gv; - SV *sv; - const char *tmps; - STRLEN len; const int perm = (MAXARG > 3) ? POPi : 0666; const int mode = POPi; - - sv = POPs; - gv = (GV *)POPs; + SV * const sv = POPs; + GV * const gv = (GV *)POPs; + STRLEN len; /* Need TIEHANDLE method ? */ - - tmps = SvPV_const(sv, len); + const char * const tmps = SvPV_const(sv, len); /* FIXME? do_open should do const */ if (do_open(gv, (char*)tmps, len, TRUE, mode, perm, Nullfp)) { IoLINES(GvIOp(gv)) = 0; @@ -1550,7 +1539,6 @@ PP(pp_sysread) { dVAR; dSP; dMARK; dORIGMARK; dTARGET; int offset; - GV *gv; IO *io; char *buffer; SSize_t length; @@ -1558,7 +1546,6 @@ PP(pp_sysread) Sock_size_t bufsize; SV *bufsv; STRLEN blen; - MAGIC *mg; int fp_utf8; int buffer_utf8; SV *read_target; @@ -1568,23 +1555,24 @@ PP(pp_sysread) STRLEN charskip = 0; STRLEN skip = 0; - gv = (GV*)*++MARK; + GV * const gv = (GV*)*++MARK; if ((PL_op->op_type == OP_READ || PL_op->op_type == OP_SYSREAD) - && gv && (io = GvIO(gv)) - && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) + && gv && (io = GvIO(gv)) ) { - SV *sv; - - PUSHMARK(MARK-1); - *MARK = SvTIED_obj((SV*)io, mg); - ENTER; - call_method("READ", G_SCALAR); - LEAVE; - SPAGAIN; - sv = POPs; - SP = ORIGMARK; - PUSHs(sv); - RETURN; + const MAGIC * mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar); + if (mg) { + SV *sv; + PUSHMARK(MARK-1); + *MARK = SvTIED_obj((SV*)io, mg); + ENTER; + call_method("READ", G_SCALAR); + LEAVE; + SPAGAIN; + sv = POPs; + SP = ORIGMARK; + PUSHs(sv); + RETURN; + } } if (!gv) @@ -80,9 +80,7 @@ PERL_CALLCONV OP* Perl_append_list(pTHX_ I32 optype, LISTOP* first, LISTOP* last PERL_CALLCONV I32 Perl_apply(pTHX_ I32 type, SV** mark, SV** sp); PERL_CALLCONV void Perl_apply_attrs_string(pTHX_ const char *stashpv, CV *cv, const char *attrstr, STRLEN len); PERL_CALLCONV void Perl_av_clear(pTHX_ AV* ar); -PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV* ar, I32 key, I32 flags) - __attribute__warn_unused_result__; - +PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV* ar, I32 key, I32 flags); PERL_CALLCONV bool Perl_av_exists(pTHX_ AV* ar, I32 key) __attribute__warn_unused_result__; @@ -104,9 +102,7 @@ PERL_CALLCONV AV* Perl_av_make(pTHX_ I32 size, SV** svp) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); -PERL_CALLCONV SV* Perl_av_pop(pTHX_ AV* ar) - __attribute__warn_unused_result__; - +PERL_CALLCONV SV* Perl_av_pop(pTHX_ AV* ar); PERL_CALLCONV void Perl_av_push(pTHX_ AV* ar, SV* val); PERL_CALLCONV void Perl_av_reify(pTHX_ AV* ar); PERL_CALLCONV SV* Perl_av_shift(pTHX_ AV* ar) @@ -403,7 +399,6 @@ PERL_CALLCONV void Perl_gv_fullname(pTHX_ SV* sv, const GV* gv); PERL_CALLCONV void Perl_gv_fullname4(pTHX_ SV* sv, const GV* gv, const char* prefix, bool keepmain); PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLEN len, int multi) __attribute__nonnull__(pTHX_1) - __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3); PERL_CALLCONV HV* Perl_gv_stashpv(pTHX_ const char* name, I32 create); @@ -1089,7 +1084,8 @@ PERL_CALLCONV SV* Perl_newSVpvf(pTHX_ const char* pat, ...) PERL_CALLCONV SV* Perl_vnewSVpvf(pTHX_ const char* pat, va_list* args); PERL_CALLCONV SV* Perl_newSVrv(pTHX_ SV* rv, const char* classname) __attribute__malloc__ - __attribute__warn_unused_result__; + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); PERL_CALLCONV SV* Perl_newSVsv(pTHX_ SV* old) __attribute__malloc__ @@ -1553,7 +1549,8 @@ PERL_CALLCONV MAGIC * Perl_sv_magicext(pTHX_ SV* sv, SV* obj, int how, const MGV __attribute__nonnull__(pTHX_1); PERL_CALLCONV SV* Perl_sv_mortalcopy(pTHX_ SV* oldsv) - __attribute__nonnull__(pTHX_1); + __attribute__malloc__ + __attribute__warn_unused_result__; PERL_CALLCONV SV* Perl_sv_newmortal(pTHX) __attribute__warn_unused_result__; @@ -1597,7 +1594,9 @@ PERL_CALLCONV SV* Perl_sv_setref_iv(pTHX_ SV* rv, const char* classname, IV iv); PERL_CALLCONV SV* Perl_sv_setref_uv(pTHX_ SV* rv, const char* classname, UV uv); PERL_CALLCONV SV* Perl_sv_setref_nv(pTHX_ SV* rv, const char* classname, NV nv); PERL_CALLCONV SV* Perl_sv_setref_pv(pTHX_ SV* rv, const char* classname, void* pv); -PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV* rv, const char* classname, char* pv, STRLEN n); +PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV* rv, const char* classname, const char* pv, STRLEN n) + __attribute__nonnull__(pTHX_3); + PERL_CALLCONV void Perl_sv_setpv(pTHX_ SV* sv, const char* ptr); PERL_CALLCONV void Perl_sv_setpvn(pTHX_ SV* sv, const char* ptr, STRLEN len) __attribute__nonnull__(pTHX_1); @@ -1782,16 +1781,33 @@ PERL_CALLCONV void Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len); PERL_CALLCONV MGVTBL* Perl_get_vtbl(pTHX_ int vtbl_id); PERL_CALLCONV char* Perl_pv_display(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim); PERL_CALLCONV void Perl_dump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...) - __attribute__format__(__printf__,pTHX_3,pTHX_4); - -PERL_CALLCONV void Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args); -PERL_CALLCONV void Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv); -PERL_CALLCONV void Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv); -PERL_CALLCONV void Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, const char *name, HV *sv); -PERL_CALLCONV void Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim); -PERL_CALLCONV void Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o); -PERL_CALLCONV void Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, const PMOP *pm); -PERL_CALLCONV void Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim); + __attribute__format__(__printf__,pTHX_3,pTHX_4) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, const char *name, GV *sv) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, const char *name, HV *sv) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, const PMOP *pm) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim) + __attribute__nonnull__(pTHX_2); + PERL_CALLCONV void Perl_magic_dump(pTHX_ const MAGIC *mg); PERL_CALLCONV void Perl_reginitcolors(pTHX); PERL_CALLCONV char* Perl_sv_2pv_nolen(pTHX_ SV* sv); @@ -1986,7 +2002,8 @@ STATIC void S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store) STATIC void S_unshare_hek_or_pvn(pTHX_ const HEK* hek, const char* str, I32 len, U32 hash); STATIC HEK* S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags) - __attribute__warn_unused_result__; + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); STATIC void S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg) __attribute__noreturn__ @@ -2547,14 +2564,32 @@ STATIC SV* S_save_scalar_at(pTHX_ SV **sptr); #endif #if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT) -STATIC IV S_asIV(pTHX_ SV* sv); -STATIC UV S_asUV(pTHX_ SV* sv); -STATIC void S_sv_unglob(pTHX_ SV* sv); -STATIC void S_not_a_number(pTHX_ SV *sv); -STATIC I32 S_visit(pTHX_ SVFUNC_t f, U32 flags, U32 mask); -STATIC void S_sv_add_backref(pTHX_ SV *tsv, SV *sv); -STATIC void S_sv_del_backref(pTHX_ SV *sv); +STATIC IV S_asIV(pTHX_ SV* sv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +STATIC UV S_asUV(pTHX_ SV* sv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +STATIC void S_sv_unglob(pTHX_ SV* sv) + __attribute__nonnull__(pTHX_1); + +STATIC void S_not_a_number(pTHX_ SV *sv) + __attribute__nonnull__(pTHX_1); + +STATIC I32 S_visit(pTHX_ SVFUNC_t f, U32 flags, U32 mask) + __attribute__nonnull__(pTHX_1); + +STATIC void S_sv_add_backref(pTHX_ SV *tsv, SV *sv) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + +STATIC void S_sv_del_backref(pTHX_ SV *sv) + __attribute__nonnull__(pTHX_1); + STATIC SV * S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, SV *keyname, I32 aindex, int subscript_type) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); # ifdef DEBUGGING @@ -512,7 +512,7 @@ Perl_sv_clean_all(pTHX) static void S_free_arena(pTHX_ void **root) { while (root) { - void **next = *(void **)root; + void ** const next = *(void **)root; Safefree(root); root = next; } @@ -690,7 +690,7 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, AV *av; if (!cv || !CvPADLIST(cv)) - return Nullsv;; + return Nullsv; av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE)); sv = *av_fetch(av, targ, FALSE); /* SvLEN in a pad name is not to be trusted */ @@ -698,9 +698,8 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, } if (subscript_type == FUV_SUBSCRIPT_HASH) { - SV *sv; + SV * const sv = NEWSV(0,0); *SvPVX(name) = '$'; - sv = NEWSV(0,0); Perl_sv_catpvf(aTHX_ name, "{%s}", pv_display(sv,SvPVX_const(keyname), SvCUR(keyname), 0, 32)); SvREFCNT_dec(sv); @@ -742,7 +741,6 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) dVAR; SV *sv; AV *av; - SV **svp; GV *gv; OP *o, *o2, *kid; @@ -795,25 +793,26 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (match && subscript_type == FUV_SUBSCRIPT_WITHIN) break; - return S_varname(aTHX_ gv, hash ? "%" : "@", obase->op_targ, + return varname(gv, hash ? "%" : "@", obase->op_targ, keysv, index, subscript_type); } case OP_PADSV: if (match && PAD_SVl(obase->op_targ) != uninit_sv) break; - return S_varname(aTHX_ Nullgv, "$", obase->op_targ, + return varname(Nullgv, "$", obase->op_targ, Nullsv, 0, FUV_SUBSCRIPT_NONE); case OP_GVSV: gv = cGVOPx_gv(obase); if (!gv || (match && GvSV(gv) != uninit_sv)) break; - return S_varname(aTHX_ gv, "$", 0, Nullsv, 0, FUV_SUBSCRIPT_NONE); + return varname(gv, "$", 0, Nullsv, 0, FUV_SUBSCRIPT_NONE); case OP_AELEMFAST: if (obase->op_flags & OPf_SPECIAL) { /* lexical array */ if (match) { + SV **svp; av = (AV*)PAD_SV(obase->op_targ); if (!av || SvRMAGICAL(av)) break; @@ -821,7 +820,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (!svp || *svp != uninit_sv) break; } - return S_varname(aTHX_ Nullgv, "$", obase->op_targ, + return varname(Nullgv, "$", obase->op_targ, Nullsv, (I32)obase->op_private, FUV_SUBSCRIPT_ARRAY); } else { @@ -829,6 +828,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (!gv) break; if (match) { + SV **svp; av = GvAV(gv); if (!av || SvRMAGICAL(av)) break; @@ -836,7 +836,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (!svp || *svp != uninit_sv) break; } - return S_varname(aTHX_ gv, "$", 0, + return varname(gv, "$", 0, Nullsv, (I32)obase->op_private, FUV_SUBSCRIPT_ARRAY); } break; @@ -885,16 +885,16 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) break; } else { - svp = av_fetch((AV*)sv, SvIV(cSVOPx_sv(kid)), FALSE); + SV ** const svp = av_fetch((AV*)sv, SvIV(cSVOPx_sv(kid)), FALSE); if (!svp || *svp != uninit_sv) break; } } if (obase->op_type == OP_HELEM) - return S_varname(aTHX_ gv, "%", o->op_targ, + return varname(gv, "%", o->op_targ, cSVOPx_sv(kid), 0, FUV_SUBSCRIPT_HASH); else - return S_varname(aTHX_ gv, "@", o->op_targ, Nullsv, + return varname(gv, "@", o->op_targ, Nullsv, SvIV(cSVOPx_sv(kid)), FUV_SUBSCRIPT_ARRAY); ; } @@ -904,18 +904,18 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) if (obase->op_type == OP_HELEM) { SV * const keysv = S_find_hash_subscript(aTHX_ (HV*)sv, uninit_sv); if (keysv) - return S_varname(aTHX_ gv, "%", o->op_targ, + return varname(gv, "%", o->op_targ, keysv, 0, FUV_SUBSCRIPT_HASH); } else { const I32 index = S_find_array_subscript(aTHX_ (AV*)sv, uninit_sv); if (index >= 0) - return S_varname(aTHX_ gv, "@", o->op_targ, + return varname(gv, "@", o->op_targ, Nullsv, index, FUV_SUBSCRIPT_ARRAY); } if (match) break; - return S_varname(aTHX_ gv, + return varname(gv, (o->op_type == OP_PADAV || o->op_type == OP_RV2AV) ? "@" : "%", o->op_targ, Nullsv, 0, FUV_SUBSCRIPT_WITHIN); @@ -939,7 +939,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) gv = cGVOPx_gv(o); if (match && GvSV(gv) != uninit_sv) break; - return S_varname(aTHX_ gv, "$", 0, + return varname(gv, "$", 0, Nullsv, 0, FUV_SUBSCRIPT_NONE); } /* other possibilities not handled are: @@ -1830,7 +1830,7 @@ S_not_a_number(pTHX_ SV *sv) { SV *dsv; char tmpbuf[64]; - char *pv; + const char *pv; if (DO_UTF8(sv)) { dsv = sv_2mortal(newSVpv("", 0)); @@ -5245,7 +5245,7 @@ S_sv_del_backref(pTHX_ SV *sv) AV *av; SV **svp; I32 i; - SV *tsv = SvRV(sv); + SV * const tsv = SvRV(sv); MAGIC *mg = NULL; if (!SvMAGICAL(tsv) || !(mg = mg_find(tsv, PERL_MAGIC_backref))) Perl_croak(aTHX_ "panic: del_backref"); @@ -5472,7 +5472,7 @@ Perl_sv_clear(pTHX_ register SV *sv) stash = SvSTASH(sv); destructor = StashHANDLER(stash,DESTROY); if (destructor) { - SV* tmpref = newRV(sv); + SV* const tmpref = newRV(sv); SvREADONLY_on(tmpref); /* DESTROY() could be naughty */ ENTER; PUSHSTACKi(PERLSI_DESTROY); @@ -6530,7 +6530,7 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) sv_pos_u2b(sv,&append,0); } } else if (SvUTF8(sv)) { - SV *tsv = NEWSV(0,0); + SV * const tsv = NEWSV(0,0); sv_gets(tsv, fp, 0); sv_utf8_upgrade_nomg(tsv); SvCUR_set(sv,append); @@ -8053,7 +8053,7 @@ Perl_sv_reftype(pTHX_ const SV *sv, int ob) /* The fact that I don't need to downcast to char * everywhere, only in ?: inside return suggests a const propagation bug in g++. */ if (ob && SvOBJECT(sv)) { - char *name = HvNAME_get(SvSTASH(sv)); + char * const name = HvNAME_get(SvSTASH(sv)); return name ? name : (char *) "__ANON__"; } else { @@ -8187,7 +8187,7 @@ Perl_newSVrv(pTHX_ SV *rv, const char *classname) SvROK_on(rv); if (classname) { - HV* stash = gv_stashpv(classname, TRUE); + HV* const stash = gv_stashpv(classname, TRUE); (void)sv_bless(rv, stash); } return sv; @@ -8296,7 +8296,7 @@ Note that C<sv_setref_pv> copies the pointer while this copies the string. */ SV* -Perl_sv_setref_pvn(pTHX_ SV *rv, const char *classname, char *pv, STRLEN n) +Perl_sv_setref_pvn(pTHX_ SV *rv, const char *classname, const char *pv, STRLEN n) { sv_setpvn(newSVrv(rv,classname), pv, n); return rv; @@ -3340,11 +3340,13 @@ Perl_init_tm(pTHX_ struct tm *ptm) /* see mktime, strftime and asctime */ { #ifdef HAS_TM_TM_ZONE Time_t now; - struct tm* my_tm; + const struct tm* my_tm; (void)time(&now); my_tm = localtime(&now); if (my_tm) Copy(my_tm, ptm, 1, struct tm); +#else + PERL_UNUSED_ARG(ptm); #endif } |