diff options
-rw-r--r-- | av.c | 19 | ||||
-rw-r--r-- | doop.c | 33 | ||||
-rw-r--r-- | handy.h | 5 | ||||
-rw-r--r-- | hv.c | 4 | ||||
-rw-r--r-- | mg.c | 16 | ||||
-rw-r--r-- | pp.c | 3 | ||||
-rw-r--r-- | pp.h | 20 | ||||
-rw-r--r-- | sv.c | 13 | ||||
-rw-r--r-- | util.c | 12 |
9 files changed, 65 insertions, 60 deletions
@@ -334,7 +334,7 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) ary[key] = val; if (SvSMAGICAL(av)) { if (val != &PL_sv_undef) { - MAGIC* mg = SvMAGIC(av); + const MAGIC* const mg = SvMAGIC(av); sv_magic(val, (SV*)av, toLOWER(mg->mg_type), 0, key); } mg_set((SV*)av); @@ -412,6 +412,7 @@ Perl_av_clear(pTHX_ register AV *av) { register I32 key; +/* XXX Should av_clear really be NN? */ #ifdef DEBUGGING if (SvREFCNT(av) == 0 && ckWARN_d(WARN_DEBUGGING)) { Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "Attempt to clear deleted array"); @@ -731,7 +732,7 @@ Perl_av_fill(pTHX_ register AV *av, I32 fill) } if (fill <= AvMAX(av)) { I32 key = AvFILLp(av); - SV** ary = AvARRAY(av); + SV** const ary = AvARRAY(av); if (AvREAL(av)) { while (key > fill) { @@ -767,7 +768,7 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) SV *sv; if (!av) - return Nullsv; + return NULL; if (SvREADONLY(av)) Perl_croak(aTHX_ PL_no_modify); @@ -790,7 +791,7 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) if (adjust_index) { key += AvFILL(av) + 1; if (key < 0) - return Nullsv; + return NULL; } } svp = av_fetch(av, key, TRUE); @@ -801,7 +802,7 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) sv_unmagic(sv, PERL_MAGIC_tiedelem); /* No longer an element */ return sv; } - return Nullsv; + return NULL; } } } @@ -809,11 +810,11 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) if (key < 0) { key += AvFILL(av) + 1; if (key < 0) - return Nullsv; + return NULL; } if (key > AvFILLp(av)) - return Nullsv; + return NULL; else { if (!AvREAL(av) && AvREIFY(av)) av_reify(av); @@ -831,7 +832,7 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) } if (flags & G_DISCARD) { SvREFCNT_dec(sv); - sv = Nullsv; + sv = NULL; } else if (AvREAL(av)) sv = sv_2mortal(sv); @@ -858,7 +859,7 @@ Perl_av_exists(pTHX_ AV *av, I32 key) if (SvRMAGICAL(av)) { const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied); if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) { - SV *sv = sv_newmortal(); + SV * const sv = sv_newmortal(); MAGIC *mg; /* Handle negative array indices 20020222 MJD */ if (key < 0) { @@ -100,7 +100,6 @@ S_do_trans_count(pTHX_ SV *sv) const U8 *send; I32 matches = 0; STRLEN len; - const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT; const short * const tbl = (short*)cPVOP->op_pv; if (!tbl) @@ -114,7 +113,8 @@ S_do_trans_count(pTHX_ SV *sv) if (tbl[*s++] >= 0) matches++; } - else + else { + const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT; while (s < send) { STRLEN ulen; const UV c = utf8n_to_uvchr(s, send - s, &ulen, 0); @@ -125,6 +125,7 @@ S_do_trans_count(pTHX_ SV *sv) matches++; s += ulen; } + } return matches; } @@ -138,9 +139,6 @@ S_do_trans_complex(pTHX_ SV *sv) U8 *dstart; I32 isutf8; I32 matches = 0; - const I32 grows = PL_op->op_private & OPpTRANS_GROWS; - const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT; - const I32 del = PL_op->op_private & OPpTRANS_DELETE; STRLEN len, rlen = 0; const short * const tbl = (short*)cPVOP->op_pv; @@ -188,6 +186,10 @@ S_do_trans_complex(pTHX_ SV *sv) SvCUR_set(sv, d - dstart); } else { /* isutf8 */ + const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT; + const I32 grows = PL_op->op_private & OPpTRANS_GROWS; + const I32 del = PL_op->op_private & OPpTRANS_DELETE; + if (grows) Newx(d, len*2+1, U8); else @@ -321,11 +323,12 @@ S_do_trans_simple_utf8(pTHX_ SV *sv) const U8 * const e = s + len; while (t < e) { const U8 ch = *t++; - if ((hibit = !NATIVE_IS_INVARIANT(ch))) + hibit = !NATIVE_IS_INVARIANT(ch); + if (hibit) { + s = bytes_to_utf8(s, &len); break; + } } - if (hibit) - s = bytes_to_utf8(s, &len); } send = s + len; start = s; @@ -413,11 +416,12 @@ S_do_trans_count_utf8(pTHX_ SV *sv) const U8 * const e = s + len; while (t < e) { const U8 ch = *t++; - if ((hibit = !NATIVE_IS_INVARIANT(ch))) + hibit = !NATIVE_IS_INVARIANT(ch); + if (hibit) { + start = s = bytes_to_utf8(s, &len); break; + } } - if (hibit) - start = s = bytes_to_utf8(s, &len); } send = s + len; @@ -460,11 +464,12 @@ S_do_trans_complex_utf8(pTHX_ SV *sv) const U8 * const e = s + len; while (t < e) { const U8 ch = *t++; - if ((hibit = !NATIVE_IS_INVARIANT(ch))) + hibit = !NATIVE_IS_INVARIANT(ch); + if (hibit) { + s = bytes_to_utf8(s, &len); break; + } } - if (hibit) - s = bytes_to_utf8(s, &len); } send = s + len; start = s; @@ -618,12 +618,9 @@ hopefully catches attempts to access uninitialized memory. #define NEWSV(x,len) newSV(len) #ifdef PERL_MALLOC_WRAP -#define MEM_WRAP_CHECK(n,t) \ - (void)((sizeof(t)>1?(n):1)>((MEM_SIZE)~0)/sizeof(t)?(Perl_croak_nocontext(PL_memory_wrap),0):0) +#define MEM_WRAP_CHECK(n,t) MEM_WRAP_CHECK_1(n,t,PL_memory_wrap) #define MEM_WRAP_CHECK_1(n,t,a) \ (void)((sizeof(t)>1?(n):1)>((MEM_SIZE)~0)/sizeof(t)?(Perl_croak_nocontext(a),0):0) -#define MEM_WRAP_CHECK_2(n,t,a,b) \ - (void)((sizeof(t)>1?(n):1)>((MEM_SIZE)~0)/sizeof(t)?(Perl_croak_nocontext(a,b),0):0) #define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t), #define PERL_STRLEN_ROUNDUP(n) ((void)(((n) > (MEM_SIZE)~0 - 2 * PERL_STRLEN_ROUNDUP_QUANTUM) ? (Perl_croak_nocontext(PL_memory_wrap),0):0),((n-1+PERL_STRLEN_ROUNDUP_QUANTUM)&~((MEM_SIZE)PERL_STRLEN_ROUNDUP_QUANTUM-1))) @@ -267,6 +267,7 @@ Perl_hv_store(pTHX_ HV *hv, const char *key, I32 klen_i32, SV *val, U32 hash) return hek ? &HeVAL(hek) : NULL; } +/* XXX This looks like an ideal candidate to inline */ SV** Perl_hv_store_flags(pTHX_ HV *hv, const char *key, I32 klen, SV *val, register U32 hash, int flags) @@ -305,6 +306,7 @@ information on how to use this function on tied hashes. =cut */ +/* XXX This looks like an ideal candidate to inline */ HE * Perl_hv_store_ent(pTHX_ HV *hv, SV *keysv, SV *val, U32 hash) { @@ -381,6 +383,7 @@ computed. =cut */ +/* XXX This looks like an ideal candidate to inline */ bool Perl_hv_exists_ent(pTHX_ HV *hv, SV *keysv, U32 hash) { @@ -936,6 +939,7 @@ precomputed hash value, or 0 to ask for it to be computed. =cut */ +/* XXX This looks like an ideal candidate to inline */ SV * Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash) { @@ -846,7 +846,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) getrx: if (i >= 0) { - int oldtainted = PL_tainted; + const int oldtainted = PL_tainted; TAINT_NOT; sv_setpvn(sv, s, i); PL_tainted = oldtainted; @@ -1043,20 +1043,17 @@ int Perl_magic_setenv(pTHX_ SV *sv, MAGIC *mg) { dVAR; - const char *s; - const char *ptr; STRLEN len, klen; - - s = SvPV_const(sv,len); - ptr = MgPV_const(mg,klen); + const char *s = SvPV_const(sv,len); + const char * const ptr = MgPV_const(mg,klen); my_setenv(ptr, s); #ifdef DYNAMIC_ENV_FETCH /* We just undefd an environment var. Is a replacement */ /* waiting in the wings? */ if (!len) { - SV **valp; - if ((valp = hv_fetch(GvHVn(PL_envgv), ptr, klen, FALSE))) + SV ** const valp = hv_fetch(GvHVn(PL_envgv), ptr, klen, FALSE); + if (valp) s = SvPV_const(*valp, len); } #endif @@ -1795,7 +1792,7 @@ Perl_magic_setpos(pTHX_ SV *sv, MAGIC *mg) if (!mg) { if (!SvOK(sv)) return 0; - sv_magic(lsv, (SV*)0, PERL_MAGIC_regex_global, Nullch, 0); + sv_magic(lsv, NULL, PERL_MAGIC_regex_global, NULL, 0); mg = mg_find(lsv, PERL_MAGIC_regex_global); } else if (!SvOK(sv)) { @@ -2843,7 +2840,6 @@ S_unwind_handler_stack(pTHX_ const void *p) if (flags & 1) PL_savestack_ix -= 5; /* Unprotect save in progress. */ - /* cxstack_ix-- Not needed, die already unwound it. */ #if !defined(PERL_IMPLICIT_CONTEXT) if (flags & 64) SvREFCNT_dec(PL_sig_sv); @@ -378,9 +378,8 @@ PP(pp_prototype) CV *cv; HV *stash; GV *gv; - SV *ret; + SV *ret = &PL_sv_undef; - ret = &PL_sv_undef; if (SvPOK(TOPs) && SvCUR(TOPs) >= 7) { const char * const s = SvPVX_const(TOPs); if (strnEQ(s, "CORE::", 6)) { @@ -398,17 +398,19 @@ and C<PUSHu>. #define AMGf_unary 8 #define tryAMAGICbinW_var(meth_enum,assign,set) STMT_START { \ - if (PL_amagic_generation) { \ - SV* tmpsv; \ - SV* const right= *(sp); SV* const left= *(sp-1);\ - if ((SvAMAGIC(left)||SvAMAGIC(right))&&\ - (tmpsv=amagic_call(left, \ + if (PL_amagic_generation) { \ + SV* const left = *(sp-1); \ + SV* const right = *(sp); \ + if ((SvAMAGIC(left)||SvAMAGIC(right))) {\ + SV * const tmpsv = amagic_call(left, \ right, \ meth_enum, \ - (assign)? AMGf_assign: 0))) {\ - SPAGAIN; \ - (void)POPs; set(tmpsv); RETURN; } \ - } \ + (assign)? AMGf_assign: 0); \ + if (tmpsv) { \ + SPAGAIN; \ + (void)POPs; set(tmpsv); RETURN; } \ + } \ + } \ } STMT_END #define tryAMAGICbinW(meth,assign,set) \ @@ -2640,11 +2640,12 @@ Perl_sv_2bool(pTHX_ register SV *sv) if (!SvOK(sv)) return 0; if (SvROK(sv)) { - SV* tmpsv; - if (SvAMAGIC(sv) && (tmpsv=AMG_CALLun(sv,bool_)) && - (!SvROK(tmpsv) || (SvRV(tmpsv) != SvRV(sv)))) - return (bool)SvTRUE(tmpsv); - return SvRV(sv) != 0; + if (SvAMAGIC(sv)) { + SV * const tmpsv = AMG_CALLun(sv,bool_); + if (tmpsv && (!SvROK(tmpsv) || (SvRV(tmpsv) != SvRV(sv)))) + return (bool)SvTRUE(tmpsv); + } + return SvRV(sv) != 0; } if (SvPOKp(sv)) { register XPV* const Xpvtmp = (XPV*)SvANY(sv); @@ -3857,7 +3858,7 @@ void Perl_sv_catpvn_flags(pTHX_ register SV *dsv, register const char *sstr, register STRLEN slen, I32 flags) { STRLEN dlen; - const char *dstr = SvPV_force_flags(dsv, dlen, flags); + const char * const dstr = SvPV_force_flags(dsv, dlen, flags); SvGROW(dsv, dlen + slen + 1); if (sstr == dstr) @@ -1021,12 +1021,12 @@ S_closest_cop(pTHX_ COP *cop, const OP *o) { /* Look for PL_op starting from o. cop is the last COP we've seen. */ - if (!o || o == PL_op) return cop; + if (!o || o == PL_op) + return cop; if (o->op_flags & OPf_KIDS) { OP *kid; - for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) - { + for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) { COP *new_cop; /* If the OP_NEXTSTATE has been optimised away we can still use it @@ -1038,7 +1038,8 @@ S_closest_cop(pTHX_ COP *cop, const OP *o) /* Keep searching, and return when we've found something. */ new_cop = closest_cop(cop, kid); - if (new_cop) return new_cop; + if (new_cop) + return new_cop; } } @@ -2585,8 +2586,7 @@ Perl_rsignal(pTHX_ int signo, Sighandler_t handler) return PerlProc_signal(signo, handler); } -static -Signal_t +static Signal_t sig_trap(int signo) { dVAR; |