diff options
author | Andy Lester <andy@petdance.com> | 2005-10-04 10:16:05 -0500 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2005-10-05 15:34:09 +0000 |
commit | 44f8325f4c9b3aaf24b47f4da7dce3e8170dcf42 (patch) | |
tree | 79ae96444551bc3a112d7601282f544236b6cdfb | |
parent | 5f0135ebccd6cdb2441aabb64baa39aea87199d3 (diff) | |
download | perl-44f8325f4c9b3aaf24b47f4da7dce3e8170dcf42.tar.gz |
Re: [PATCH] Random constings and printf cleanup
Message-ID: <20051004201605.GA31682@petdance.com>
p4raw-id: //depot/perl@25693
-rw-r--r-- | malloc.c | 2 | ||||
-rw-r--r-- | pad.c | 8 | ||||
-rw-r--r-- | perl.c | 14 | ||||
-rw-r--r-- | perl.h | 2 | ||||
-rw-r--r-- | pp_ctl.c | 53 | ||||
-rw-r--r-- | sv.c | 12 | ||||
-rw-r--r-- | utf8.c | 10 | ||||
-rw-r--r-- | xsutils.c | 5 |
8 files changed, 55 insertions, 51 deletions
@@ -2354,7 +2354,7 @@ Perl_putenv(char *a) MEM_SIZE Perl_malloced_size(void *p) { - union overhead *ovp = (union overhead *) + union overhead * const ovp = (union overhead *) ((caddr_t)p - sizeof (union overhead) * CHUNK_SHIFT); const int bucket = OV_INDEX(ovp); #ifdef RCHECK @@ -1566,12 +1566,12 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth) return; { - SV** svp = AvARRAY(padlist); - AV *newpad = newAV(); - SV **oldpad = AvARRAY(svp[depth-1]); + SV** const svp = AvARRAY(padlist); + AV* const newpad = newAV(); + SV** const oldpad = AvARRAY(svp[depth-1]); I32 ix = AvFILLp((AV*)svp[1]); const I32 names_fill = AvFILLp((AV*)svp[0]); - SV** names = AvARRAY(svp[0]); + SV** const names = AvARRAY(svp[0]); AV *av; for ( ;ix > 0; ix--) { @@ -347,7 +347,7 @@ perl_construct(pTHXx) # endif if ((long) PL_mmap_page_size < 0) { if (errno) { - SV *error = ERRSV; + SV * const error = ERRSV; (void) SvUPGRADE(error, SVt_PV); Perl_croak(aTHX_ "panic: sysconf: %s", SvPV_nolen_const(error)); } @@ -1085,15 +1085,15 @@ perl_destruct(pTHXx) */ I32 riter = 0; const I32 max = HvMAX(PL_strtab); - HE **array = HvARRAY(PL_strtab); + HE ** const array = HvARRAY(PL_strtab); HE *hent = array[0]; for (;;) { if (hent && ckWARN_d(WARN_INTERNAL)) { - HE *next = HeNEXT(hent); + HE * const next = HeNEXT(hent); Perl_warner(aTHX_ packWARN(WARN_INTERNAL), - "Unbalanced string table refcount: (%d) for \"%s\"", - HeVAL(hent) - Nullsv, HeKEY(hent)); + "Unbalanced string table refcount: (%ld) for \"%s\"", + (long)(HeVAL(hent) - Nullsv), HeKEY(hent)); Safefree(hent); hent = next; } @@ -3084,8 +3084,8 @@ Perl_moreswitches(pTHX_ char *s) PL_preambleav = newAV(); s++; { - char *start = s; - SV *sv = newSVpv("use assertions::activate", 24); + char * const start = s; + SV * const sv = newSVpv("use assertions::activate", 24); while(isALNUM(*s) || *s == ':') ++s; if (s != start) { sv_catpvn(sv, "::", 2); @@ -3266,7 +3266,7 @@ Gid_t getegid (void); #define DEBUG_SCOPE(where) \ DEBUG_l(WITH_THR(Perl_deb(aTHX_ "%s scope %ld at %s:%d\n", \ - where, PL_scopestack_ix, __FILE__, __LINE__))); + where, (long)PL_scopestack_ix, __FILE__, __LINE__))); @@ -122,7 +122,7 @@ PP(pp_regcomp) mg = mg_find(sv, PERL_MAGIC_qr); } if (mg) { - regexp *re = (regexp *)mg->mg_obj; + regexp * const re = (regexp *)mg->mg_obj; ReREFCNT_dec(PM_GETRE(pm)); PM_SETRE(pm, ReREFCNT_inc(re)); } @@ -280,7 +280,7 @@ PP(pp_substcont) } cx->sb_s = rx->endp[0] + orig; { /* Update the pos() information. */ - SV *sv = cx->sb_targ; + SV * const sv = cx->sb_targ; MAGIC *mg; I32 i; if (SvTYPE(sv) < SVt_PVMG) @@ -368,7 +368,7 @@ Perl_rxres_restore(pTHX_ void **rsp, REGEXP *rx) void Perl_rxres_free(pTHX_ void **rsp) { - UV *p = (UV*)*rsp; + UV * const p = (UV*)*rsp; if (p) { #ifdef PERL_POISON @@ -1075,7 +1075,7 @@ PP(pp_flip) } else { dTOPss; - SV *targ = PAD_SV(PL_op->op_targ); + SV * const targ = PAD_SV(PL_op->op_targ); int flip = 0; if (PL_op->op_private & OPpFLIP_LINENUM) { @@ -1083,8 +1083,9 @@ PP(pp_flip) flip = SvIV(sv) == (IV)IoLINES(GvIOp(PL_last_in_gv)); } else { - GV *gv = gv_fetchpv(".", TRUE, SVt_PV); - if (gv && GvSV(gv)) flip = SvIV(sv) == SvIV(GvSV(gv)); + GV * const gv = gv_fetchpv(".", TRUE, SVt_PV); + if (gv && GvSV(gv)) + flip = SvIV(sv) == SvIV(GvSV(gv)); } } else { flip = SvTRUE(sv); @@ -1150,7 +1151,7 @@ PP(pp_flop) } } else { - SV *final = sv_mortalcopy(right); + SV * const final = sv_mortalcopy(right); STRLEN len; const char *tmps = SvPV_const(final, len); @@ -1470,7 +1471,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen) PL_curcop = cx->blk_oldcop; if (optype == OP_REQUIRE) { - const char* msg = SvPVx_nolen_const(ERRSV); + const char* const msg = SvPVx_nolen_const(ERRSV); SV * const nsv = cx->blk_eval.old_namesv; (void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv), &PL_sv_undef, 0); @@ -3093,7 +3094,6 @@ PP(pp_require) STRLEN len; const char *tryname = Nullch; SV *namesv = Nullsv; - SV** svp; const I32 gimme = GIMME_V; PerlIO *tryrsfp = 0; int filter_has_file = 0; @@ -3130,12 +3130,14 @@ PP(pp_require) if (!(name && len > 0 && *name)) DIE(aTHX_ "Null filename used"); TAINT_PROPER("require"); - if (PL_op->op_type == OP_REQUIRE && - (svp = hv_fetch(GvHVn(PL_incgv), name, len, 0))) { - if (*svp != &PL_sv_undef) - RETPUSHYES; - else - DIE(aTHX_ "Compilation failed in require"); + if (PL_op->op_type == OP_REQUIRE) { + SV ** const svp = hv_fetch(GvHVn(PL_incgv), name, len, 0); + if ( svp ) { + if (*svp != &PL_sv_undef) + RETPUSHYES; + else + DIE(aTHX_ "Compilation failed in require"); + } } /* prepare to compile file */ @@ -3156,7 +3158,7 @@ PP(pp_require) } #endif if (!tryrsfp) { - AV *ar = GvAVn(PL_incgv); + AV * const ar = GvAVn(PL_incgv); I32 i; #ifdef VMS char *unixname; @@ -3339,15 +3341,15 @@ PP(pp_require) if (PL_op->op_type == OP_REQUIRE) { const char *msgstr = name; if(errno == EMFILE) { - SV *msg = sv_2mortal(newSVpv(msgstr,0)); + SV * const msg = sv_2mortal(newSVpv(msgstr,0)); sv_catpv(msg, ": "); sv_catpv(msg, Strerror(errno)); msgstr = SvPV_nolen_const(msg); } else { if (namesv) { /* did we lookup @INC? */ - SV *msg = sv_2mortal(newSVpv(msgstr,0)); - SV *dirmsgsv = NEWSV(0, 0); - AV *ar = GvAVn(PL_incgv); + SV * const msg = sv_2mortal(newSVpv(msgstr,0)); + SV * const dirmsgsv = NEWSV(0, 0); + AV * const ar = GvAVn(PL_incgv); I32 i; sv_catpvn(msg, " in @INC", 8); if (instr(SvPVX_const(msg), ".h ")) @@ -3376,11 +3378,12 @@ PP(pp_require) /* Assume success here to prevent recursive requirement. */ len = strlen(name); /* Check whether a hook in @INC has already filled %INC */ - if (!hook_sv || !(svp = hv_fetch(GvHVn(PL_incgv), name, len, 0))) { - (void)hv_store(GvHVn(PL_incgv), name, len, - (hook_sv ? SvREFCNT_inc(hook_sv) - : newSVpv(CopFILE(&PL_compiling), 0)), - 0 ); + if (!hook_sv) { + (void)hv_store(GvHVn(PL_incgv), name, len, newSVpv(CopFILE(&PL_compiling),0),0); + } else { + SV** const svp = hv_fetch(GvHVn(PL_incgv), name, len, 0); + if (!svp) + (void)hv_store(GvHVn(PL_incgv), name, len, SvREFCNT_inc(hook_sv), 0 ); } ENTER; @@ -10174,27 +10174,27 @@ Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, const void *sv) /* add a new entry to a pointer-mapping table */ void -Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, const void *oldv, void *newv) +Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, const void *oldsv, void *newsv) { PTR_TBL_ENT_t *tblent, **otblent; /* XXX this may be pessimal on platforms where pointers aren't good * hash values e.g. if they grow faster in the most significant * bits */ - const UV hash = PTR_TABLE_HASH(oldv); + const UV hash = PTR_TABLE_HASH(oldsv); bool empty = 1; assert(tbl); otblent = &tbl->tbl_ary[hash & tbl->tbl_max]; for (tblent = *otblent; tblent; empty=0, tblent = tblent->next) { - if (tblent->oldval == oldv) { - tblent->newval = newv; + if (tblent->oldval == oldsv) { + tblent->newval = newsv; return; } } new_body_inline(tblent, (void**)&PL_pte_arenaroot, (void**)&PL_pte_root, sizeof(struct ptr_tbl_ent)); - tblent->oldval = oldv; - tblent->newval = newv; + tblent->oldval = oldsv; + tblent->newval = newsv; tblent->next = *otblent; *otblent = tblent; tbl->tbl_items++; @@ -240,7 +240,7 @@ will be returned if it is valid, otherwise 0. STRLEN Perl_is_utf8_char(pTHX_ const U8 *s) { - STRLEN len = UTF8SKIP(s); + const STRLEN len = UTF8SKIP(s); #ifdef IS_UTF8_CHAR if (IS_UTF8_CHAR_FAST(len)) return IS_UTF8_CHAR(s, len) ? len : 0; @@ -267,7 +267,7 @@ Perl_is_utf8_string(pTHX_ const U8 *s, STRLEN len) const U8* x = s; const U8* send; - if (!len && s) + if (!len) len = strlen((const char *)s); send = s + len; @@ -323,7 +323,7 @@ Perl_is_utf8_string_loclen(pTHX_ const U8 *s, STRLEN len, const U8 **ep, STRLEN const U8* send; STRLEN c; - if (!len && s) + if (!len) len = strlen((const char *)s); send = s + len; if (el) @@ -543,7 +543,7 @@ malformed: } if (dowarn) { - SV* sv = sv_2mortal(newSVpv("Malformed UTF-8 character ", 0)); + SV* const sv = sv_2mortal(newSVpv("Malformed UTF-8 character ", 0)); switch (warning) { case 0: /* Intentionally empty. */ break; @@ -590,7 +590,7 @@ malformed: } if (warning) { - const char *s = SvPVX_const(sv); + const char * const s = SvPVX_const(sv); if (PL_op) Perl_warner(aTHX_ packWARN(WARN_UTF8), @@ -132,10 +132,11 @@ modify_SV_attributes(pTHX_ SV *sv, SV **retlist, SV **attrlist, int numattrs) case 'e': if (memEQ(name, "uniqu", 5)) { if (SvTYPE(sv) == SVt_PVGV) { - if (negated) + if (negated) { GvUNIQUE_off(sv); - else + } else { GvUNIQUE_on(sv); + } } /* Hope this came from toke.c if not a GV. */ continue; |