This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorAndy Lester <andy@petdance.com>
Sun, 29 May 2005 00:19:06 +0000 (19:19 -0500)
committerNicholas Clark <nick@ccl4.org>
Mon, 19 Sep 2005 18:04:59 +0000 (18:04 +0000)
[ 24622]
Subject: [PATCH] Minor warning squashings
Date: Sun, 29 May 2005 00:19:06 -0500
Message-Id: <740ea3aca85400c6d03e945323badad4@petdance.com>

Subject: [PATCH] Consting in Opcode.xs
From: Andy Lester <andy@petdance.com>
Date: Sun, 29 May 2005 11:23:50 -0500
Message-ID: <20050529162350.GA13965@petdance.com>

Subject: [PATCH] consting attrs.xs
From: Andy Lester <andy@petdance.com>
Date: Sun, 29 May 2005 14:15:46 -0500
Message-ID: <20050529191546.GA15581@petdance.com>

Subject: [PATCH] consting B.xs
From: Andy Lester <andy@petdance.com>
Date: Sun, 29 May 2005 15:09:24 -0500
Message-ID: <20050529200924.GA15873@petdance.com>

[ 24625]
Subject: [PATCH] More embed.fnc strictures, plus consting and localizing
From: Andy Lester <andy@petdance.com>
Date: Tue, 24 May 2005 11:47:22 -0500
Message-ID: <20050524164722.GC12027@petdance.com>

Subject: [PATCH] Remove unused casts
From: Andy Lester <andy@petdance.com>
Date: Tue, 24 May 2005 11:42:18 -0500
Message-ID: <20050524164218.GB12027@petdance.com>
p4raw-link: @24625 on //depot/perl: 1df70142a966e14eb7ff3560d69bddb190dbe2ba
p4raw-link: @24622 on //depot/perl: 5d7488b2fd9fa6515201f39bec25777d9fccd7db

p4raw-id: //depot/maint-5.8/perl@25495
p4raw-integrated: from //depot/perl@25494 'copy in' ext/attrs/attrs.xs
(@15378..)
p4raw-integrated: from //depot/perl@24625 'edit in' regexec.c
(@24489..) sv.c (@24619..) embed.fnc regcomp.c (@24622..)
'merge in' scope.c (@24508..) op.c (@24584..)
p4raw-integrated: from //depot/perl@24622 'edit in' pp_sys.c (@24561..)
'merge in' ext/Opcode/Opcode.xs (@24526..) ext/B/B.xs
(@24538..) perlio.c utf8.c (@24561..) proto.h (@24619..)

13 files changed:
embed.fnc
ext/B/B.xs
ext/Opcode/Opcode.xs
ext/attrs/attrs.xs
op.c
perlio.c
pp_sys.c
proto.h
regcomp.c
regexec.c
scope.c
sv.c
utf8.c

index 53e9df8..6ab6a76 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -360,22 +360,22 @@ ApPR      |bool   |is_uni_xdigit_lc|UV c
 Apd    |STRLEN |is_utf8_char   |NN U8 *p
 Apd    |bool   |is_utf8_string |NN U8 *s|STRLEN len
 Apd    |bool   |is_utf8_string_loc|NN U8 *s|STRLEN len|NN U8 **p
-Ap     |bool   |is_utf8_alnum  |NN U8 *p
-Ap     |bool   |is_utf8_alnumc |NN U8 *p
-Ap     |bool   |is_utf8_idfirst|NN U8 *p
-Ap     |bool   |is_utf8_idcont |NN U8 *p
-Ap     |bool   |is_utf8_alpha  |NN U8 *p
-Ap     |bool   |is_utf8_ascii  |NN U8 *p
-Ap     |bool   |is_utf8_space  |NN U8 *p
-Ap     |bool   |is_utf8_cntrl  |NN U8 *p
-Ap     |bool   |is_utf8_digit  |NN U8 *p
-Ap     |bool   |is_utf8_graph  |NN U8 *p
-Ap     |bool   |is_utf8_upper  |NN U8 *p
-Ap     |bool   |is_utf8_lower  |NN U8 *p
-Ap     |bool   |is_utf8_print  |NN U8 *p
-Ap     |bool   |is_utf8_punct  |NN U8 *p
-Ap     |bool   |is_utf8_xdigit |NN U8 *p
-Ap     |bool   |is_utf8_mark   |NN U8 *p
+ApR    |bool   |is_utf8_alnum  |NN U8 *p
+ApR    |bool   |is_utf8_alnumc |NN U8 *p
+ApR    |bool   |is_utf8_idfirst|NN U8 *p
+ApR    |bool   |is_utf8_idcont |NN U8 *p
+ApR    |bool   |is_utf8_alpha  |NN U8 *p
+ApR    |bool   |is_utf8_ascii  |NN U8 *p
+ApR    |bool   |is_utf8_space  |NN U8 *p
+ApR    |bool   |is_utf8_cntrl  |NN U8 *p
+ApR    |bool   |is_utf8_digit  |NN U8 *p
+ApR    |bool   |is_utf8_graph  |NN U8 *p
+ApR    |bool   |is_utf8_upper  |NN U8 *p
+ApR    |bool   |is_utf8_lower  |NN U8 *p
+ApR    |bool   |is_utf8_print  |NN U8 *p
+ApR    |bool   |is_utf8_punct  |NN U8 *p
+ApR    |bool   |is_utf8_xdigit |NN U8 *p
+ApR    |bool   |is_utf8_mark   |NN U8 *p
 p      |OP*    |jmaybe         |NN OP* arg
 pP     |I32    |keyword        |NN char* d|I32 len
 Ap     |void   |leave_scope    |I32 base
@@ -569,8 +569,8 @@ p   |void   |package        |OP* o
 pd     |PADOFFSET|pad_alloc    |I32 optype|U32 tmptype
 p      |PADOFFSET|allocmy      |NN char* name
 pd     |PADOFFSET|pad_findmy   |NN char* name
-p      |OP*    |oopsAV         |NN OP* o
-p      |OP*    |oopsHV         |NN OP* o
+pR     |OP*    |oopsAV         |NN OP* o
+pR     |OP*    |oopsHV         |NN OP* o
 pd     |void   |pad_leavemy
 Apd    |SV*    |pad_sv         |PADOFFSET po
 pd     |void   |pad_free       |PADOFFSET po
@@ -635,7 +635,7 @@ Ap  |SV*    |re_intuit_string|regexp* prog
 Ap     |I32    |regexec_flags  |NN regexp* prog|NN char* stringarg \
                                |NN char* strend|NN char* strbeg|I32 minend \
                                |SV* screamer|void* data|U32 flags
-Ap     |regnode*|regnext       |regnode* p
+ApR    |regnode*|regnext       |NN regnode* p
 Ep     |void   |regprop        |SV* sv|regnode* o
 Ap     |void   |repeatcpy      |NN char* to|NN const char* from|I32 len|I32 count
 ApP    |char*  |rninstr        |NN const char* big|NN const char* bigend \
@@ -749,7 +749,7 @@ Apd |void   |sv_clear       |NN SV* sv
 Apd    |I32    |sv_cmp         |NN SV* sv1|NN SV* sv2
 Apd    |I32    |sv_cmp_locale  |NN SV* sv1|NN SV* sv2
 #if defined(USE_LOCALE_COLLATE)
-Apd    |char*  |sv_collxfrm    |NN SV* sv|STRLEN* nxp
+Apd    |char*  |sv_collxfrm    |NN SV* sv|NN STRLEN* nxp
 #endif
 Ap     |OP*    |sv_compile_2op |NN SV* sv|NN OP** startp|NN char* code|NN PAD** padp
 Apd    |int    |getcwd_sv      |NN SV* sv
