diff options
author | Andy Lester <andy@petdance.com> | 2005-06-20 05:22:37 -0500 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-06-20 15:12:50 +0000 |
commit | 53c1dcc098c6cc47963786f1928061d90b5d30e1 (patch) | |
tree | 018888fffdf323f44128fe1434e39e7b5cccceae /sv.c | |
parent | 7e3ec654269fdea39968d4cec52cbfcb1f030631 (diff) | |
download | perl-53c1dcc098c6cc47963786f1928061d90b5d30e1.tar.gz |
The continuing adventures of Constman and Localize Boy
Message-ID: <20050620152237.GA5032@petdance.com>
p4raw-id: //depot/perl@24913
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 78 |
1 files changed, 43 insertions, 35 deletions
@@ -286,8 +286,8 @@ S_del_sv(pTHX_ SV *p) SV* sva; bool ok = 0; for (sva = PL_sv_arenaroot; sva; sva = (SV *) SvANY(sva)) { - SV *sv = sva + 1; - SV *svend = &sva[SvREFCNT(sva)]; + const SV * const sv = sva + 1; + const SV * const svend = &sva[SvREFCNT(sva)]; if (p >= sv && p < svend) { ok = 1; break; @@ -366,7 +366,7 @@ S_visit(pTHX_ SVFUNC_t f, U32 flags, U32 mask) I32 visited = 0; for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { - register SV * const svend = &sva[SvREFCNT(sva)]; + register const SV * const svend = &sva[SvREFCNT(sva)]; register SV* sv; for (sv = sva + 1; sv < svend; ++sv) { if (SvTYPE(sv) != SVTYPEMASK @@ -674,8 +674,6 @@ STATIC SV* S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, SV* keyname, I32 aindex, int subscript_type) { - AV *av; - SV *sv; SV * const name = sv_newmortal(); if (gv) { @@ -685,7 +683,7 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, * directly */ const char *p; - HV *hv = GvSTASH(gv); + HV * const hv = GvSTASH(gv); sv_setpv(name, gvtype); if (!hv) p = "???"; @@ -705,8 +703,11 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, sv_catpvn(name,GvNAME(gv),GvNAMELEN(gv)); } else { - U32 u; - CV *cv = find_runcv(&u); + U32 unused; + CV * const cv = find_runcv(&unused); + SV *sv; + AV *av; + if (!cv || !CvPADLIST(cv)) return Nullsv;; av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE)); @@ -716,6 +717,7 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, } if (subscript_type == FUV_SUBSCRIPT_HASH) { + SV *sv; *SvPVX(name) = '$'; sv = NEWSV(0,0); Perl_sv_catpvf(aTHX_ name, "{%s}", @@ -919,7 +921,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) /* index is an expression; * attempt to find a match within the aggregate */ if (obase->op_type == OP_HELEM) { - SV *keysv = S_find_hash_subscript(aTHX_ (HV*)sv, uninit_sv); + SV * const keysv = S_find_hash_subscript(aTHX_ (HV*)sv, uninit_sv); if (keysv) return S_varname(aTHX_ gv, "%", o->op_targ, keysv, 0, FUV_SUBSCRIPT_HASH); @@ -1079,7 +1081,7 @@ S_more_bodies (pTHX_ void **arena_root, void **root, size_t size) { char *start; const char *end; - size_t count = PERL_ARENA_SIZE/size; + const size_t count = PERL_ARENA_SIZE/size; New(0, start, count*size, char); *((void **) start) = *arena_root; *arena_root = (void *)start; @@ -1094,7 +1096,7 @@ S_more_bodies (pTHX_ void **arena_root, void **root, size_t size) *root = (void *)start; while (start < end) { - char *next = start + size; + char * const next = start + size; *(void**) start = (void *)next; start = next; } @@ -1285,7 +1287,7 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 mt) size_t new_body_offset; void** new_body_arena; void** new_body_arenaroot; - U32 old_type = SvTYPE(sv); + const U32 old_type = SvTYPE(sv); if (mt != SVt_PV && SvIsCOW(sv)) { sv_force_normal_flags(sv, 0); @@ -1598,7 +1600,7 @@ Perl_sv_backoff(pTHX_ register SV *sv) assert(SvTYPE(sv) != SVt_PVHV); assert(SvTYPE(sv) != SVt_PVAV); if (SvIVX(sv)) { - const char *s = SvPVX_const(sv); + const char * const s = SvPVX_const(sv); SvLEN_set(sv, SvLEN(sv) + SvIVX(sv)); SvPV_set(sv, SvPVX(sv) - SvIVX(sv)); SvIV_set(sv, 0); @@ -3347,8 +3349,7 @@ void Perl_sv_copypv(pTHX_ SV *dsv, register SV *ssv) { STRLEN len; - const char *s; - s = SvPV_const(ssv,len); + const char * const s = SvPV_const(ssv,len); sv_setpvn(dsv,s,len); if (SvUTF8(ssv)) SvUTF8_on(dsv); @@ -3452,8 +3453,8 @@ Perl_sv_2bool(pTHX_ register SV *sv) return SvRV(sv) != 0; } if (SvPOKp(sv)) { - register XPV* Xpvtmp; - if ((Xpvtmp = (XPV*)SvANY(sv)) && + register XPV* const Xpvtmp = (XPV*)SvANY(sv); + if (Xpvtmp && (*sv->sv_u.svu_pv > '0' || Xpvtmp->xpv_cur > 1 || (Xpvtmp->xpv_cur && *sv->sv_u.svu_pv != '0'))) @@ -3547,13 +3548,13 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags) int hibit = 0; while (t < e) { - U8 ch = *t++; + const U8 ch = *t++; if ((hibit = !NATIVE_IS_INVARIANT(ch))) break; } if (hibit) { STRLEN len = SvCUR(sv) + 1; /* Plus the \0 */ - U8 *recoded = bytes_to_utf8((U8*)s, &len); + U8 * const recoded = bytes_to_utf8((U8*)s, &len); SvPV_free(sv); /* No longer using what was there before. */ @@ -8832,6 +8833,8 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV /* large enough for "%#.#f" --chip */ /* what about long double NVs? --jhi */ + PERL_UNUSED_ARG(maybe_tainted); + /* no matter what, this is a string now */ (void)SvPV_force(sv, origlen); @@ -8840,7 +8843,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV return; if (patlen == 2 && pat[0] == '%' && pat[1] == 's') { if (args) { - const char *s = va_arg(*args, char*); + const char * const s = va_arg(*args, char*); sv_catpv(sv, s ? s : nullstr); } else if (svix < svmax) { @@ -9728,7 +9731,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV sv_utf8_upgrade(sv); } else { - SV *nsv = sv_2mortal(newSVpvn(eptr, elen)); + SV * const nsv = sv_2mortal(newSVpvn(eptr, elen)); sv_utf8_upgrade(nsv); eptr = SvPVX_const(nsv); elen = SvCUR(nsv); @@ -9744,6 +9747,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV SvGROW(sv, SvCUR(sv) + need + dotstrlen + 1); p = SvEND(sv); if (esignlen && fill == '0') { + int i; for (i = 0; i < (int)esignlen; i++) *p++ = esignbuf[i]; } @@ -9752,10 +9756,12 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV p += gap; } if (esignlen && fill != '0') { + int i; for (i = 0; i < (int)esignlen; i++) *p++ = esignbuf[i]; } if (zeros) { + int i; for (i = zeros; i; i--) *p++ = '0'; } @@ -9831,7 +9837,7 @@ ptr_table_* functions. regcomp.c. AMS 20010712 */ REGEXP * -Perl_re_dup(pTHX_ REGEXP *r, CLONE_PARAMS *param) +Perl_re_dup(pTHX_ const REGEXP *r, CLONE_PARAMS *param) { dVAR; REGEXP *ret; @@ -9867,6 +9873,7 @@ Perl_re_dup(pTHX_ REGEXP *r, CLONE_PARAMS *param) if (r->data) { struct reg_data *d; const int count = r->data->count; + int i; Newc(0, d, sizeof(struct reg_data) + count*sizeof(void *), char, struct reg_data); @@ -9949,7 +9956,8 @@ PerlIO * Perl_fp_dup(pTHX_ PerlIO *fp, char type, CLONE_PARAMS *param) { PerlIO *ret; - (void)type; + + PERL_UNUSED_ARG(type); if (!fp) return (PerlIO*)NULL; @@ -10108,7 +10116,7 @@ Perl_ptr_table_new(pTHX) /* map an existing pointer using a table */ void * -Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *sv) +Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, const void *sv) { PTR_TBL_ENT_t *tblent; const UV hash = PTR_TABLE_HASH(sv); @@ -10124,7 +10132,7 @@ Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *sv) /* add a new entry to a pointer-mapping table */ void -Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, void *oldv, void *newv) +Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, const void *oldv, void *newv) { PTR_TBL_ENT_t *tblent, **otblent; /* XXX this may be pessimal on platforms where pointers aren't good @@ -10854,7 +10862,7 @@ Perl_si_dup(pTHX_ PERL_SI *si, CLONE_PARAMS* param) */ void * -Perl_any_dup(pTHX_ void *v, PerlInterpreter *proto_perl) +Perl_any_dup(pTHX_ void *v, const PerlInterpreter *proto_perl) { void *ret; @@ -10881,9 +10889,9 @@ Perl_any_dup(pTHX_ void *v, PerlInterpreter *proto_perl) ANY * Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) { - ANY *ss = proto_perl->Tsavestack; - I32 ix = proto_perl->Tsavestack_ix; - I32 max = proto_perl->Tsavestack_max; + ANY * const ss = proto_perl->Tsavestack; + const I32 max = proto_perl->Tsavestack_max; + I32 ix = proto_perl->Tsavestack_ix; ANY *nss; SV *sv; GV *gv; @@ -10897,7 +10905,6 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) char *c = NULL; void (*dptr) (void*); void (*dxptr) (pTHX_ void*); - OP *o; Newz(54, nss, max, ANY); @@ -11030,6 +11037,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) ptr = POPPTR(ss,ix); if (ptr && (((OP*)ptr)->op_private & OPpREFCOUNTED)) { /* these are assumed to be refcounted properly */ + OP *o; switch (((OP*)ptr)->op_type) { case OP_LEAVESUB: case OP_LEAVESUBLV: @@ -11157,9 +11165,9 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) static void do_mark_cloneable_stash(pTHX_ SV *sv) { - const HEK *hvname = HvNAME_HEK((HV*)sv); + const HEK * const hvname = HvNAME_HEK((HV*)sv); if (hvname) { - GV* cloner = gv_fetchmethod_autoload((HV*)sv, "CLONE_SKIP", 0); + GV* const cloner = gv_fetchmethod_autoload((HV*)sv, "CLONE_SKIP", 0); SvFLAGS(sv) |= SVphv_CLONEABLE; /* clone objects by default */ if (cloner && GvCV(cloner)) { dSP; @@ -11485,7 +11493,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_regex_padav = newAV(); { const I32 len = av_len((AV*)proto_perl->Iregex_padav); - SV** regexen = AvARRAY((AV*)proto_perl->Iregex_padav); + SV** const regexen = AvARRAY((AV*)proto_perl->Iregex_padav); IV i; av_push(PL_regex_padav, sv_dup_inc(regexen[0],param)); @@ -12007,8 +12015,8 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, identified by sv_dup() above. */ while(av_len(param->stashes) != -1) { - HV* stash = (HV*) av_shift(param->stashes); - GV* cloner = gv_fetchmethod_autoload(stash, "CLONE", 0); + HV* const stash = (HV*) av_shift(param->stashes); + GV* const cloner = gv_fetchmethod_autoload(stash, "CLONE", 0); if (cloner && GvCV(cloner)) { dSP; ENTER; |