Change 29925 by [EMAIL PROTECTED] on 2007/01/22 22:10:59

        Integrate:
        [ 27630]
        Subject: [PATCH] Clean up regexec.c, and remove two functions
        From: [EMAIL PROTECTED] (Andy Lester)
        Date: Wed, 29 Mar 2006 10:13:36 -0600
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 27641]
        Subject: [PATCH] Random accumulated patches
        From: [EMAIL PROTECTED] (Andy Lester)
        Date: Thu, 30 Mar 2006 23:42:28 -0600
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 27649]
        Subject: [PATCH] Redo PERL_UNUSED_DECL
        From: [EMAIL PROTECTED] (Andy Lester)
        Date: Fri, 31 Mar 2006 00:54:58 -0600
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 27653]
        Updated version of the grumpy comment deleted by change #27649,
        by Jarkko
        
        [ 27657]
        Inconsistencies in paramter const-ness noticed by SADAHIRO Tomoyuki.
        
        [ 27690]
        Subject: [PATCH] Removed unnecessary pointers checks
        From: [EMAIL PROTECTED] (Andy Lester)
        Date: Sat, 1 Apr 2006 01:01:32 -0600
        Message-ID: <[EMAIL PROTECTED]>
        
        [ 27735]
        Patch from Jarkko to fix breakage caused by change #27649
        see: 
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2006-04/msg00144.html

Affected files ...

... //depot/maint-5.8/perl/cop.h#27 integrate
... //depot/maint-5.8/perl/doio.c#90 integrate
... //depot/maint-5.8/perl/dump.c#63 integrate
... //depot/maint-5.8/perl/embed.fnc#179 integrate
... //depot/maint-5.8/perl/embed.h#134 integrate
... //depot/maint-5.8/perl/gv.c#86 integrate
... //depot/maint-5.8/perl/gv.h#18 integrate
... //depot/maint-5.8/perl/hv.c#100 integrate
... //depot/maint-5.8/perl/malloc.c#23 integrate
... //depot/maint-5.8/perl/mg.c#129 integrate
... //depot/maint-5.8/perl/op.c#168 integrate
... //depot/maint-5.8/perl/perl.c#190 integrate
... //depot/maint-5.8/perl/perl.h#133 integrate
... //depot/maint-5.8/perl/pp.c#116 integrate
... //depot/maint-5.8/perl/pp_ctl.c#149 integrate
... //depot/maint-5.8/perl/pp_hot.c#116 edit
... //depot/maint-5.8/perl/pp_sort.c#43 edit
... //depot/maint-5.8/perl/proto.h#168 integrate
... //depot/maint-5.8/perl/regcomp.c#81 integrate
... //depot/maint-5.8/perl/regexec.c#69 integrate
... //depot/maint-5.8/perl/sv.c#302 integrate
... //depot/maint-5.8/perl/sv.h#71 integrate
... //depot/maint-5.8/perl/toke.c#139 integrate
... //depot/maint-5.8/perl/utf8.c#67 integrate

Differences ...

==== //depot/maint-5.8/perl/cop.h#27 (text) ====
Index: perl/cop.h
--- perl/cop.h#26~29924~        2007-01-22 12:22:04.000000000 -0800
+++ perl/cop.h  2007-01-22 14:10:59.000000000 -0800
@@ -286,7 +286,7 @@
 #define POPLOOP(cx)                                                    \
        SvREFCNT_dec(cx->blk_loop.iterlval);                            \
        if (CxITERVAR(cx)) {                                            \
-           SV **s_v_p = CxITERVAR(cx);                                 \
+           SV ** const s_v_p = CxITERVAR(cx);                          \
            sv_2mortal(*s_v_p);                                         \
            *s_v_p = cx->blk_loop.itersave;                             \
        }                                                               \

==== //depot/maint-5.8/perl/doio.c#90 (text) ====
Index: perl/doio.c
--- perl/doio.c#89~29859~       2007-01-17 14:07:40.000000000 -0800
+++ perl/doio.c 2007-01-22 14:10:59.000000000 -0800
@@ -2254,7 +2254,7 @@
        SETERRNO(EFAULT,SS_ACCVIO);             /* can't do as caller requested 
*/
        return -1;
     }