@@ -1016,13 +1016,13 @@ s       |void   |require_errno  |NN GV *gv
 #if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
 s      |void   |hsplit         |HV *hv
 s      |void   |hfreeentries   |HV *hv
-s      |HE*    |new_he
-s      |void   |del_he         |HE *p
-s      |HEK*   |save_hek_flags |const char *str|I32 len|U32 hash|int flags
-s      |void   |hv_magic_check |HV *hv|bool *needs_copy|bool *needs_store
-s      |void   |unshare_hek_or_pvn|HEK* hek|const char* sv|I32 len|U32 hash
-s      |HEK*   |share_hek_flags|const char* sv|I32 len|U32 hash|int flags
-rs     |void   |hv_notallowed  |int flags|const char *key|I32 klen|const char *msg
+sR     |HE*    |new_he
+s      |void   |del_he         |NN HE *p
+sR     |HEK*   |save_hek_flags |NN const char *str|I32 len|U32 hash|int flags
+s      |void   |hv_magic_check |NN HV *hv|NN bool *needs_copy|NN bool *needs_store
+s      |void   |unshare_hek_or_pvn|HEK* hek|NN const char* sv|I32 len|U32 hash
+sR     |HEK*   |share_hek_flags|const char* sv|I32 len|U32 hash|int flags
+rs     |void   |hv_notallowed  |int flags|NN const char *key|I32 klen|NN const char *msg
 #endif
 
 #if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT)
@@ -1105,7 +1105,7 @@ s |char * |group_end      |NN char *pat|NN char *patend|char ender
 s      |char * |get_num        |NN char *ppat|NN I32 *
 s      |bool   |next_symbol    |NN tempsym_t* symptr
 s      |void   |doencodes      |SV* sv|char* s|I32 len
-s      |SV*    |is_an_int      |NN char *s|STRLEN l
+sR     |SV*    |is_an_int      |NN char *s|STRLEN l
 s      |int    |div128         |NN SV *pnum|NN bool *done
 #endif
 
@@ -1553,3 +1553,6 @@ ApR       |OP*    |ck_unpack      |NN OP *o
 #endif
 
 END_EXTERN_C
+/*
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */
index 4324cfa..94d24eb 100644 (file)
@@ -101,7 +101,7 @@ START_MY_CXT
 #define specialsv_list         (MY_CXT.x_specialsv_list)
 
 static opclass
-cc_opclass(pTHX_ OP *o)
+cc_opclass(pTHX_ const OP *o)
 {
     if (!o)
        return OPc_NULL;
@@ -209,7 +209,7 @@ cc_opclass(pTHX_ OP *o)
 }
 
 static char *
-cc_opclassname(pTHX_ OP *o)
+cc_opclassname(pTHX_ const OP *o)
 {
     return opclassnames[cc_opclass(aTHX_ o)];
 }
