From: Andy Lester Date: Wed, 28 Dec 2005 15:44:14 +0000 (-0600) Subject: av.c cleanup, plus! X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7a5b473ebcffe303e0ee757c10a615cdeb97e2f3;p=p5sagit%2Fp5-mst-13.2.git av.c cleanup, plus! Message-ID: <20051228214414.GD26033@petdance.com> p4raw-id: //depot/perl@26526 --- diff --git a/av.c b/av.c index 6223136..c225093 100644 --- a/av.c +++ b/av.c @@ -62,9 +62,11 @@ extended. void Perl_av_extend(pTHX_ AV *av, I32 key) { + MAGIC *mg; + assert(av); - MAGIC * const mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied); + mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied); if (mg) { dSP; ENTER; @@ -416,8 +418,6 @@ Perl_av_clear(pTHX_ register AV *av) register I32 key; assert(av); - -/* 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"); diff --git a/dump.c b/dump.c index 0679ed9..3acbc42 100644 --- a/dump.c +++ b/dump.c @@ -1441,7 +1441,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo } if (nest < maxnest && !HvEITER_get(sv)) { /* Try to preserve iterator */ HE *he; - HV *hv = (HV*)sv; + HV * const hv = (HV*)sv; int count = maxnest - nest; hv_iterinit(hv); @@ -1450,7 +1450,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo SV *elt, *keysv; const char *keypv; STRLEN len; - U32 hash = HeHASH(he); + const U32 hash = HeHASH(he); keysv = hv_iterkeysv(he); keypv = SvPV_const(keysv, len); diff --git a/embed.fnc b/embed.fnc index 5aed31e..45f3a92 100644 --- a/embed.fnc +++ b/embed.fnc @@ -95,22 +95,22 @@ p |OP* |append_elem |I32 optype|NULLOK OP* first|NULLOK OP* last p |OP* |append_list |I32 optype|NULLOK LISTOP* first|NULLOK LISTOP* last p |I32 |apply |I32 type|NN SV** mark|NN SV** sp ApM |void |apply_attrs_string|NN const char *stashpv|NN CV *cv|NN const char *attrstr|STRLEN len -Apd |void |av_clear |NULLOK AV* ar -Apd |SV* |av_delete |NULLOK AV* ar|I32 key|I32 flags -ApdR |bool |av_exists |NULLOK AV* ar|I32 key +Apd |void |av_clear |NN AV* ar +Apd |SV* |av_delete |NN AV* ar|I32 key|I32 flags +ApdR |bool |av_exists |NN AV* ar|I32 key Apd |void |av_extend |NN AV* ar|I32 key pR |AV* |av_fake |I32 size|NN SV** svp -ApdR |SV** |av_fetch |NULLOK AV* ar|I32 key|I32 lval +ApdR |SV** |av_fetch |NN AV* ar|I32 key|I32 lval Apd |void |av_fill |NN AV* ar|I32 fill ApdR |I32 |av_len |NN const AV* ar ApdR |AV* |av_make |I32 size|NN SV** svp -Apd |SV* |av_pop |NULLOK AV* ar -Apd |void |av_push |NULLOK AV* ar|NN SV* val +Apd |SV* |av_pop |NN AV* ar +Apd |void |av_push |NN AV* ar|NN SV* val p |void |av_reify |NN AV* ar -ApdR |SV* |av_shift |NULLOK AV* ar -Apd |SV** |av_store |NULLOK AV* ar|I32 key|NULLOK SV* val -Apd |void |av_undef |NULLOK AV* ar -Apd |void |av_unshift |NULLOK AV* ar|I32 num +ApdR |SV* |av_shift |NN AV* ar +Apd |SV** |av_store |NN AV* ar|I32 key|NULLOK SV* val +Apd |void |av_undef |NN AV* ar +Apd |void |av_unshift |NN AV* ar|I32 num Apo |SV** |av_arylen_p |NN AV* av pR |OP* |bind_match |I32 type|NN OP* left|NN OP* pat pR |OP* |block_end |I32 floor|NULLOK OP* seq diff --git a/gv.c b/gv.c index e1b1e94..8c902b5 100644 --- a/gv.c +++ b/gv.c @@ -1168,7 +1168,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, { SV * const sv = GvSVn(gv); if (!sv_derived_from(PL_patchlevel, "version")) - (void *)upg_version(PL_patchlevel); + upg_version(PL_patchlevel); GvSV(gv) = vnumify(PL_patchlevel); SvREADONLY_on(GvSV(gv)); SvREFCNT_dec(sv); diff --git a/perl.c b/perl.c index 133d3b5..469593b 100644 --- a/perl.c +++ b/perl.c @@ -3213,7 +3213,7 @@ Perl_moreswitches(pTHX_ char *s) return s; case 'v': if (!sv_derived_from(PL_patchlevel, "version")) - (void *)upg_version(PL_patchlevel); + upg_version(PL_patchlevel); #if !defined(DGUX) PerlIO_printf(PerlIO_stdout(), Perl_form(aTHX_ "\nThis is perl, %"SVf" built for %s", diff --git a/proto.h b/proto.h index fbf3c86..3a265d7 100644 --- a/proto.h +++ b/proto.h @@ -123,10 +123,15 @@ PERL_CALLCONV void Perl_apply_attrs_string(pTHX_ const char *stashpv, CV *cv, co __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_3); -PERL_CALLCONV void Perl_av_clear(pTHX_ AV* ar); -PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV* ar, I32 key, I32 flags); +PERL_CALLCONV void Perl_av_clear(pTHX_ AV* ar) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV* ar, I32 key, I32 flags) + __attribute__nonnull__(pTHX_1); + PERL_CALLCONV bool Perl_av_exists(pTHX_ AV* ar, I32 key) - __attribute__warn_unused_result__; + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_av_extend(pTHX_ AV* ar, I32 key) __attribute__nonnull__(pTHX_1); @@ -136,7 +141,8 @@ PERL_CALLCONV AV* Perl_av_fake(pTHX_ I32 size, SV** svp) __attribute__nonnull__(pTHX_2); PERL_CALLCONV SV** Perl_av_fetch(pTHX_ AV* ar, I32 key, I32 lval) - __attribute__warn_unused_result__; + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); PERL_CALLCONV void Perl_av_fill(pTHX_ AV* ar, I32 fill) __attribute__nonnull__(pTHX_1); @@ -149,19 +155,29 @@ 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); +PERL_CALLCONV SV* Perl_av_pop(pTHX_ AV* ar) + __attribute__nonnull__(pTHX_1); + PERL_CALLCONV void Perl_av_push(pTHX_ AV* ar, SV* val) + __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); PERL_CALLCONV void Perl_av_reify(pTHX_ AV* ar) __attribute__nonnull__(pTHX_1); PERL_CALLCONV SV* Perl_av_shift(pTHX_ AV* ar) - __attribute__warn_unused_result__; + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV SV** Perl_av_store(pTHX_ AV* ar, I32 key, SV* val) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void Perl_av_undef(pTHX_ AV* ar) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void Perl_av_unshift(pTHX_ AV* ar, I32 num) + __attribute__nonnull__(pTHX_1); -PERL_CALLCONV SV** Perl_av_store(pTHX_ AV* ar, I32 key, SV* val); -PERL_CALLCONV void Perl_av_undef(pTHX_ AV* ar); -PERL_CALLCONV void Perl_av_unshift(pTHX_ AV* ar, I32 num); PERL_CALLCONV SV** Perl_av_arylen_p(pTHX_ AV* av) __attribute__nonnull__(pTHX_1); diff --git a/sv.c b/sv.c index f11f219..781222e 100644 --- a/sv.c +++ b/sv.c @@ -6276,7 +6276,7 @@ Perl_sv_2mortal(pTHX_ register SV *sv) { dVAR; if (!sv) - return sv; + return NULL; if (SvREADONLY(sv) && SvIMMORTAL(sv)) return sv; EXTEND_MORTAL(1); @@ -6578,7 +6578,7 @@ Perl_newSVsv(pTHX_ register SV *old) register SV *sv; if (!old) - return Nullsv; + return NULL; if (SvTYPE(old) == SVTYPEMASK) { if (ckWARN_d(WARN_INTERNAL)) Perl_warner(aTHX_ packWARN(WARN_INTERNAL), "semi-panic: attempt to dup freed string"); @@ -10288,20 +10288,20 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_regex_padav = newAV(); { const I32 len = av_len((AV*)proto_perl->Iregex_padav); - SV** const regexen = AvARRAY((AV*)proto_perl->Iregex_padav); + SV* const * const regexen = AvARRAY((AV*)proto_perl->Iregex_padav); IV i; av_push(PL_regex_padav, sv_dup_inc(regexen[0],param)); for(i = 1; i <= len; i++) { - if(SvREPADTMP(regexen[i])) { - av_push(PL_regex_padav, sv_dup_inc(regexen[i], param)); - } else { - av_push(PL_regex_padav, - SvREFCNT_inc( - newSViv(PTR2IV(re_dup(INT2PTR(REGEXP *, - SvIVX(regexen[i])), param))) - )); - } + const SV * const regex = regexen[i]; + SV * const sv = + SvREPADTMP(regex) + ? sv_dup_inc(regex, param) + : SvREFCNT_inc( + newSViv(PTR2IV(re_dup( + INT2PTR(REGEXP *, SvIVX(regex)), param)))) + ; + av_push(PL_regex_padav, sv); } } PL_regex_pad = AvARRAY(PL_regex_padav); diff --git a/toke.c b/toke.c index 95669a9..b8f3c71 100644 --- a/toke.c +++ b/toke.c @@ -10338,7 +10338,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims) /* update debugger info */ if (PERLDB_LINE && PL_curstash != PL_debstash) { - SV *sv = NEWSV(88,0); + SV * const sv = NEWSV(88,0); sv_upgrade(sv, SVt_PVMG); sv_setsv(sv,PL_linestr);