-    shm = (char *)shmat(id, (char*)NULL, (optype == OP_SHMREAD) ? SHM_RDONLY : 
0);
+    shm = (char *)shmat(id, NULL, (optype == OP_SHMREAD) ? SHM_RDONLY : 0);
     if (shm == (char *)-1)     /* I hate System V IPC, I really do */
        return -1;
     if (optype == OP_SHMREAD) {

==== //depot/maint-5.8/perl/dump.c#63 (text) ====
Index: perl/dump.c
--- perl/dump.c#62~29906~       2007-01-21 04:16:40.000000000 -0800
+++ perl/dump.c 2007-01-22 14:10:59.000000000 -0800
@@ -358,7 +358,7 @@
        op_dump(pm->op_pmreplroot);
     }
     if (pm->op_pmflags || (PM_GETRE(pm) && PM_GETRE(pm)->check_substr)) {
-       SV *tmpsv = newSVpvs("");
+       SV * const tmpsv = newSVpvs("");
        if (pm->op_pmdynflags & PMdf_USED)
            sv_catpv(tmpsv, ",USED");
        if (pm->op_pmdynflags & PMdf_TAINTED)
@@ -652,7 +652,7 @@
 #else
        if ( ! PL_op->op_flags & OPf_SPECIAL) { /* not lexical */
            if (cSVOPo->op_sv) {
-               SV *tmpsv = newSV(0);
+               SV * const tmpsv = newSV(0);
                ENTER;
                SAVEFREESV(tmpsv);
                gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, NULL);

==== //depot/maint-5.8/perl/embed.fnc#179 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#178~29924~   2007-01-22 12:22:04.000000000 -0800
+++ perl/embed.fnc      2007-01-22 14:10:59.000000000 -0800
@@ -471,7 +471,7 @@
 Afp    |SV*    |mess           |NN const char* pat|...
 Ap     |SV*    |vmess          |NN const char* pat|NULLOK va_list* args
 p      |void   |qerror         |NN SV* err
-Apd    |void   |sortsv         |NN SV** array|size_t num_elts|SVCOMPARE_t cmp
+Apd    |void   |sortsv         |NN SV** array|size_t num_elts|NN SVCOMPARE_t 
cmp
 Apd    |int    |mg_clear       |NN SV* sv
 Apd    |int    |mg_copy        |NN SV* sv|NN SV* nsv|NULLOK const char* 
key|I32 klen
 pd     |void   |mg_localize    |NN SV* sv|NN SV* nsv
@@ -1270,9 +1270,7 @@
 Es     |CHECKPOINT|regcppush   |I32 parenfloor
 Es     |char*|regcppop
 Es     |void   |cache_re       |NN regexp *prog
-ERs    |U8*    |reghop         |NN U8 *pos|I32 off
 ERsn   |U8*    |reghop3        |NN U8 *pos|I32 off|NN U8 *lim
-ERs    |U8*    |reghopmaybe    |NN U8 *pos|I32 off
 ERsn   |U8*    |reghopmaybe3   |NN U8 *pos|I32 off|NN U8 *lim
 ERs    |char*  |find_byclass   |NN regexp * prog|NN regnode *c|NN char *s|NN 
const char *strend|I32 norun
 Es     |void   |to_utf8_substr |NN regexp * prog
@@ -1306,7 +1304,7 @@
 s      |STRLEN |sv_pos_u2b_forwards|NN const U8 *const start \
                |NN const U8 *const send|STRLEN uoffset
 s      |STRLEN |sv_pos_u2b_midway|NN const U8 *const start \
-               |NN const U8 *const send|STRLEN uoffset|STRLEN uend
+               |NN const U8 *send|STRLEN uoffset|STRLEN uend
 s      |STRLEN |sv_pos_u2b_cached|NN SV *sv|NN MAGIC **mgp \
                |NN const U8 *const start|NN const U8 *const send \
                |STRLEN uoffset|STRLEN uoffset0|STRLEN boffset0

==== //depot/maint-5.8/perl/embed.h#134 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#133~29924~     2007-01-22 12:22:04.000000000 -0800
+++ perl/embed.h        2007-01-22 14:10:59.000000000 -0800
@@ -1301,9 +1301,7 @@
 #define regcppush              S_regcppush
 #define regcppop               S_regcppop
 #define cache_re               S_cache_re
-#define reghop                 S_reghop
 #define reghop3                        S_reghop3
-#define reghopmaybe            S_reghopmaybe
 #define reghopmaybe3           S_reghopmaybe3
 #define find_byclass           S_find_byclass
 #define to_utf8_substr         S_to_utf8_substr
@@ -3380,9 +3378,7 @@
 #define regcppush(a)           S_regcppush(aTHX_ a)
 #define regcppop()             S_regcppop(aTHX)
 #define cache_re(a)            S_cache_re(aTHX_ a)
-#define reghop(a,b)            S_reghop(aTHX_ a,b)
 #define reghop3                        S_reghop3
-#define reghopmaybe(a,b)       S_reghopmaybe(aTHX_ a,b)
 #define reghopmaybe3           S_reghopmaybe3
 #define find_byclass(a,b,c,d,e)        S_find_byclass(aTHX_ a,b,c,d,e)
 #define to_utf8_substr(a)      S_to_utf8_substr(aTHX_ a)

==== //depot/maint-5.8/perl/gv.c#86 (text) ====
Index: perl/gv.c
--- perl/gv.c#85~29913~ 2007-01-22 06:45:23.000000000 -0800
+++ perl/gv.c   2007-01-22 14:10:59.000000000 -0800
@@ -903,7 +903,7 @@
                        *gvp == (GV*)&PL_sv_undef ||
                        SvTYPE(*gvp) != SVt_PVGV)
                    {
-                       stash = 0;
+                       stash = NULL;
                    }
                    else if ((sv_type == SVt_PV   && !GvIMPORTED_SV(*gvp)) ||
                             (sv_type == SVt_PVAV && !GvIMPORTED_AV(*gvp)) ||
@@ -915,7 +915,7 @@
                            name);
                        if (GvCVu(*gvp))
                            Perl_warn(aTHX_ "\t(Did you mean &%s instead?)\n", 
name);
-                       stash = 0;
+                       stash = NULL;
                    }
                }
            }