@@ -246,32 +246,28 @@ static SV *
 cstring(pTHX_ SV *sv, bool perlstyle)
 {
     SV *sstr = newSVpvn("", 0);
-    STRLEN len;
-    char *s;
-    char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */
 
     if (!SvOK(sv))
        sv_setpvn(sstr, "0", 1);
-    else if (perlstyle && SvUTF8(sv))
-    {
+    else if (perlstyle && SvUTF8(sv)) {
        SV *tmpsv = sv_newmortal(); /* Temporary SV to feed sv_uni_display */
-       len = SvCUR(sv);
-       s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
+       const STRLEN len = SvCUR(sv);
+       const char *s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
        sv_setpvn(sstr,"\"",1);
        while (*s)
        {
            if (*s == '"')
-               sv_catpv(sstr, "\\\"");
+               sv_catpvn(sstr, "\\\"", 2);
            else if (*s == '$')
-               sv_catpv(sstr, "\\$");
+               sv_catpvn(sstr, "\\$", 2);
            else if (*s == '@')
-               sv_catpv(sstr, "\\@");
+               sv_catpvn(sstr, "\\@", 2);
            else if (*s == '\\')
            {
                if (strchr("nrftax\\",*(s+1)))
                    sv_catpvn(sstr, s++, 2);
                else
-                   sv_catpv(sstr, "\\\\");
+                   sv_catpvn(sstr, "\\\\", 2);
            }
            else /* should always be printable */
                sv_catpvn(sstr, s, 1);
@@ -283,7 +279,8 @@ cstring(pTHX_ SV *sv, bool perlstyle)
     else
     {
        /* XXX Optimise? */
-       s = SvPV(sv, len);
+       STRLEN len;
+       const char *s = SvPV(sv, len);
        sv_catpv(sstr, "\"");
        for (; len; len--, s++)
        {
@@ -293,8 +290,8 @@ cstring(pTHX_ SV *sv, bool perlstyle)
            else if (*s == '\\')
                sv_catpv(sstr, "\\\\");
             /* trigraphs - bleagh */
-            else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?')
-            {
+            else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?') {
+               char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */
                 sprintf(escbuff, "\\%03o", '?');
                 sv_catpv(sstr, escbuff);
             }
@@ -325,7 +322,8 @@ cstring(pTHX_ SV *sv, bool perlstyle)
            else
            {
                /* Don't want promotion of a signed -1 char in sprintf args */
-               unsigned char c = (unsigned char) *s;
+               char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */
+               const unsigned char c = (unsigned char) *s;
                sprintf(escbuff, "\\%03o", c);
                sv_catpv(sstr, escbuff);
            }
@@ -340,13 +338,12 @@ static SV *
 cchar(pTHX_ SV *sv)
 {
     SV *sstr = newSVpvn("'", 1);
-    STRLEN n_a;
-    char *s = SvPV(sv, n_a);
+    const char *s = SvPV_nolen(sv);
 
     if (*s == '\'')
-       sv_catpv(sstr, "\\'");
+       sv_catpvn(sstr, "\\'", 2);
     else if (*s == '\\')
-       sv_catpv(sstr, "\\\\");
+       sv_catpvn(sstr, "\\\\", 2);
 #ifdef EBCDIC
     else if (isPRINT(*s))
 #else
@@ -354,19 +351,19 @@ cchar(pTHX_ SV *sv)
 #endif /* EBCDIC */
        sv_catpvn(sstr, s, 1);
     else if (*s == '\n')
-       sv_catpv(sstr, "\\n");
+       sv_catpvn(sstr, "\\n", 2);
     else if (*s == '\r')
-       sv_catpv(sstr, "\\r");
+       sv_catpvn(sstr, "\\r", 2);
     else if (*s == '\t')
-       sv_catpv(sstr, "\\t");
+       sv_catpvn(sstr, "\\t", 2);
     else if (*s == '\a')
-       sv_catpv(sstr, "\\a");
+       sv_catpvn(sstr, "\\a", 2);
     else if (*s == '\b')
-       sv_catpv(sstr, "\\b");
+       sv_catpvn(sstr, "\\b", 2);
     else if (*s == '\f')
-       sv_catpv(sstr, "\\f");
+       sv_catpvn(sstr, "\\f", 2);
     else if (*s == '\v')
-       sv_catpv(sstr, "\\v");
+       sv_catpvn(sstr, "\\v", 2);
     else
     {
        /* no trigraph support */
@@ -376,12 +373,12 @@ cchar(pTHX_ SV *sv)
        sprintf(escbuff, "\\%03o", c);
        sv_catpv(sstr, escbuff);
     }
-    sv_catpv(sstr, "'");
+    sv_catpvn(sstr, "'", 1);
     return sstr;
 }
 
-void
-walkoptree(pTHX_ SV *opsv, char *method)
+static void
+walkoptree(pTHX_ SV *opsv, const char *method)
 {
     dSP;
     OP *o, *kid;
@@ -416,7 +413,7 @@ walkoptree(pTHX_ SV *opsv, char *method)
     }
 }
 
-SV **
+static SV **
 oplist(pTHX_ OP *o, SV **SP)
 {
     for(; o; o = o->op_next) {
@@ -605,7 +602,7 @@ MODULE = B  PACKAGE = B
 void
 walkoptree(opsv, method)
        SV *    opsv
-       char *  method
+       const char *    method
     CODE:
        walkoptree(aTHX_ opsv, method);
 
@@ -637,7 +634,7 @@ svref_2object(sv)
 
 void
 opnumber(name)
-char * name
+const char *   name
 CODE:
 {
  int i; 
@@ -670,11 +667,10 @@ void
 hash(sv)
        SV *    sv
     CODE:
-       char *s;
        STRLEN len;
        U32 hash = 0;
        char hexhash[19]; /* must fit "0xffffffffffffffff" plus trailing \0 */
-       s = SvPV(sv, len);
+       const char *s = SvPV(sv, len);
        PERL_HASH(hash, s, len);
        sprintf(hexhash, "0x%"UVxf, (UV)hash);
        ST(0) = sv_2mortal(newSVpv(hexhash, 0));
@@ -724,7 +720,7 @@ threadsv_names()
 #if PERL_VERSION <= 8
 # ifdef USE_5005THREADS
        int i;
-       STRLEN len = strlen(PL_threadsv_names);
+       const STRLEN len = strlen(PL_threadsv_names);
 
        EXTEND(sp, len);
        for (i = 0; i < len; i++)
@@ -1011,8 +1007,8 @@ PVOP_pv(o)
                (o->op_private & OPpTRANS_COMPLEMENT) &&
                !(o->op_private & OPpTRANS_DELETE))
        {
-           short* tbl = (short*)o->op_pv;
-           short entries = 257 + tbl[256];
+           const short* const tbl = (short*)o->op_pv;
+           const short entries = 257 + tbl[256];
            ST(0) = sv_2mortal(newSVpv(o->op_pv, entries * sizeof(short)));
        }
        else if (o->op_type == OP_TRANS) {
@@ -1158,7 +1154,7 @@ packiv(sv)
     CODE:
        if (sizeof(IV) == 8) {
            U32 wp[2];
-           IV iv = SvIVX(sv);
+           const IV iv = SvIVX(sv);
            /*
             * The following way of spelling 32 is to stop compilers on
             * 32-bit architectures from moaning about the shift count
@@ -1519,7 +1515,7 @@ IoSUBPROCESS(io)
 bool
 IsSTD(io,name)
        B::IO   io
-       char*   name
+       const char*     name
     PREINIT:
        PerlIO* handle = 0;
     CODE:
index 95d3495..805c1e2 100644 (file)
@@ -25,9 +25,9 @@ START_MY_CXT
 
 static SV  *new_opset (pTHX_ SV *old_opset);
 static int  verify_opset (pTHX_ SV *opset, int fatal);
-static void set_opset_bits (pTHX_ char *bitmap, SV *bitspec, int on, char *opname);
-static void put_op_bitspec (pTHX_ char *optag,  STRLEN len, SV *opset);
-static SV  *get_op_bitspec (pTHX_ char *opname, STRLEN len, int fatal);
+static void set_opset_bits (pTHX_ char *bitmap, SV *bitspec, int on, const char *opname);
+static void put_op_bitspec (pTHX_ const char *optag,  STRLEN len, SV *opset);
+static SV  *get_op_bitspec (pTHX_ const char *opname, STRLEN len, int fatal);
 
 
 /* Initialise our private op_named_bits HV.
@@ -50,8 +50,7 @@ op_names_init(pTHX)
     op_named_bits = newHV();
     op_names = get_op_names();
     for(i=0; i < PL_maxo; ++i) {
-       SV *sv;
-       sv = newSViv(i);
+       SV * const sv = newSViv(i);
        SvREADONLY_on(sv);
        hv_store(op_named_bits, op_names[i], strlen(op_names[i]), sv, 0);
     }
@@ -75,7 +74,7 @@ op_names_init(pTHX)
  */
 
 static void
-put_op_bitspec(pTHX_ char *optag, STRLEN len, SV *mask)
+put_op_bitspec(pTHX_ const char *optag, STRLEN len, SV *mask)
 {
     SV **svp;
     dMY_CXT;
@@ -98,7 +97,7 @@ put_op_bitspec(pTHX_ char *optag, STRLEN len, SV *mask)
  */
 
 static SV *
-get_op_bitspec(pTHX_ char *opname, STRLEN len, int fatal)
+get_op_bitspec(pTHX_ const char *opname, STRLEN len, int fatal)
 {
     SV **svp;
     dMY_CXT;
@@ -146,7 +145,7 @@ new_opset(pTHX_ SV *old_opset)
 static int
 verify_opset(pTHX_ SV *opset, int fatal)
 {
-    char *err = Nullch;
+    const char *err = Nullch;
     dMY_CXT;
 
     if      (!SvOK(opset))              err = "undefined";
@@ -160,14 +159,14 @@ verify_opset(pTHX_ SV *opset, int fatal)
 
 
 static void
-set_opset_bits(pTHX_ char *bitmap, SV *bitspec, int on, char *opname)
+set_opset_bits(pTHX_ char *bitmap, SV *bitspec, int on, const char *opname)
 {
     dMY_CXT;
 
     if (SvIOK(bitspec)) {
-       int myopcode = SvIV(bitspec);
-       int offset = myopcode >> 3;
-       int bit    = myopcode & 0x07;
+       const int myopcode = SvIV(bitspec);
+       const int offset = myopcode >> 3;
+       const int bit    = myopcode & 0x07;
        if (myopcode >= PL_maxo || myopcode < 0)
            croak("panic: opcode \"%s\" value %d is invalid", opname, myopcode);
        if (opcode_debug >= 2)
@@ -181,7 +180,7 @@ set_opset_bits(pTHX_ char *bitmap, SV *bitspec, int on, char *opname)
     else if (SvPOK(bitspec) && SvCUR(bitspec) == (STRLEN)opset_len) {
 
        STRLEN len;
-       char *specbits = SvPV(bitspec, len);
+       const char * const specbits = SvPV(bitspec, len);
        if (opcode_debug >= 2)
            warn("set_opset_bits opset %s %s\n", opname, (on)?"on":"off");
        if (on) 
@@ -213,7 +212,7 @@ opmask_add(pTHX_ SV *opset) /* THE ONLY FUNCTION TO EDIT PL_op_mask ITSELF  */
 
     bitmask = SvPV(opset, len);
     for (i=0; i < opset_len; i++) {
-       U16 bits = bitmask[i];
+       const U16 bits = bitmask[i];
        if (!bits) {    /* optimise for sparse masks */
            myopcode += 8;
            continue;
@@ -261,7 +260,7 @@ BOOT:
 
 void
 _safe_pkg_prep(Package)
-    char *     Package
+    const char *Package
 PPCODE:
     HV *hv; 
     ENTER;
@@ -359,13 +358,13 @@ PPCODE:
     {
     STRLEN len;
     int i, j, myopcode;
-    char *bitmap = SvPV(opset, len);
+    const char * const bitmap = SvPV(opset, len);
     char **names = (desc) ? get_op_descs() : get_op_names();
     dMY_CXT;
 
     verify_opset(aTHX_ opset,1);
     for (myopcode=0, i=0; i < opset_len; i++) {
-       U16 bits = bitmap[i];
+       const U16 bits = bitmap[i];
        for (j=0; j < 8 && myopcode < PL_maxo; j++, myopcode++) {
            if ( bits & (1 << j) )
                XPUSHs(sv_2mortal(newSVpv(names[myopcode], 0)));
@@ -378,14 +377,13 @@ void
 opset(...)
 CODE:
     int i;
-    SV *bitspec, *opset;
-    char *bitmap;
+    SV *bitspec;
     STRLEN len, on;
 
-    opset = sv_2mortal(new_opset(aTHX_ Nullsv));
-    bitmap = SvPVX(opset);
+    SV * const opset = sv_2mortal(new_opset(aTHX_ Nullsv));
+    char * const bitmap = SvPVX(opset);
     for (i = 0; i < items; i++) {
-       char *opname;
+       const char *opname;
        on = 1;
        if (verify_opset(aTHX_ ST(i),0)) {
            opname = "(opset)";
@@ -412,9 +410,9 @@ ALIAS:
        deny_only = 2
        deny      = 3
 CODE:
-    int i, on;
+    int i;
     SV *bitspec, *mask;
-    char *bitmap, *opname;
+    char *bitmap;
     STRLEN len;
     dMY_CXT;
 
@@ -427,7 +425,8 @@ CODE:
        verify_opset(aTHX_ mask,1); /* croaks */
     bitmap = SvPVX(mask);
     for (i = 1; i < items; i++) {
-       on = PERMITING ? 0 : 1;         /* deny = mask bit on   */
+       const char *opname;
+       int on = PERMITING ? 0 : 1;             /* deny = mask bit on   */
        if (verify_opset(aTHX_ ST(i),0)) {      /* it's a valid mask    */
            opname = "(opset)";
            bitspec = ST(i);
@@ -447,7 +446,7 @@ CODE:
 void
 opdesc(...)
 PPCODE:
-    int i, myopcode;
+    int i;
     STRLEN len;
     SV **args;
     char **op_desc = get_op_descs(); 
@@ -457,10 +456,10 @@ PPCODE:
     /* the stack faster than we read values off it if masks are used.  */
     args = (SV**)SvPVX(sv_2mortal(newSVpvn((char*)&ST(0), items*sizeof(SV*))));
     for (i = 0; i < items; i++) {
-       char *opname = SvPV(args[i], len);
+       const char * const opname = SvPV(args[i], len);
        SV *bitspec = get_op_bitspec(aTHX_ opname, len, 1);
        if (SvIOK(bitspec)) {
-           myopcode = SvIV(bitspec);
+           const int myopcode = SvIV(bitspec);
            if (myopcode < 0 || myopcode >= PL_maxo)
                croak("panic: opcode %d (%s) out of range",myopcode,opname);
            XPUSHs(sv_2mortal(newSVpv(op_desc[myopcode], 0)));
@@ -468,10 +467,10 @@ PPCODE:
        else if (SvPOK(bitspec) && SvCUR(bitspec) == (STRLEN)opset_len) {
            int b, j;
            STRLEN n_a;
-           char *bitmap = SvPV(bitspec,n_a);
-           myopcode = 0;
+           const char * const bitmap = SvPV(bitspec,n_a);
+           int myopcode = 0;
            for (b=0; b < opset_len; b++) {
-               U16 bits = bitmap[b];
+               const U16 bits = bitmap[b];
                for (j=0; j < 8 && myopcode < PL_maxo; j++, myopcode++)
                    if (bits & (1 << j))
                        XPUSHs(sv_2mortal(newSVpv(op_desc[myopcode], 0)));
@@ -489,7 +488,7 @@ define_optag(optagsv, mask)
     SV *mask
 CODE:
     STRLEN len;
-    char *optag = SvPV(optagsv, len);
+    const char *optag = SvPV(optagsv, len);
 
     put_op_bitspec(aTHX_ optag, len, mask); /* croaks */
     ST(0) = &PL_sv_yes;
@@ -530,7 +529,7 @@ opmask()
 CODE:
     ST(0) = sv_2mortal(new_opset(aTHX_ Nullsv));
     if (PL_op_mask) {
-       char *bitmap = SvPVX(ST(0));
+       char * const bitmap = SvPVX(ST(0));
        int myopcode;
        for(myopcode=0; myopcode < PL_maxo; ++myopcode) {
            if (PL_op_mask[myopcode])
index 73f100d..e3ba012 100644 (file)
@@ -4,7 +4,7 @@
 #include "XSUB.h"
 
 static cv_flags_t
-get_flag(char *attr)
+get_flag(const char *attr)
 {
     if (strnEQ(attr, "method", 6))
        return CVf_METHOD;
@@ -32,9 +32,8 @@ import(...)
                        "pragma \"attrs\" is deprecated, "
                        "use \"sub NAME : ATTRS\" instead");
        for (i = 1; i < items; i++) {
-           STRLEN n_a;
-           char *attr = SvPV(ST(i), n_a);
-           cv_flags_t flag = get_flag(attr);
+           const char * const attr = SvPV_nolen(ST(i));
+           const cv_flags_t flag = get_flag(attr);
            if (!flag)
                croak("invalid attribute name %s", attr);
            if (ix)
@@ -53,8 +52,7 @@ SV *  sub
                sub = Nullsv;
        }
        else {
-           STRLEN n_a;
-           char *name = SvPV(sub, n_a);
+           const char * const name = SvPV_nolen(sub);
            sub = (SV*)perl_get_cv(name, FALSE);
        }
        if (!sub)
diff --git a/op.c b/op.c
index e6c40ee..55ea1b9 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4600,6 +4600,7 @@ Perl_newXS(pTHX_ char *name, XSUBADDR_t subaddr, char *filename)
        }
        else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
            /* already defined (or promised) */
+           /* XXX It's possible for this HvNAME_get to return null, and get passed into strEQ */
            if (ckWARN(WARN_REDEFINE) && !(CvGV(cv) && GvSTASH(CvGV(cv))
                            && strEQ(HvNAME_get(GvSTASH(CvGV(cv))), "autouse"))) {
                const line_t oldline = CopLINE(PL_curcop);
@@ -4907,8 +4908,8 @@ Perl_ck_bitop(pTHX_ OP *o)
             || o->op_type == OP_BIT_AND
             || o->op_type == OP_BIT_XOR))
     {
-       const OP * left = cBINOPo->op_first;
-       const OP * right = left->op_sibling;
+       const OP * const left = cBINOPo->op_first;
+       const OP * const right = left->op_sibling;
        if ((OP_IS_NUMCOMPARE(left->op_type) &&
                (left->op_flags & OPf_PARENS) == 0) ||
            (OP_IS_NUMCOMPARE(right->op_type) &&
index 08cdefa..ff98c77 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -2943,6 +2943,7 @@ PerlIOStdio_invalidate_fileno(pTHX_ FILE *f)
      */
 #    error "Don't know how to set FILE.fileno on your platform"
 #endif
+    (void)f;
     return 0;
 #  endif
 }
index d01a488..617ba73 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -303,6 +303,8 @@ S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
 STATIC int
 S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
 {
+    (void)path;
+    (void)mode;
     Perl_croak(aTHX_ "switching effective uid is not implemented");
     /*NOTREACHED*/
     return -1;
@@ -782,7 +784,7 @@ PP(pp_tie)
     HV* stash;
     GV *gv;
     SV *sv;
-    I32 markoff = MARK - PL_stack_base;
+    const I32 markoff = MARK - PL_stack_base;
     const char *methname;
     int how = PERL_MAGIC_tied;
     U32 items;
@@ -869,7 +871,7 @@ PP(pp_untie)
     dSP;
     MAGIC *mg;
     SV *sv = POPs;
-    char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
+    const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
                ? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
     if (SvTYPE(sv) == SVt_PVGV && !(sv = (SV *)GvIOp(sv)))
@@ -908,7 +910,7 @@ PP(pp_tied)
     dSP;
     MAGIC *mg;
     SV *sv = POPs;
-    char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
+    const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
                ? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
     if (SvTYPE(sv) == SVt_PVGV && !(sv = (SV *)GvIOp(sv)))
@@ -1154,10 +1156,10 @@ Perl_setdefout(pTHX_ GV *gv)
 PP(pp_select)
 {
     dSP; dTARGET;
-    GV *newdefout, *egv;
+    GV *egv;
     HV *hv;
 
-    newdefout = (PL_op->op_private > 0) ? ((GV *) POPs) : (GV *) NULL;
+    GV * const newdefout = (PL_op->op_private > 0) ? ((GV *) POPs) : (GV *) NULL;
 
     egv = GvEGV(PL_defoutgv);
     if (!egv)
@@ -1286,14 +1288,14 @@ PP(pp_enterwrite)
 
     cv = GvFORM(fgv);
     if (!cv) {
-        char *name = NULL;
        if (fgv) {
-           SV *tmpsv = sv_newmortal();
+           SV * const tmpsv = sv_newmortal();
+           char *name;
            gv_efullname4(tmpsv, fgv, Nullch, FALSE);
            name = SvPV_nolen(tmpsv);
+           if (name && *name)
+               DIE(aTHX_ "Undefined format \"%s\" called", name);
        }
-       if (name && *name)
-           DIE(aTHX_ "Undefined format \"%s\" called", name);
        DIE(aTHX_ "Not a format reference");
     }
     if (CvCLONE(cv))
@@ -1375,20 +1377,18 @@ PP(pp_leavewrite)
        if (!fgv)
            DIE(aTHX_ "bad top format reference");
        cv = GvFORM(fgv);
-       {
-           char *name = NULL;
-           if (!cv) {
-               SV *sv = sv_newmortal();
-               gv_efullname4(sv, fgv, Nullch, FALSE);
-               name = SvPV_nolen(sv);
-           }
+       if (!cv) {
+           SV * const sv = sv_newmortal();
+           char *name;
+           gv_efullname4(sv, fgv, Nullch, FALSE);
+           name = SvPV_nolen(sv);
            if (name && *name)
-               DIE(aTHX_ "Undefined top format \"%s\" called",name);
-           /* why no:
-           else
-               DIE(aTHX_ "Undefined top format called");
-           ?*/
+               DIE(aTHX_ "Undefined top format \"%s\" called",name);
        }
+       /* why no:
+       else
+           DIE(aTHX_ "Undefined top format called");
+       ?*/
        if (CvCLONE(cv))
            cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
        return doform(cv,gv,PL_op);
@@ -1512,13 +1512,9 @@ PP(pp_sysopen)
     SV *sv;
     char *tmps;
     STRLEN len;
-    int mode, perm;
+    const int perm = (MAXARG > 3) ? POPi : 0666;
+    const int mode = POPi;
 
-    if (MAXARG > 3)
-       perm = POPi;
-    else
-       perm = 0666;
-    mode = POPi;
     sv = POPs;
     gv = (GV *)POPs;
 
@@ -1738,7 +1734,7 @@ PP(pp_sysread)
     (void)SvPOK_only(read_target);
     if (fp_utf8 && !IN_BYTES) {
        /* Look at utf8 we got back and count the characters */
-       char *bend = buffer + count;
+       const char *bend = buffer + count;
        while (buffer < bend) {
            if (charstart) {
                skip = UTF8SKIP(buffer);
@@ -1792,7 +1788,7 @@ PP(pp_sysread)
 PP(pp_syswrite)
 {
     dSP;
-    int items = (SP - PL_stack_base) - TOPMARK;
+    const int items = (SP - PL_stack_base) - TOPMARK;
     if (items == 2) {
        SV *sv;
         EXTEND(SP, 1);
@@ -1909,9 +1905,8 @@ PP(pp_send)
     }
 #ifdef HAS_SOCKET
     else if (SP > MARK) {
-       char *sockbuf;
        STRLEN mlen;
-       sockbuf = SvPVx(*++MARK, mlen);
+       char * const sockbuf = SvPVx(*++MARK, mlen);
        /* length is really flags */
        retval = PerlSock_sendto(PerlIO_fileno(IoIFP(io)), buffer, blen,
                                 length, (struct sockaddr *)sockbuf, mlen);
@@ -2035,7 +2030,7 @@ PP(pp_sysseek)
     dSP;
     GV *gv;
     IO *io;
-    int whence = POPi;
+    const int whence = POPi;
 #if LSEEKSIZE > IVSIZE
     Off_t offset = (Off_t)SvNVx(POPs);
 #else
@@ -2188,7 +2183,7 @@ PP(pp_ioctl)
 {
     dSP; dTARGET;
     SV *argsv = POPs;
-    unsigned int func = POPu;
+    const unsigned int func = POPu;
     const int optype = PL_op->op_type;
     char *s;
     IV retval;
diff --git a/proto.h b/proto.h
index 5992855..358c41e 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -628,51 +628,67 @@ PERL_CALLCONV bool        Perl_is_utf8_string_loc(pTHX_ U8 *s, STRLEN len, U8 **p)
                        __attribute__nonnull__(pTHX_3);
 
 PERL_CALLCONV bool     Perl_is_utf8_alnum(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_alnumc(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_idfirst(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_idcont(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_alpha(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_ascii(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_space(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_cntrl(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_digit(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_graph(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_upper(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_lower(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_print(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_punct(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_xdigit(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool     Perl_is_utf8_mark(pTHX_ U8 *p)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV OP*      Perl_jmaybe(pTHX_ OP* arg)
@@ -1073,9 +1089,11 @@ PERL_CALLCONV PADOFFSET  Perl_pad_findmy(pTHX_ char* name)
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV OP*      Perl_oopsAV(pTHX_ OP* o)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV OP*      Perl_oopsHV(pTHX_ OP* o)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV void     Perl_pad_leavemy(pTHX);
@@ -1184,7 +1202,10 @@ PERL_CALLCONV I32        Perl_regexec_flags(pTHX_ regexp* prog, char* stringarg, char*
                        __attribute__nonnull__(pTHX_3)
                        __attribute__nonnull__(pTHX_4);
 
-PERL_CALLCONV regnode* Perl_regnext(pTHX_ regnode* p);
+PERL_CALLCONV regnode* Perl_regnext(pTHX_ regnode* p)
+                       __attribute__warn_unused_result__
+                       __attribute__nonnull__(pTHX_1);
+
 PERL_CALLCONV void     Perl_regprop(pTHX_ SV* sv, regnode* o);
 PERL_CALLCONV void     Perl_repeatcpy(pTHX_ char* to, const char* from, I32 len, I32 count)
                        __attribute__nonnull__(pTHX_1)
@@ -1397,7 +1418,8 @@ PERL_CALLCONV I32 Perl_sv_cmp_locale(pTHX_ SV* sv1, SV* sv2)
 
 #if defined(USE_LOCALE_COLLATE)
 PERL_CALLCONV char*    Perl_sv_collxfrm(pTHX_ SV* sv, STRLEN* nxp)
-                       __attribute__nonnull__(pTHX_1);
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_2);
 
 #endif
 PERL_CALLCONV OP*      Perl_sv_compile_2op(pTHX_ SV* sv, OP** startp, char* code, PAD** padp)
@@ -1817,14 +1839,31 @@ STATIC void     S_require_errno(pTHX_ GV *gv)
 #if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
 STATIC void    S_hsplit(pTHX_ HV *hv);
 STATIC void    S_hfreeentries(pTHX_ HV *hv);
-STATIC HE*     S_new_he(pTHX);
-STATIC void    S_del_he(pTHX_ HE *p);
-STATIC HEK*    S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags);
-STATIC void    S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store);
-STATIC void    S_unshare_hek_or_pvn(pTHX_ HEK* hek, const char* sv, I32 len, U32 hash);
-STATIC HEK*    S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags);
+STATIC HE*     S_new_he(pTHX)
+                       __attribute__warn_unused_result__;
+
+STATIC void    S_del_he(pTHX_ HE *p)
+                       __attribute__nonnull__(pTHX_1);
+
+STATIC HEK*    S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags)
+                       __attribute__warn_unused_result__
+                       __attribute__nonnull__(pTHX_1);
+
+STATIC void    S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store)
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_2)
+                       __attribute__nonnull__(pTHX_3);
+
+STATIC void    S_unshare_hek_or_pvn(pTHX_ HEK* hek, const char* sv, I32 len, U32 hash)
+                       __attribute__nonnull__(pTHX_2);
+
+STATIC HEK*    S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags)
+                       __attribute__warn_unused_result__;
+
 STATIC void    S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)
-                       __attribute__noreturn__;
+                       __attribute__noreturn__
+                       __attribute__nonnull__(pTHX_2)
+                       __attribute__nonnull__(pTHX_4);
 
 #endif
 
@@ -1970,6 +2009,7 @@ STATIC bool       S_next_symbol(pTHX_ tempsym_t* symptr)
 
 STATIC void    S_doencodes(pTHX_ SV* sv, char* s, I32 len);
 STATIC SV*     S_is_an_int(pTHX_ char *s, STRLEN l)
+                       __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
 
 STATIC int     S_div128(pTHX_ SV *pnum, bool *done)
@@ -2632,4 +2672,7 @@ PERL_CALLCONV OP* Perl_ck_unpack(pTHX_ OP *o)
 #endif
 
 END_EXTERN_C
+/*
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */
 /* ex: set ro: */
index 6cc0a87..0c05d4a 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1704,21 +1704,22 @@ S_add_data(pTHX_ RExC_state_t *pRExC_state, I32 n, const char *s)
 void
 Perl_reginitcolors(pTHX)
 {
-    int i = 0;
-    char *s = PerlEnv_getenv("PERL_RE_COLORS");
-       
+    const char * const s = PerlEnv_getenv("PERL_RE_COLORS");
     if (s) {
-       PL_colors[0] = s = savepv(s);
+       char *t = savepv(s);
+       int i = 0;
+       PL_colors[0] = t;
        while (++i < 6) {
-           s = strchr(s, '\t');
-           if (s) {
-               *s = '\0';
-               PL_colors[i] = ++s;
+           t = strchr(t, '\t');
+           if (t) {
+               *t = '\0';
+               PL_colors[i] = ++t;
            }
            else
-               PL_colors[i] = s = (char *)"";
+               PL_colors[i] = t = (char *)"";
        }
     } else {
+       int i = 0;
        while (i < 6)
            PL_colors[i++] = (char *)"";
     }
@@ -1921,13 +1922,10 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
            !(r->reganch & ROPT_ANCH) )
        {
            /* turn .* into ^.* with an implied $*=1 */
-           int type = OP(NEXTOPER(first));
-
-           if (type == REG_ANY)
-               type = ROPT_ANCH_MBOL;
-           else
-               type = ROPT_ANCH_SBOL;
-
+           const int type =
+               (OP(NEXTOPER(first)) == REG_ANY)
+                   ? ROPT_ANCH_MBOL
+                   : ROPT_ANCH_SBOL;
            r->reganch |= type | ROPT_IMPLICIT;
            first = NEXTOPER(first);
            goto again;
@@ -2042,7 +2040,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
            && !(data.start_class->flags & ANYOF_EOS)
            && !cl_is_anything(data.start_class))
        {
-           I32 n = add_data(pRExC_state, 1, "f");
+           const I32 n = add_data(pRExC_state, 1, "f");
 
            New(1006, RExC_rx->data->data[n], 1,
                struct regnode_charclass_class);
@@ -2098,7 +2096,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
        if (!(data.start_class->flags & ANYOF_EOS)
            && !cl_is_anything(data.start_class))
        {
-           I32 n = add_data(pRExC_state, 1, "f");
+           const I32 n = add_data(pRExC_state, 1, "f");
 
            New(1006, RExC_rx->data->data[n], 1,
                struct regnode_charclass_class);
@@ -2625,7 +2623,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp)
     register char op;
     register char *next;
     I32 flags;
-    char *origparse = RExC_parse;
+    const char * const origparse = RExC_parse;
     char *maxpos;
     I32 min;
     I32 max = REG_INFTY;
@@ -3031,7 +3029,7 @@ tryagain:
        case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
            {
-               I32 num = atoi(RExC_parse);
+               const I32 num = atoi(RExC_parse);
 
                if (num > 9 && num >= RExC_npar)
                    goto defchar;
@@ -3081,7 +3079,6 @@ tryagain:
            register UV ender;
            register char *p;
            char *oldp, *s;
-           STRLEN numlen;
            STRLEN foldlen;
            U8 tmpbuf[UTF8_MAXBYTES_CASE+1], *foldbuf;
 
@@ -3157,7 +3154,7 @@ tryagain:
                        break;
                    case 'x':
                        if (*++p == '{') {
-                           char* e = strchr(p, '}');
+                           char* const e = strchr(p, '}');
        
                            if (!e) {
                                RExC_parse = p + 1;
@@ -3166,7 +3163,7 @@ tryagain:
                            else {
                                 I32 flags = PERL_SCAN_ALLOW_UNDERSCORES
                                     | PERL_SCAN_DISALLOW_PREFIX;
-                                numlen = e - p - 1;
+                                STRLEN numlen = e - p - 1;
                                ender = grok_hex(p + 1, &numlen, &flags, NULL);
                                if (ender > 0xff)
                                    RExC_utf8 = 1;
@@ -3175,7 +3172,7 @@ tryagain:
                        }
                        else {
                             I32 flags = PERL_SCAN_DISALLOW_PREFIX;
-                           numlen = 2;
+                           STRLEN numlen = 2;
                            ender = grok_hex(p, &numlen, &flags, NULL);
                            p += numlen;
                        }
@@ -3190,7 +3187,7 @@ tryagain:
                        if (*p == '0' ||
                          (isDIGIT(p[1]) && atoi(p) >= RExC_npar) ) {
                             I32 flags = 0;
-                           numlen = 3;
+                           STRLEN numlen = 3;
                            ender = grok_oct(p, &numlen, &flags, NULL);
                            p += numlen;
                        }
@@ -3212,6 +3209,7 @@ tryagain:
                default:
                  normal_default:
                    if (UTF8_IS_START(*p) && UTF) {
+                       STRLEN numlen;
                        ender = utf8n_to_uvchr((U8*)p, RExC_end - p,
                                               &numlen, 0);
                        p += numlen;
@@ -3234,6 +3232,7 @@ tryagain:
 
                         if (FOLD) {
                              /* Emit all the Unicode characters. */
+                             STRLEN numlen;
                              for (foldbuf = tmpbuf;
                                   foldlen;
                                   foldlen -= numlen) {
@@ -3271,6 +3270,7 @@ tryagain:
 
                     if (FOLD) {
                          /* Emit all the Unicode characters. */
+                         STRLEN numlen;
                          for (foldbuf = tmpbuf;
                               foldlen;
                               foldlen -= numlen) {
@@ -3334,8 +3334,8 @@ tryagain:
        if (RExC_utf8)
            SvUTF8_on(sv);
        if (sv_utf8_downgrade(sv, TRUE)) {
-           char *s       = sv_recode_to_utf8(sv, PL_encoding);
-           STRLEN newlen = SvCUR(sv);
+           const char * const s = sv_recode_to_utf8(sv, PL_encoding);
+           const STRLEN newlen = SvCUR(sv);
 
            if (SvUTF8(sv))
                RExC_utf8 = 1;
@@ -3390,7 +3390,7 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
     if (value == '[' && RExC_parse + 1 < RExC_end &&
        /* I smell either [: or [= or [. -- POSIX has been here, right? */
        POSIXCC(UCHARAT(RExC_parse))) {
-       char  c = UCHARAT(RExC_parse);
+       const char c = UCHARAT(RExC_parse);
        char* s = RExC_parse++;
        
        while (RExC_parse < RExC_end && UCHARAT(RExC_parse) != c)
@@ -3399,7 +3399,7 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
            /* Grandfather lone [:, [=, [. */
            RExC_parse = s;
        else {
-           char* t = RExC_parse++; /* skip over the c */
+           const char* t = RExC_parse++; /* skip over the c */
 
            assert(*t == c);
 
@@ -3407,8 +3407,8 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
                RExC_parse++; /* skip over the ending ] */
                posixcc = s + 1;
                if (*s == ':') {
-                   I32 complement = *posixcc == '^' ? *posixcc++ : 0;
-                   I32 skip = t - posixcc;
+                   const I32 complement = *posixcc == '^' ? *posixcc++ : 0;
+                   const I32 skip = t - posixcc;
 
                    /* Initially switch on the length of the name.  */
                    switch (skip) {
@@ -3544,8 +3544,8 @@ STATIC void
 S_checkposixcc(pTHX_ RExC_state_t *pRExC_state)
 {
     if (!SIZE_ONLY && POSIXCC(UCHARAT(RExC_parse))) {
-       char *s = RExC_parse;
-       char  c = *s++;
+       const char *s = RExC_parse;
+       const char  c = *s++;
 
        while(*s && isALNUM(*s))
            s++;
@@ -3666,7 +3666,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
                if (RExC_parse >= RExC_end)
                    vFAIL2("Empty \\%c{}", (U8)value);
                if (*RExC_parse == '{') {
-                   U8 c = (U8)value;
+                   const U8 c = (U8)value;
                    e = strchr(RExC_parse++, '}');
                     if (!e)
                         vFAIL2("Missing right brace on \\%c{}", c);
@@ -4193,7 +4193,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
            IV i;
 
            if (prevvalue < 256) {
-               IV ceilvalue = value < 256 ? value : 255;
+               const IV ceilvalue = value < 256 ? value : 255;
 
 #ifdef EBCDIC
                /* In EBCDIC [\x89-\x91] should include
@@ -4218,8 +4218,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
                          ANYOF_BITMAP_SET(ret, i);
          }
          if (value > 255 || UTF) {
-               UV prevnatvalue  = NATIVE_TO_UNI(prevvalue);
-               UV natvalue      = NATIVE_TO_UNI(value);
+               const UV prevnatvalue  = NATIVE_TO_UNI(prevvalue);
+               const UV natvalue      = NATIVE_TO_UNI(value);
 
                ANYOF_FLAGS(ret) |= ANYOF_UNICODE;
                if (prevnatvalue < natvalue) { /* what about > ? */
@@ -4231,7 +4231,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
                    if (FOLD) {
                         U8 foldbuf[UTF8_MAXBYTES_CASE+1];
                         STRLEN foldlen;
-                        UV f = to_uni_fold(natvalue, foldbuf, &foldlen);
+                        const UV f = to_uni_fold(natvalue, foldbuf, &foldlen);
 
                         /* If folding and foldable and a single
                          * character, insert also the folded version
@@ -4795,8 +4795,8 @@ Perl_regprop(pTHX_ SV *sv, regnode *o)
        /* Using is_utf8_string() is a crude hack but it may
         * be the best for now since we have no flag "this EXACTish
         * node was UTF-8" --jhi */
-       bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
-       char *s    = do_utf8 ?
+       const bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
+       const char *s = do_utf8 ?
          pv_uni_display(dsv, (U8*)STRING(o), STR_LEN(o), 60,
                         UNI_DISPLAY_REGEX) :
          STRING(o);
@@ -4899,7 +4899,7 @@ Perl_regprop(pTHX_ SV *sv, regnode *o)
                    U8 s[UTF8_MAXBYTES_CASE+1];
                
                    for (i = 0; i <= 256; i++) { /* just the first 256 */
-                       U8 *e = uvchr_to_utf8(s, i);
+                       uvchr_to_utf8(s, i);
                        
                        if (i < 256 && swash_fetch(sw, s, TRUE)) {
                            if (rangestart == -1)
@@ -4909,15 +4909,17 @@ Perl_regprop(pTHX_ SV *sv, regnode *o)
                        
                            if (i <= rangestart + 3)
                                for (; rangestart < i; rangestart++) {
+                                   U8 *e;
                                    for(e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++)
                                        put_byte(sv, *p);
                                }
                            else {
+                               U8 *e;
                                for (e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++)
                                    put_byte(sv, *p);
                                sv_catpv(sv, "-");
-                                   for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++)
-                                       put_byte(sv, *p);
+                               for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++)
+                                   put_byte(sv, *p);
                                }
                                rangestart = -1;
                            }
@@ -4933,7 +4935,7 @@ Perl_regprop(pTHX_ SV *sv, regnode *o)
                    while(*s && *s != '\n') s++;
                
                    if (*s == '\n') {
-                       char *t = ++s;
+                       const char *t = ++s;
                        
                        while (*s) {
                            if (*s == '\n')
@@ -5179,13 +5181,13 @@ Perl_save_re_context(pTHX)
 
     {
        /* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */
-       U32 i;
-       GV *mgv;
        REGEXP *rx;
-       char digits[TYPE_CHARS(long)];
 
        if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
+           U32 i;
            for (i = 1; i <= rx->nparens; i++) {
+               GV *mgv;
+               char digits[TYPE_CHARS(long)];
                sprintf(digits, "%lu", (long)i);
                if ((mgv = gv_fetchpv(digits, FALSE, SVt_PV)))
                    save_scalar(mgv);
index fedc13e..884d076 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -221,7 +221,6 @@ S_regcppop(pTHX)
     I32 i;
     U32 paren = 0;
     char *input;
-    I32 tmps;
 
     /* Pop REGCP_OTHER_ELEMS before the parentheses loop starts. */
     i = SSPOPINT;
@@ -235,6 +234,7 @@ S_regcppop(pTHX)
     /* Now restore the parentheses context. */
     for (i -= (REGCP_OTHER_ELEMS - REGCP_FRAME_ELEMS);
         i > 0; i -= REGCP_PAREN_ELEMS) {
+       I32 tmps;
        paren = (U32)SSPOPINT;
        PL_reg_start_tmp[paren] = (char *) SSPOPPTR;
        PL_regstartp[paren] = SSPOPINT;
@@ -421,10 +421,10 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     }
 
     DEBUG_r({
-        char *s   = PL_reg_match_utf8 ?
+        const char *s   = PL_reg_match_utf8 ?
                         sv_uni_display(dsv, sv, 60, UNI_DISPLAY_REGEX) :
                         strpos;
-        int   len = PL_reg_match_utf8 ?
+        const int   len = PL_reg_match_utf8 ?
                         strlen(s) : strend - strpos;
         if (!PL_colorset)
              reginitcolors();
@@ -959,7 +959,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
 STATIC char *
 S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32 norun)
 {
-       I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
+       const I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
        char *m;
        STRLEN ln;
        STRLEN lnc;
@@ -1072,7 +1072,6 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32
            if (do_utf8) {
                UV c, f;
                U8 tmpbuf [UTF8_MAXBYTES+1];
-               U8 foldbuf[UTF8_MAXBYTES_CASE+1];
                STRLEN len, foldlen;
                
                if (c1 == c2) {
@@ -1089,6 +1088,7 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32
                             && (norun || regtry(prog, s)) )
                            goto got_it;
                        else {
+                            U8 foldbuf[UTF8_MAXBYTES_CASE+1];
                             uvchr_to_utf8(tmpbuf, c);
                             f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
                             if ( f != c
@@ -1128,6 +1128,7 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32
                             && (norun || regtry(prog, s)) )
                            goto got_it;
                        else {
+                            U8 foldbuf[UTF8_MAXBYTES_CASE+1];
                             uvchr_to_utf8(tmpbuf, c);
                             f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
                             if ( f != c
@@ -1625,17 +1626,16 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
     register char *startpos = stringarg;
     I32 minlen;                /* must match at least this many chars */
     I32 dontbother = 0;        /* how many characters not to try at end */
-    /* I32 start_shift = 0; */         /* Offset of the start to find
-                                        constant substr. */            /* CC */
     I32 end_shift = 0;                 /* Same for the end. */         /* CC */
     I32 scream_pos = -1;               /* Internal iterator of scream. */
     char *scream_olds;
     SV* oreplsv = GvSV(PL_replgv);
-    bool do_utf8 = DO_UTF8(sv);
+    const bool do_utf8 = DO_UTF8(sv);
 #ifdef DEBUGGING
     SV *dsv0 = PERL_DEBUG_PAD_ZERO(0);
     SV *dsv1 = PERL_DEBUG_PAD_ZERO(1);
 #endif
+    (void)data; /* Currently unused */
     RX_MATCH_UTF8_set(prog,do_utf8);
 
     PL_regcc = 0;
@@ -1720,14 +1720,14 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
     }
 
     DEBUG_r({
-        char *s0   = UTF ?
-          pv_uni_display(dsv0, (U8*)prog->precomp, prog->prelen, 60,
-                         UNI_DISPLAY_REGEX) :
-          prog->precomp;
-        int   len0 = UTF ? SvCUR(dsv0) : prog->prelen;
-        char *s1   = do_utf8 ? sv_uni_display(dsv1, sv, 60,
+       const char * const s0   = UTF
+           ? pv_uni_display(dsv0, (U8*)prog->precomp, prog->prelen, 60,
+                         UNI_DISPLAY_REGEX)
+           : prog->precomp;
+       const int len0 = UTF ? SvCUR(dsv0) : prog->prelen;
+       const char * const s1 = do_utf8 ? sv_uni_display(dsv1, sv, 60,
                                               UNI_DISPLAY_REGEX) : startpos;
-        int   len1 = do_utf8 ? SvCUR(dsv1) : strend - startpos;
+       const int len1 = do_utf8 ? SvCUR(dsv1) : strend - startpos;
         if (!PL_colorset)
             reginitcolors();
         PerlIO_printf(Perl_debug_log,
@@ -2327,8 +2327,8 @@ S_regmatch(pTHX_ regnode *prog)
 
         DEBUG_r( {
            SV *prop = sv_newmortal();
-           int docolor = *PL_colors[0];
-           int taill = (docolor ? 10 : 7); /* 3 chars for "> <" */
+           const int docolor = *PL_colors[0];
+           const int taill = (docolor ? 10 : 7); /* 3 chars for "> <" */
            int l = (PL_regeol - locinput) > taill ? taill : (PL_regeol - locinput);
            /* The part of the string before starttry has one color
               (pref0_len chars), between starttry and current
@@ -2354,22 +2354,22 @@ S_regmatch(pTHX_ regnode *prog)
                pref0_len = pref_len;
            regprop(prop, scan);
            {
-             char *s0 =
+             const char * const s0 =
                do_utf8 && OP(scan) != CANY ?
                pv_uni_display(dsv0, (U8*)(locinput - pref_len),
                               pref0_len, 60, UNI_DISPLAY_REGEX) :
                locinput - pref_len;
-             int len0 = do_utf8 ? strlen(s0) : pref0_len;
-             char *s1 = do_utf8 && OP(scan) != CANY ?
+             const int len0 = do_utf8 ? strlen(s0) : pref0_len;
+             const char * const s1 = do_utf8 && OP(scan) != CANY ?
                pv_uni_display(dsv1, (U8*)(locinput - pref_len + pref0_len),
                               pref_len - pref0_len, 60, UNI_DISPLAY_REGEX) :
                locinput - pref_len + pref0_len;
-             int len1 = do_utf8 ? strlen(s1) : pref_len - pref0_len;
-             char *s2 = do_utf8 && OP(scan) != CANY ?
+             const int len1 = do_utf8 ? strlen(s1) : pref_len - pref0_len;
+             const char * const s2 = do_utf8 && OP(scan) != CANY ?
                pv_uni_display(dsv2, (U8*)locinput,
                               PL_regeol - locinput, 60, UNI_DISPLAY_REGEX) :
                locinput;
-             int len2 = do_utf8 ? strlen(s2) : l;
+             const int len2 = do_utf8 ? strlen(s2) : l;
              PerlIO_printf(Perl_debug_log,
                            "%4"IVdf" <%s%.*s%s%s%.*s%s%s%s%.*s%s>%*s|%3"IVdf":%*s%s\n",
                            (IV)(locinput - PL_bostr),
diff --git a/scope.c b/scope.c
index 7a78056..0ac91c2 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -900,7 +900,7 @@ Perl_leave_scope(pTHX_ I32 base)
            break;
        case SAVEt_FREEPV:
            ptr = SSPOPPTR;
-           Safefree((char*)ptr);
+           Safefree(ptr);
            break;
        case SAVEt_CLEARSV:
            ptr = (void*)&PL_curpad[SSPOPLONG];
diff --git a/sv.c b/sv.c
index 6e1f829..f5b8fdb 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -501,7 +501,7 @@ Perl_sv_free_arenas(pTHX)
            svanext = (SV*) SvANY(svanext);
 
        if (!SvFAKE(sva))
-           Safefree((void *)sva);
+           Safefree(sva);
     }
 
     for (arena = PL_xiv_arenaroot; arena; arena = arenanext) {
diff --git a/utf8.c b/utf8.c
index 4587e7e..aa7d1eb 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -489,7 +489,7 @@ malformed:
                            (UV)s[1], startbyte);
            else
                Perl_sv_catpvf(aTHX_ sv, "(unexpected non-continuation byte 0x%02"UVxf", %d byte%s after start byte 0x%02"UVxf", expected %d bytes)",
-                           (UV)s[1], s - s0, s - s0 > 1 ? "s" : "", startbyte, expectlen);
+                           (UV)s[1], s - s0, s - s0 > 1 ? "s" : "", startbyte, (int)expectlen);
              
            break;
        case UTF8_WARN_FE_FF:
@@ -497,7 +497,7 @@ malformed:
            break;
        case UTF8_WARN_SHORT:
            Perl_sv_catpvf(aTHX_ sv, "(%d byte%s, need %d, after start byte 0x%02"UVxf")",
-                           curlen, curlen == 1 ? "" : "s", expectlen, startbyte);
+                           (int)curlen, curlen == 1 ? "" : "s", (int)expectlen, startbyte);
            expectlen = curlen;         /* distance for caller to skip */
            break;
        case UTF8_WARN_OVERFLOW:
@@ -509,7 +509,7 @@ malformed:
            break;
        case UTF8_WARN_LONG:
            Perl_sv_catpvf(aTHX_ sv, "(%d byte%s, need %d, after start byte 0x%02"UVxf")",
-                          expectlen, expectlen == 1 ? "": "s", UNISKIP(uv), startbyte);
+                          (int)expectlen, expectlen == 1 ? "": "s", UNISKIP(uv), startbyte);
            break;
        case UTF8_WARN_FFFF:
            Perl_sv_catpvf(aTHX_ sv, "(character 0x%04"UVxf")", uv);