summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2005-10-04 10:16:05 -0500
committerH.Merijn Brand <h.m.brand@xs4all.nl>2005-10-05 15:34:09 +0000
commit44f8325f4c9b3aaf24b47f4da7dce3e8170dcf42 (patch)
tree79ae96444551bc3a112d7601282f544236b6cdfb
parent5f0135ebccd6cdb2441aabb64baa39aea87199d3 (diff)
downloadperl-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.c2
-rw-r--r--pad.c8
-rw-r--r--perl.c14
-rw-r--r--perl.h2
-rw-r--r--pp_ctl.c53
-rw-r--r--sv.c12
-rw-r--r--utf8.c10
-rw-r--r--xsutils.c5
8 files changed, 55 insertions, 51 deletions
diff --git a/malloc.c b/malloc.c
index 4ec2174343..a33155093d 100644
--- a/malloc.c
+++ b/malloc.c
@@ -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
diff --git a/pad.c b/pad.c
index c0e7a5b619..336d816083 100644
--- a/pad.c
+++ b/pad.c
@@ -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--) {
diff --git a/perl.c b/perl.c
index 3cb25ea51e..7f663b1cad 100644
--- a/perl.c
+++ b/perl.c
@@ -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);
diff --git a/perl.h b/perl.h
index 148ce61b3e..e8bf99fc59 100644
--- a/perl.h
+++ b/perl.h
@@ -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__)));
diff --git a/pp_ctl.c b/pp_ctl.c
index beab0bf87b..b2e43a7289 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -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;
diff --git a/sv.c b/sv.c
index 3581b50125..9bb43e79f8 100644
--- a/sv.c
+++ b/sv.c
@@ -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++;
diff --git a/utf8.c b/utf8.c
index 2a88a4503f..66642c5fa1 100644
--- a/utf8.c
+++ b/utf8.c
@@ -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),
diff --git a/xsutils.c b/xsutils.c
index 848fc958d0..86620083af 100644
--- a/xsutils.c
+++ b/xsutils.c
@@ -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;