@@ -1361,7 +1361,7 @@
 Perl_gp_ref(pTHX_ GP *gp)
 {
     if (!gp)
-       return (GP*)NULL;
+       return NULL;
     gp->gp_refcnt++;
     if (gp->gp_cv) {
        if (gp->gp_cvgen) {
@@ -1403,8 +1403,8 @@
         return;
     }
 
-    if (gp->gp_sv) SvREFCNT_dec(gp->gp_sv);
-    if (gp->gp_av) SvREFCNT_dec(gp->gp_av);
+    SvREFCNT_dec(gp->gp_sv);
+    SvREFCNT_dec(gp->gp_av);
     /* FIXME - another reference loop GV -> symtab -> GV ?
        Somehow gp->gp_hv can end up pointing at freed garbage.  */
     if (gp->gp_hv && SvTYPE(gp->gp_hv) == SVt_PVHV) {
@@ -1414,9 +1414,9 @@
            hv_delete(PL_stashcache, hvname, strlen(hvname), G_DISCARD);
        SvREFCNT_dec(gp->gp_hv);
     }
-    if (gp->gp_io)   SvREFCNT_dec(gp->gp_io);
-    if (gp->gp_cv)   SvREFCNT_dec(gp->gp_cv);
-    if (gp->gp_form) SvREFCNT_dec(gp->gp_form);
+    SvREFCNT_dec(gp->gp_io);
+    SvREFCNT_dec(gp->gp_cv);
+    SvREFCNT_dec(gp->gp_form);
 
     Safefree(gp);
     GvGP(gv) = 0;
@@ -1622,7 +1622,7 @@
       && (mg = mg_find((SV*)stash, PERL_MAGIC_overload_table))
       && (ocvp = cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr)
                        ? (oamtp = amtp = (AMT*)mg->mg_ptr)->table
-                       : (CV **) NULL))
+                       : NULL))
       && ((cv = cvp[off=method+assignshift])
          || (assign && amtp->fallback > AMGfallNEVER && /* fallback to
                                                          * usual method */
@@ -1740,7 +1740,7 @@
               && (mg = mg_find((SV*)stash, PERL_MAGIC_overload_table))
               && (cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr)
                          ? (amtp = (AMT*)mg->mg_ptr)->table
-                         : (CV **) NULL))
+                         : NULL))
               && (cv = cvp[off=method])) { /* Method for right
                                             * argument found */
       lr=1;

==== //depot/maint-5.8/perl/hv.c#100 (text) ====
Index: perl/hv.c
--- perl/hv.c#99~29913~ 2007-01-22 06:45:23.000000000 -0800
+++ perl/hv.c   2007-01-22 14:10:59.000000000 -0800
@@ -1020,7 +1020,7 @@
            return NULL;
        }
        if (SvREADONLY(hv) && HeVAL(entry) && SvREADONLY(HeVAL(entry))) {
-           S_hv_notallowed(aTHX_ k_flags, key, klen,
+           hv_notallowed(k_flags, key, klen,
                            "Attempt to delete readonly key '%"SVf"' from"
                            " a restricted hash");
        }
@@ -1062,7 +1062,7 @@
        return sv;
     }
     if (SvREADONLY(hv)) {
-        S_hv_notallowed(aTHX_ k_flags, key, klen,
+       hv_notallowed(k_flags, key, klen,
                        "Attempt to delete disallowed key '%"SVf"' from"
                        " a restricted hash");
     }

==== //depot/maint-5.8/perl/mg.c#129 (text) ====
Index: perl/mg.c
--- perl/mg.c#128~29920~        2007-01-22 11:20:43.000000000 -0800
+++ perl/mg.c   2007-01-22 14:10:59.000000000 -0800
@@ -542,7 +542,8 @@
 int
 Perl_magic_regdatum_set(pTHX_ SV *sv, MAGIC *mg)
 {
-    PERL_UNUSED_ARG(sv); PERL_UNUSED_ARG(mg);
+    PERL_UNUSED_ARG(sv);
+    PERL_UNUSED_ARG(mg);
     Perl_croak(aTHX_ PL_no_modify);
     NORETURN_FUNCTION_END;
 }
@@ -715,7 +716,7 @@
             }
 #elif defined(WIN32)
             {
-                 DWORD dwErr = GetLastError();
+                 const DWORD dwErr = GetLastError();
                  sv_setnv(sv, (NV)dwErr);
                  if (dwErr) {
                       PerlProc_GetOSError(sv, dwErr);
@@ -2040,7 +2041,7 @@
        if ((I32)LvTARGLEN(sv) < 0 && (I32)LvTARGOFF(sv) > AvFILL(av))
            LvTARG(sv) = NULL;  /* array can't be extended */
        else {
-           SV** const svp = av_fetch(av, LvTARGOFF(sv), TRUE);
+           SV* const * const svp = av_fetch(av, LvTARGOFF(sv), TRUE);
            if (!svp || (value = *svp) == &PL_sv_undef)
                Perl_croak(aTHX_ PL_no_aelem, (I32)LvTARGOFF(sv));
        }

==== //depot/maint-5.8/perl/op.c#168 (text) ====
Index: perl/op.c
--- perl/op.c#167~29924~        2007-01-22 12:22:04.000000000 -0800
+++ perl/op.c   2007-01-22 14:10:59.000000000 -0800
@@ -833,16 +833,16 @@
            if (ckWARN(WARN_VOID)) {
                useless = "a constant";
                if (o->op_private & OPpCONST_ARYBASE)
-                   useless = 0;
+                   useless = NULL;
                /* don't warn on optimised away booleans, eg 
                 * use constant Foo, 5; Foo || print; */
                if (cSVOPo->op_private & OPpCONST_SHORTCIRCUIT)
-                   useless = 0;
+                   useless = NULL;
                /* the constants 0 and 1 are permitted as they are
                   conventionally used as dummies in constructs like
                        1 while some_condition_with_side_effects;  */
                else if (SvNIOK(sv) && (SvNV(sv) == 0.0 || SvNV(sv) == 1.0))
-                   useless = 0;
+                   useless = NULL;
                else if (SvPOK(sv)) {
                   /* perl4's way of mixing documentation and code
                      (before the invention of POD) was based on a
@@ -854,7 +854,7 @@
                    if (strnEQ(maybe_macro, "di", 2) ||
                        strnEQ(maybe_macro, "ds", 2) ||
                        strnEQ(maybe_macro, "ig", 2))
-                           useless = 0;
+                           useless = NULL;
                }
            }
        }
@@ -2074,8 +2074,7 @@
        o2->op_targ = find_threadsv(";");
 #else
        OP * const o2
-           = newSVREF(newGVOP(OP_GV, 0, gv_fetchpvs(";", GV_ADD|GV_NOTQUAL,
-                                                    SVt_PV)));
+           = newSVREF(newGVOP(OP_GV, 0, gv_fetchpvs(";", GV_ADD|GV_NOTQUAL, 
SVt_PV)));
 #endif /* USE_5005THREADS */
        o = convert(OP_JOIN, 0, prepend_elem(OP_LIST, o2, o));
     }
@@ -3296,8 +3295,7 @@
        doop = ck_subr(newUNOP(OP_ENTERSUB, OPf_STACKED,
                               append_elem(OP_LIST, term,
                                           scalar(newUNOP(OP_RV2CV, 0,
-                                                         newGVOP(OP_GV, 0,
-                                                                 gv))))));
+                                                         newGVOP(OP_GV, 0, 
gv))))));
     }
     else {
        doop = newUNOP(OP_DOFILE, 0, scalar(term));
@@ -4037,7 +4035,7 @@
         * set the STACKED flag to indicate that these values are to be
         * treated as min/max values by 'pp_iterinit'.
         */
-       UNOP* const flip = (UNOP*)((UNOP*)((BINOP*)expr)->op_first)->op_first;
+       const UNOP* const flip = 
(UNOP*)((UNOP*)((BINOP*)expr)->op_first)->op_first;
        LOGOP* const range = (LOGOP*) flip->op_first;
        OP* const left  = range->op_first;
        OP* const right = left->op_sibling;

==== //depot/maint-5.8/perl/perl.c#190 (text) ====
Index: perl/perl.c
--- perl/perl.c#189~29924~      2007-01-22 12:22:04.000000000 -0800
+++ perl/perl.c 2007-01-22 14:10:59.000000000 -0800
@@ -3227,7 +3227,7 @@
        }
 #endif /* __CYGWIN__ */
        {
-           const char *start = ++s;
+           const char * const start = ++s;
            while (*s && !isSPACE(*s))
                ++s;
 

==== //depot/maint-5.8/perl/perl.h#133 (text) ====
Index: perl/perl.h
--- perl/perl.h#132~29920~      2007-01-22 11:20:43.000000000 -0800
+++ perl/perl.h 2007-01-22 14:10:59.000000000 -0800
@@ -115,7 +115,7 @@
 #      define MULTIPLICITY
 #    endif
 #    define tTHX       PerlInterpreter*
-#    define pTHX       register PerlInterpreter *my_perl PERL_UNUSED_DECL
+#    define pTHX  register tTHX my_perl PERL_UNUSED_DECL
 #    define aTHX       my_perl
 #    define dTHXa(a)   pTHX = (tTHX)a
 #  endif
@@ -152,10 +152,17 @@
 #define CALLREG_INTUIT_STRING CALL_FPTR(PL_regint_string)
 #define CALLREGFREE CALL_FPTR(PL_regfree)
 
-/* XXX The PERL_UNUSED_DECL suffix is unfortunately rather inflexible:
- * it assumes that in all compilers the way to suppress an "unused"
- * warning is to have a suffix.  In some compilers that might be a
- * a compiler pragma, e.g. #pragma unused(varname). */
+/*
+ * Because of backward compatibility reasons the PERL_UNUSED_DECL
+ * cannot be changed from postfix to PERL_UNUSED_DECL(x).  Sigh.
+ *
+ * Note that there are C compilers such as MetroWerks CodeWarrior
+ * which do not have an "inlined" way (like the gcc __attribute__) of
+ * marking unused variables (they need e.g. a #pragma) and therefore
+ * cpp macros like PERL_UNUSED_DECL cannot work for this purpose, even
+ * if it were PERL_UNUSED_DECL(x), which it cannot be (see above).
+ *
+ */
 
 #ifdef PERL_FLEXIBLE_EXCEPTIONS
 #  define CALLPROTECT CALL_FPTR(PL_protect)

==== //depot/maint-5.8/perl/pp.c#116 (text) ====
Index: perl/pp.c
--- perl/pp.c#115~29915~        2007-01-22 07:49:59.000000000 -0800
+++ perl/pp.c   2007-01-22 14:10:59.000000000 -0800
@@ -3948,7 +3948,7 @@
                        save_helem(hv, keysv, svp);
                    else {
                        STRLEN keylen;
-                       const char *key = SvPV_const(keysv, keylen);
+                       const char * const key = SvPV_const(keysv, keylen);
                        SAVEDELETE(hv, savepvn(key,keylen), keylen);
                    }
                 }

==== //depot/maint-5.8/perl/pp_ctl.c#149 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#148~29924~    2007-01-22 12:22:04.000000000 -0800
+++ perl/pp_ctl.c       2007-01-22 14:10:59.000000000 -0800
@@ -2403,7 +2403,7 @@
 
        /* find label */
 
-       PL_lastgotoprobe = 0;
+       PL_lastgotoprobe = NULL;
        *enterops = 0;
        for (ix = cxstack_ix; ix >= 0; ix--) {
            cx = &cxstack[ix];

==== //depot/maint-5.8/perl/pp_hot.c#116 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#115~29915~    2007-01-22 07:49:59.000000000 -0800
+++ perl/pp_hot.c       2007-01-22 14:10:59.000000000 -0800
@@ -346,13 +346,12 @@
                     ivp = *--SP;
                 }
                 iv = SvIVX(ivp);
-                if (iv < 0) {
+               if (iv < 0)
                     /* As uv is a UV, it's >0, so it cannot be == */
                     SETs(&PL_sv_no);
-                    RETURN;
-                }
-               /* we know iv is >= 0 */
-               SETs(boolSV((UV)iv == SvUVX(uvp)));
+               else
+                   /* we know iv is >= 0 */
+                   SETs(boolSV((UV)iv == SvUVX(uvp)));
                RETURN;
            }
        }
@@ -3214,7 +3213,7 @@
            if (!stash)
                packsv = sv;
             else {
-               SV* ref = newSViv(PTR2IV(stash));
+               SV* const ref = newSViv(PTR2IV(stash));
                hv_store(PL_stashcache, packname, packlen, ref, 0);
            }
            goto fetch;

==== //depot/maint-5.8/perl/pp_sort.c#43 (text) ====
Index: perl/pp_sort.c
--- perl/pp_sort.c#42~29898~    2007-01-20 10:43:49.000000000 -0800
+++ perl/pp_sort.c      2007-01-22 14:10:59.000000000 -0800
@@ -178,12 +178,11 @@
 
 
 static IV
-dynprep(pTHX_ gptr *list1, gptr *list2, size_t nmemb, SVCOMPARE_t cmp)
+dynprep(pTHX_ gptr *list1, gptr *list2, size_t nmemb, const SVCOMPARE_t cmp)
 {
     I32 sense;
     register gptr *b, *p, *q, *t, *p2;
-    register gptr c, *last, *r;
-    gptr *savep;
+    register gptr *last, *r;
     IV runs = 0;
 
     b = list1;
@@ -215,7 +214,8 @@
                }
            }
            if (q > b) {                /* run of greater than 2 at b */
-               savep = p;
+               gptr *savep = p;
+
                p = q += 2;
                /* pick up singleton, if possible */
                if ((p == t) &&
@@ -223,17 +223,18 @@
                    ((cmp(aTHX_ *(p-1), *p) > 0) == sense))
                    savep = r = p = q = last;
                p2 = NEXT(p2) = p2 + (p - b); ++runs;
-               if (sense) while (b < --p) {
-                   c = *b;
-                   *b++ = *p;
-                   *p = c;
-               }
+               if (sense)
+                   while (b < --p) {
+                       const gptr c = *b;
+                       *b++ = *p;
+                       *p = c;
+                   }
                p = savep;
            }
            while (q < p) {             /* simple pairs */
                p2 = NEXT(p2) = p2 + 2; ++runs;
                if (sense) {
-                   c = *q++;
+                   const gptr c = *q++;
                    *(q-1) = *q;
                    *q++ = c;
                } else q += 2;
@@ -354,7 +355,7 @@
     gptr small[SMALLSORT];
     gptr *which[3];
     off_runs stack[60], *stackp;
-    SVCOMPARE_t savecmp = 0;
+    SVCOMPARE_t savecmp = NULL;
 
     if (nmemb <= 1) return;                    /* sorted trivially */
 
@@ -1405,7 +1406,7 @@
         /* restore prevailing comparison routine */
         PL_sort_RealCmp = savecmp;
     } else if (flags) {
-        SVCOMPARE_t savecmp = PL_sort_RealCmp; /* Save current comparison 
routine, if any */
+        const SVCOMPARE_t savecmp = PL_sort_RealCmp;   /* Save current 
comparison routine, if any */
         PL_sort_RealCmp = cmp; /* Put comparison routine where cmp_desc can 
find it */
         cmp = cmp_desc;
         S_qsortsvu(aTHX_ list1, nmemb, cmp);
@@ -1433,38 +1434,31 @@
 void
 Perl_sortsv(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp)
 {
-    void (*sortsvp)(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp, U32 flags)
-      = S_mergesortsv;
     dSORTHINTS;
     const I32 hints = SORTHINTS;
     if (hints & HINT_SORT_QUICKSORT) {
-       sortsvp = S_qsortsv;
+       S_qsortsv(aTHX_ array, nmemb, cmp, 0);
     }
     else {
        /* The default as of 5.8.0 is mergesort */
-       sortsvp = S_mergesortsv;
+       S_mergesortsv(aTHX_ array, nmemb, cmp, 0);
     }
-
-    sortsvp(aTHX_ array, nmemb, cmp, 0);
 }
 
 
 static void
 S_sortsv_desc(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp)
 {
-    void (*sortsvp)(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp, U32 flags)
-      = S_mergesortsv;
     dSORTHINTS;
     const I32 hints = SORTHINTS;
     if (hints & HINT_SORT_QUICKSORT) {
-       sortsvp = S_qsortsv;
+       S_qsortsv(aTHX_ array, nmemb, cmp, 1);
     }
     else {
        /* The default as of 5.8.0 is mergesort */
-       sortsvp = S_mergesortsv;
+       S_mergesortsv(aTHX_ array, nmemb, cmp, 1);
     }
 
-    sortsvp(aTHX_ array, nmemb, cmp, 1);
 }
 
 #define SvNSIOK(sv) ((SvFLAGS(sv) & SVf_NOK) || ((SvFLAGS(sv) & 
(SVf_IOK|SVf_IVisUV)) == SVf_IOK))

==== //depot/maint-5.8/perl/proto.h#168 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#167~29924~     2007-01-22 12:22:04.000000000 -0800
+++ perl/proto.h        2007-01-22 14:10:59.000000000 -0800
@@ -1859,15 +1859,9 @@
 STATIC CHECKPOINT      S_regcppush(pTHX_ I32 parenfloor);
 STATIC char*   S_regcppop(pTHX);
 STATIC void    S_cache_re(pTHX_ regexp *prog);
-STATIC U8*     S_reghop(pTHX_ U8 *pos, I32 off)
-                       __attribute__warn_unused_result__;
-
 STATIC U8*     S_reghop3(U8 *pos, I32 off, U8 *lim)
                        __attribute__warn_unused_result__;
 
-STATIC U8*     S_reghopmaybe(pTHX_ U8 *pos, I32 off)
-                       __attribute__warn_unused_result__;
-
 STATIC U8*     S_reghopmaybe3(U8 *pos, I32 off, U8 *lim)
                        __attribute__warn_unused_result__;
 
@@ -1907,7 +1901,7 @@
 
 #
 STATIC STRLEN  S_sv_pos_u2b_forwards(pTHX_ const U8 *const start, const U8 
*const send, STRLEN uoffset);
-STATIC STRLEN  S_sv_pos_u2b_midway(pTHX_ const U8 *const start, const U8 
*const send, STRLEN uoffset, STRLEN uend);
+STATIC STRLEN  S_sv_pos_u2b_midway(pTHX_ const U8 *const start, const U8 
*send, STRLEN uoffset, STRLEN uend);
 STATIC STRLEN  S_sv_pos_u2b_cached(pTHX_ SV *sv, MAGIC **mgp, const U8 *const 
start, const U8 *const send, STRLEN uoffset, STRLEN uoffset0, STRLEN boffset0);
 STATIC void    S_utf8_mg_pos_cache_update(pTHX_ SV *sv, MAGIC **mgp, STRLEN 
byte, STRLEN utf8, STRLEN blen);
 STATIC STRLEN  S_sv_pos_b2u_forwards(pTHX_ const U8 *s, const U8 *const 
target);

==== //depot/maint-5.8/perl/regcomp.c#81 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#80~29897~    2007-01-20 10:14:46.000000000 -0800
+++ perl/regcomp.c      2007-01-22 14:10:59.000000000 -0800
@@ -739,7 +739,7 @@
                 char * const s0 = STRING(scan), *s, *t;
                 char * const s1 = s0 + STR_LEN(scan) - 1;
                 char * const s2 = s1 - 4;
-                const char * const t0 = "\xcc\x88\xcc\x81";
+                const char t0[] = "\xcc\x88\xcc\x81";
                 const char * const t1 = t0 + 3;
 
                 for (s = s0 + 2;
@@ -999,7 +999,7 @@
        else if (strchr((const char*)PL_varies,OP(scan))) {
            I32 mincount, maxcount, minnext, deltanext, fl = 0;
            I32 f = flags, pos_before = 0;
-           regnode *oscan = scan;
+           regnode * const oscan = scan;
            struct regnode_charclass_class this_class;
            struct regnode_charclass_class *oclass = NULL;
            I32 next_is_eval = 0;
@@ -1134,7 +1134,7 @@
                      && !deltanext && minnext == 1 ) {
                    /* Try to optimize to CURLYN.  */
                    regnode *nxt = NEXTOPER(oscan) + EXTRA_STEP_2ARGS;
-                   regnode *nxt1 = nxt;
+                   regnode * const nxt1 = nxt;
 #ifdef DEBUGGING
                    regnode *nxt2;
 #endif
@@ -1263,7 +1263,7 @@
                        I32 b = pos_before >= data->last_start_min
                            ? pos_before : data->last_start_min;
                        STRLEN l;
-                       const char *s = SvPV_const(data->last_found, l);
+                       const char * const s = SvPV_const(data->last_found, l);
                        I32 old = b - data->last_start_min;
 #endif
 
@@ -1312,8 +1312,8 @@
                            the group.  */
                        scan_commit(pRExC_state,data);
                        if (mincount && last_str) {
-                           SV *sv = data->last_found;
-                           MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ?
+                           SV * const sv = data->last_found;
+                           MAGIC * const mg = SvUTF8(sv) && SvMAGICAL(sv) ?
                                mg_find(sv, PERL_MAGIC_utf8) : NULL;
 
                            if (mg)
@@ -2582,7 +2582,7 @@
        *flagp |= flags&SIMPLE;
     }
 
-    return(ret);
+    return ret;
 }
 
 /*
@@ -4141,10 +4141,8 @@
 
        if (range) {
            if (prevvalue > (IV)value) /* b-a */ {
-               Simple_vFAIL4("Invalid [] range \"%*.*s\"",
-                             RExC_parse - rangebegin,
-                             RExC_parse - rangebegin,
-                             rangebegin);
+               const int w = RExC_parse - rangebegin;
+               Simple_vFAIL4("Invalid [] range \"%*.*s\"", w, w, rangebegin);
                range = 0; /* not a valid range */
            }
        }
@@ -4157,7 +4155,7 @@
                /* a bad range like \w-, [:word:]- ? */
                if (namedclass > OOB_NAMEDCLASS) {
                    if (ckWARN(WARN_REGEXP)) {
-                       int w =
+                       const int w =
                            RExC_parse >= rangebegin ?
                            RExC_parse - rangebegin : 0;
                        vWARN4(RExC_parse,

==== //depot/maint-5.8/perl/regexec.c#69 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#68~29916~    2007-01-22 08:26:58.000000000 -0800
+++ perl/regexec.c      2007-01-22 14:10:59.000000000 -0800
@@ -116,28 +116,20 @@
 #define CHR_SVLEN(sv) (do_utf8 ? sv_len_utf8(sv) : SvCUR(sv))
 #define CHR_DIST(a,b) (PL_reg_match_utf8 ? utf8_distance(a,b) : a - b)
 
-#define reghop_c(pos,off) ((char*)reghop((U8*)pos, off))
-#define reghopmaybe_c(pos,off) ((char*)reghopmaybe((U8*)pos, off))
-#define HOP(pos,off) (PL_reg_match_utf8 ? reghop((U8*)pos, off) : (U8*)(pos + 
off))
-#define HOPMAYBE(pos,off) (PL_reg_match_utf8 ? reghopmaybe((U8*)pos, off) : 
(U8*)(pos + off))
-#define HOPc(pos,off) ((char*)HOP(pos,off))
-#define HOPMAYBEc(pos,off) ((char*)HOPMAYBE(pos,off))
-
-#define HOPBACK(pos, off) (            \
-    (PL_reg_match_utf8)                        \
-       ? reghopmaybe((U8*)pos, -off)   \
+#define HOPc(pos,off) ((char *)(PL_reg_match_utf8 \
+           ? reghop3((U8*)pos, off, (U8*)(off >= 0 ? PL_regeol : PL_bostr)) \
+           : (U8*)(pos + off)))
+#define HOPBACKc(pos, off) ((char*)    \
+    ((PL_reg_match_utf8)               \
+       ? reghopmaybe3((U8*)pos, -off, ((U8*)(off < 0 ? PL_regeol : PL_bostr))) 
\
     : (pos - off >= PL_bostr)          \
        ? (U8*)(pos - off)              \
-    : (U8*)NULL                                \
+    : (U8*)NULL)                       \
 )
-#define HOPBACKc(pos, off) (char*)HOPBACK(pos, off)
 
-#define reghop3_c(pos,off,lim) ((char*)reghop3((U8*)pos, off, (U8*)lim))
 #define reghopmaybe3_c(pos,off,lim) ((char*)reghopmaybe3((U8*)pos, off, 
(U8*)lim))
 #define HOP3(pos,off,lim) (PL_reg_match_utf8 ? reghop3((U8*)pos, off, 
(U8*)lim) : (U8*)(pos + off))
-#define HOPMAYBE3(pos,off,lim) (PL_reg_match_utf8 ? reghopmaybe3((U8*)pos, 
off, (U8*)lim) : (U8*)(pos + off))
 #define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
-#define HOPMAYBE3c(pos,off,lim) ((char*)HOPMAYBE3(pos,off,lim))
 
 #define LOAD_UTF8_CHARCLASS(class,str) STMT_START { \
     if (!CAT2(PL_utf8_,class)) { bool ok; ENTER; save_re_context(); 
ok=CAT2(is_utf8_,class)((U8*)str); assert(ok); LEAVE; } } STMT_END
@@ -1888,10 +1880,10 @@
                s = HOPc(s, -back_max);
            }
            else {
-               char *t = (last1 >= PL_bostr) ? HOPc(last1, 1) : last1 + 1;
+               char * const t = (last1 >= PL_bostr) ? HOPc(last1, 1) : last1 + 
1;
 
                last1 = HOPc(s, -back_min);
-               s = t;          
+               s = t;
            }
            if (do_utf8) {
                while (s <= last1) {
@@ -4460,12 +4452,6 @@
 }
 
 STATIC U8 *
-S_reghop(pTHX_ U8 *s, I32 off)
-{
-    return S_reghop3(s, off, (U8*)(off >= 0 ? PL_regeol : PL_bostr));
-}
-
-STATIC U8 *
 S_reghop3(U8 *s, I32 off, U8* lim)
 {
     if (off >= 0) {
@@ -4490,12 +4476,6 @@
 }
 
 STATIC U8 *
-S_reghopmaybe(pTHX_ U8 *s, I32 off)
-{
-    return S_reghopmaybe3(s, off, (U8*)(off >= 0 ? PL_regeol : PL_bostr));
-}
-
-STATIC U8 *
 S_reghopmaybe3(U8* s, I32 off, U8* lim)
 {
     if (off >= 0) {

==== //depot/maint-5.8/perl/sv.c#302 (text) ====
Index: perl/sv.c
--- perl/sv.c#301~29920~        2007-01-22 11:20:43.000000000 -0800
+++ perl/sv.c   2007-01-22 14:10:59.000000000 -0800
@@ -1066,7 +1066,7 @@
        void ** const r3wt = &PL_body_roots[sv_type]; \
        LOCK_SV_MUTEX; \
        xpv = *((void **)(r3wt)) \
-         ? *((void **)(r3wt)) : S_more_bodies(aTHX_ sv_type); \
+         ? *((void **)(r3wt)) : more_bodies(sv_type); \
        *(r3wt) = *(void**)(xpv); \
        UNLOCK_SV_MUTEX; \
     } STMT_END
@@ -3342,7 +3342,7 @@
 
     case SVt_PVGV:
        if (dtype <= SVt_PVGV) {
-           S_glob_assign_glob(aTHX_ dstr, sstr, dtype);
+           glob_assign_glob(dstr, sstr, dtype);
            return;
        }
        /*FALLTHROUGH*/
@@ -3355,7 +3355,7 @@
            if ((int)SvTYPE(sstr) != stype) {
                stype = SvTYPE(sstr);
                if (stype == SVt_PVGV && dtype <= SVt_PVGV) {
-                   S_glob_assign_glob(aTHX_ dstr, sstr, dtype);
+                   glob_assign_glob(dstr, sstr, dtype);
                    return;
                }
            }
@@ -3383,13 +3383,13 @@
                GvMULTI_on(dstr);
                return;
            }
-           S_glob_assign_glob(aTHX_ dstr, sstr, dtype);
+           glob_assign_glob(dstr, sstr, dtype);
            return;
        }
 
        if (dtype >= SVt_PV) {
            if (dtype == SVt_PVGV) {
-               S_glob_assign_ref(aTHX_ dstr, sstr);
+               glob_assign_ref(dstr, sstr);
                return;
            }
            if (SvPVX_const(dstr)) {
@@ -4806,6 +4806,8 @@
 {
     const U8 *s = start;
 
+    PERL_UNUSED_CONTEXT;
+
     while (s < send && uoffset--)
        s += UTF8SKIP(s);
     if (s > send) {
@@ -5257,7 +5259,7 @@
     if (SvMAGICAL(sv) && !SvREADONLY(sv) && PL_utf8cache
        && (mg = mg_find(sv, PERL_MAGIC_utf8))) {
        if (mg->mg_ptr) {
-           STRLEN *cache = (STRLEN *) mg->mg_ptr;
+           STRLEN * const cache = (STRLEN *) mg->mg_ptr;
            if (cache[1] == byte) {
                /* An exact match. */
                *offsetp = cache[0];
@@ -9144,7 +9146,7 @@
        if (tblent->oldval == sv)
            return tblent;
     }
-    return 0;
+    return NULL;
 }
 
 void *
@@ -9152,7 +9154,7 @@
 {
     PTR_TBL_ENT_t const *const tblent = ptr_table_find(tbl, (const void *)sv);
     PERL_UNUSED_CONTEXT;
-    return tblent ? tblent->newval : (void *) 0;
+    return tblent ? tblent->newval : NULL;
 }
 
 /* add a new entry to a pointer-mapping table */

==== //depot/maint-5.8/perl/toke.c#139 (text) ====
Index: perl/toke.c
--- perl/toke.c#138~29914~      2007-01-22 07:29:10.000000000 -0800
+++ perl/toke.c 2007-01-22 14:10:59.000000000 -0800
@@ -419,7 +419,8 @@
                    "\t(Missing semicolon on previous line?)\n");
        else if (PL_oldoldbufptr && isIDFIRST_lazy_if(PL_oldoldbufptr,UTF)) {
            const char *t;
-           for (t = PL_oldoldbufptr; *t && (isALNUM_lazy_if(t,UTF) || *t == 
':'); t++) ;
+           for (t = PL_oldoldbufptr; *t && (isALNUM_lazy_if(t,UTF) || *t == 
':'); t++)
+               /**/;
            if (t < PL_bufptr && isSPACE(*t))
                Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
                        "\t(Do you need to predeclare %.*s?)\n",
@@ -437,7 +438,7 @@
 /*
  * S_missingterm
  * Complain about missing quote/regexp/heredoc terminator.
- * If it's called with (char *)NULL then it cauterizes the line buffer.
+ * If it's called with NULL then it cauterizes the line buffer.
  * If we're in a delimited string and the delimiter is a control
  * character, it's reformatted into a two-char sequence like ^C.
  * This is fatal.
@@ -650,7 +651,8 @@
     CopLINE_inc(PL_curcop);
     if (*s++ != '#')
        return;
-    while (SPACE_OR_TAB(*s)) s++;
+    while (SPACE_OR_TAB(*s))
+       s++;
     if (strnEQ(s, "line", 4))
        s += 4;
     else
@@ -659,9 +661,11 @@
        s++;
     else
        return;
-    while (SPACE_OR_TAB(*s)) s++;
+    while (SPACE_OR_TAB(*s))
+       s++;
     if (!isDIGIT(*s))
        return;
+
     n = s;
     while (isDIGIT(*s))
        s++;
@@ -858,14 +862,15 @@
 STATIC void
 S_check_uni(pTHX)
 {
-    char *s;
-    char *t;
+    const char *s;
+    const char *t;
 
     if (PL_oldoldbufptr != PL_last_uni)
        return;
     while (isSPACE(*PL_last_uni))
        PL_last_uni++;
-    for (s = PL_last_uni; isALNUM_lazy_if(s,UTF) || *s == '-'; s++) ;
+    for (s = PL_last_uni; isALNUM_lazy_if(s,UTF) || *s == '-'; s++)
+       /**/;
     if ((t = strchr(s, '(')) && t < PL_bufptr)
        return;
 
@@ -1425,7 +1430,7 @@
     UV literal_endpoint = 0;
 #endif
 
-    const char *leaveit =      /* set of acceptably-backslashed characters */
+    const char * const leaveit = /* set of acceptably-backslashed characters */
        PL_lex_inpat
            ? "[EMAIL PROTECTED]|()-nrtfeaxz0123456789[{]} \t\n\r\f\v#"
            : "";
@@ -2972,7 +2977,8 @@
                        do {
                            if (*d == 'M' || *d == 'm') {
                                const char * const m = d;
-                               while (*d && !isSPACE(*d)) d++;
+                               while (*d && !isSPACE(*d))
+                                   d++;
                                Perl_croak(aTHX_ "Too late for \"-%.*s\" 
option",
                                      (int)(d - m), m);
                            }
@@ -3706,7 +3712,7 @@
            const char tmp = *s++;
            if (tmp == '>')
                SHop(OP_RIGHT_SHIFT);
-           if (tmp == '=')
+           else if (tmp == '=')
                Rop(OP_GE);
        }
        s--;
@@ -3955,7 +3961,7 @@
                no_op("String",s);
        }
        if (!s)
-           missingterm((char*)0);
+           missingterm(NULL);
        yylval.ival = OP_CONST;
        TERM(sublex_start());
 
@@ -3972,7 +3978,7 @@
                no_op("String",s);
        }
        if (!s)
-           missingterm((char*)0);
+           missingterm(NULL);
        yylval.ival = OP_CONST;
        /* FIXME. I think that this can be const if char *d is replaced by
           more localised variables.  */
@@ -3990,7 +3996,7 @@
        if (PL_expect == XOPERATOR)
            no_op("Backticks",s);
        if (!s)
-           missingterm((char*)0);
+           missingterm(NULL);
        yylval.ival = OP_BACKTICK;
        set_csh();
        TERM(sublex_start());
@@ -4015,6 +4021,7 @@
            }
            /* avoid v123abc() or $h{v1}, allow C<print v10;> */
            else if (!isALPHA(*start) && (PL_expect == XTERM || PL_expect == 
XREF || PL_expect == XSTATE)) {
+               /* XXX Use gv_fetchpvn rather than stomping on a const string */
                const char c = *start;
                GV *gv;
                *start = '\0';
@@ -5047,7 +5054,7 @@
        case KEY_q:
            s = scan_str(s,FALSE,FALSE);
            if (!s)
-               missingterm((char*)0);
+               missingterm(NULL);
            yylval.ival = OP_CONST;
            TERM(sublex_start());
 
@@ -5057,7 +5064,7 @@
        case KEY_qw:
            s = scan_str(s,FALSE,FALSE);
            if (!s)
-               missingterm((char*)0);
+               missingterm(NULL);
            PL_expect = XOPERATOR;
            force_next(')');
            if (SvCUR(PL_lex_stuff)) {
@@ -5065,9 +5072,10 @@
                int warned = 0;
                d = SvPV_force(PL_lex_stuff, len);
                while (len) {
-                   SV *sv;
-                   for (; isSPACE(*d) && len; --len, ++d) ;
+                   for (; isSPACE(*d) && len; --len, ++d)
+                       /**/;
                    if (len) {
+                       SV *sv;
                        const char *b = d;
                        if (!warned && ckWARN(WARN_QW)) {
                            for (; !isSPACE(*d) && len; --len, ++d) {
@@ -5084,7 +5092,8 @@
                            }
                        }
                        else {
-                           for (; !isSPACE(*d) && len; --len, ++d) ;
+                           for (; !isSPACE(*d) && len; --len, ++d)
+                               /**/;
                        }
                        sv = newSVpvn(b, d-b);
                        if (DO_UTF8(PL_lex_stuff))
@@ -5108,7 +5117,7 @@
        case KEY_qq:
            s = scan_str(s,FALSE,FALSE);
            if (!s)
-               missingterm((char*)0);
+               missingterm(NULL);
            yylval.ival = OP_STRINGIFY;
            if (SvIVX(PL_lex_stuff) == '\'')
                SvIV_set(PL_lex_stuff, 0);      /* qq'$foo' should intepolate */
@@ -5121,7 +5130,7 @@
        case KEY_qx:
            s = scan_str(s,FALSE,FALSE);
            if (!s)
-               missingterm((char*)0);
+               missingterm(NULL);
            yylval.ival = OP_BACKTICK;
            set_csh();
            TERM(sublex_start());
@@ -11056,22 +11065,20 @@
     if (!isALPHA(*pos)) {
        U8 tmpbuf[UTF8_MAXBYTES+1];
 
-       if (*s == 'v') s++;  /* get past 'v' */
+       if (*s == 'v')
+           s++;  /* get past 'v' */
 
        sv_setpvn(sv, "", 0);
 
        for (;;) {
+           /* this is atoi() that tolerates underscores */
            U8 *tmpend;
            UV rev = 0;
-           {
-               /* this is atoi() that tolerates underscores */
-               const char *end = pos;
-               UV mult = 1;
-               while (--end >= s) {
-                   UV orev;
-                   if (*end == '_')
-                       continue;
-                   orev = rev;
+           const char *end = pos;
+           UV mult = 1;
+           while (--end >= s) {
+               if (*end != '_') {
+                   const UV orev = rev;
                    rev += (*end - '0') * mult;
                    mult *= 10;
                    if (orev > rev && ckWARN_d(WARN_OVERFLOW))

==== //depot/maint-5.8/perl/utf8.c#67 (text) ====
Index: perl/utf8.c
--- perl/utf8.c#66~29920~       2007-01-22 11:20:43.000000000 -0800
+++ perl/utf8.c 2007-01-22 14:10:59.000000000 -0800
@@ -403,7 +403,7 @@
 UV
 Perl_utf8n_to_uvuni(pTHX_ U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags)
 {
-    const U8 *s0 = s;
+    const U8 * const s0 = s;
     UV uv = *s, ouv = 0;
     STRLEN len = 1;
     const bool dowarn = ckWARN_d(WARN_UTF8);
@@ -754,12 +754,12 @@
 U8 *
 Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *len)
 {
-    U8 *send;
+    U8 * const save = s;
+    U8 * const send = s + *len;
     U8 *d;
-    U8 *save = s;
 
     /* ensure valid UTF-8 and chars < 256 before updating string */
-    for (send = s + *len; s < send; ) {
+    while (s < send) {
         U8 c = *s++;
 
         if (!UTF8_IS_INVARIANT(c) &&
@@ -941,9 +941,9 @@
 Perl_utf16_to_utf8_reversed(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen)
 {
     U8* s = (U8*)p;
-    U8* send = s + bytelen;
+    U8* const send = s + bytelen;
     while (s < send) {
-       U8 tmp = s[0];
+       const U8 tmp = s[0];
        s[0] = s[1];
        s[1] = tmp;
        s += 2;
@@ -1226,13 +1226,13 @@
     /* NOTE: "IsWord", not "IsAlnum", since Alnum is a true
      * descendant of isalnum(3), in other words, it doesn't
      * contain the '_'. --jhi */
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_alnum, "IsWord");
+    return is_utf8_common(p, &PL_utf8_alnum, "IsWord");
 }
 
 bool
 Perl_is_utf8_alnumc(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_alnumc, "IsAlnumC");
+    return is_utf8_common(p, &PL_utf8_alnumc, "IsAlnumC");
 }
 
 bool
@@ -1241,7 +1241,7 @@
     if (*p == '_')
        return TRUE;
     /* is_utf8_idstart would be more logical. */
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_idstart, "IdStart");
+    return is_utf8_common(p, &PL_utf8_idstart, "IdStart");
 }
 
 bool
@@ -1249,79 +1249,79 @@
 {
     if (*p == '_')
        return TRUE;
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_idcont, "IdContinue");
+    return is_utf8_common(p, &PL_utf8_idcont, "IdContinue");
 }
 
 bool
 Perl_is_utf8_alpha(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_alpha, "IsAlpha");
+    return is_utf8_common(p, &PL_utf8_alpha, "IsAlpha");
 }
 
 bool
 Perl_is_utf8_ascii(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_ascii, "IsAscii");
+    return is_utf8_common(p, &PL_utf8_ascii, "IsAscii");
 }
 
 bool
 Perl_is_utf8_space(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_space, "IsSpacePerl");
+    return is_utf8_common(p, &PL_utf8_space, "IsSpacePerl");
 }
 
 bool
 Perl_is_utf8_digit(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_digit, "IsDigit");
+    return is_utf8_common(p, &PL_utf8_digit, "IsDigit");
 }
 
 bool
 Perl_is_utf8_upper(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_upper, "IsUppercase");
+    return is_utf8_common(p, &PL_utf8_upper, "IsUppercase");
 }
 
 bool
 Perl_is_utf8_lower(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_lower, "IsLowercase");
+    return is_utf8_common(p, &PL_utf8_lower, "IsLowercase");
 }
 
 bool
 Perl_is_utf8_cntrl(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_cntrl, "IsCntrl");
+    return is_utf8_common(p, &PL_utf8_cntrl, "IsCntrl");
 }
 
 bool
 Perl_is_utf8_graph(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_graph, "IsGraph");
+    return is_utf8_common(p, &PL_utf8_graph, "IsGraph");
 }
 
 bool
 Perl_is_utf8_print(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_print, "IsPrint");
+    return is_utf8_common(p, &PL_utf8_print, "IsPrint");
 }
 
 bool
 Perl_is_utf8_punct(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_punct, "IsPunct");
+    return is_utf8_common(p, &PL_utf8_punct, "IsPunct");
 }
 
 bool
 Perl_is_utf8_xdigit(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_xdigit, "Isxdigit");
+    return is_utf8_common(p, &PL_utf8_xdigit, "Isxdigit");
 }
 
 bool
 Perl_is_utf8_mark(pTHX_ U8 *p)
 {
-    return S_is_utf8_common(aTHX_ p, &PL_utf8_mark, "IsM");
+    return is_utf8_common(p, &PL_utf8_mark, "IsM");
 }
 
 /*
@@ -1392,7 +1392,7 @@
                        STRLEN tlen = 0;
                        
                        while (t < tend) {
-                            UV c = utf8_to_uvchr(t, &tlen);
+                            const UV c = utf8_to_uvchr(t, &tlen);
                             if (tlen > 0) {
                                  d = uvchr_to_utf8(d, UNI_TO_NATIVE(c));
                                  t += tlen;
@@ -1417,12 +1417,11 @@
     }
 
     if (!len && *swashp) {
-        UV uv2 = swash_fetch(*swashp, tmpbuf, TRUE);
-        
+       const UV uv2 = swash_fetch(*swashp, tmpbuf, TRUE);
+
         if (uv2) {
              /* It was "normal" (a single character mapping). */
-             UV uv3 = UNI_TO_NATIVE(uv2);
-             
+             const UV uv3 = UNI_TO_NATIVE(uv2);
              len = uvchr_to_utf8(ustrp, uv3) - ustrp;
         }
     }
@@ -1719,7 +1718,6 @@
        return (tmps[off] << 24) + (tmps[off+1] << 16) + (tmps[off+2] << 8) + 
tmps[off + 3] ;
     }
     Perl_croak(aTHX_ "panic: swash_fetch got swatch of unexpected bit width");
-    return 0;
 }
 
 /* Note:
@@ -2173,7 +2171,8 @@
 
 The pointer to the PV of the dsv is returned.
 
-=cut */
+=cut
+*/
 char *
 Perl_sv_uni_display(pTHX_ SV *dsv, SV *ssv, STRLEN pvlim, UV flags)
 {
End of Patch.

Reply via email to