This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
The revenge of the consts
authorAndy Lester <andy@petdance.com>
Thu, 3 May 2007 00:45:54 +0000 (19:45 -0500)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 3 May 2007 09:30:08 +0000 (09:30 +0000)
Message-ID: <20070503054554.GA30975@petdance.com>

p4raw-id: //depot/perl@31123

av.c
embed.fnc
numeric.c
proto.h
regcomp.c

diff --git a/av.c b/av.c
index 39b4b7d..9361e28 100644 (file)
--- a/av.c
+++ b/av.c
@@ -656,10 +656,9 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num)
     }
     if (num) {
        register SV **ary;
-       I32 slide;
-       i = AvFILLp(av);
+       const I32 i = AvFILLp(av);
        /* Create extra elements */
-       slide = i > 0 ? i : 0;
+       const I32 slide = i > 0 ? i : 0;
        num += slide;
        av_extend(av, i + num);
        AvFILLp(av) += num;
index 70cfbe5..5211577 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -1351,7 +1351,7 @@ Es        |STRLEN |reguni         |NN const struct RExC_state_t *state|UV uv|NN char *s
 Es     |regnode*|regclass      |NN struct RExC_state_t *state|U32 depth
 ERsn   |I32    |regcurly       |NN const char *
 Es     |regnode*|reg_node      |NN struct RExC_state_t *state|U8 op
-Es     |UV     |reg_recode     |const char value|NULLOK SV **encp
+Es     |UV     |reg_recode     |const char value|NN SV **encp
 Es     |regnode*|regpiece      |NN struct RExC_state_t *state|NN I32 *flagp|U32 depth
 Es     |regnode*|reg_namedseq  |NN struct RExC_state_t *state|NULLOK UV *valuep
 Es     |void   |reginsert      |NN struct RExC_state_t *state|U8 op|NN regnode *opnd|U32 depth
index 20fd7bd..34264f3 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -953,10 +953,9 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value)
        else if (!seen_dp && GROK_NUMERIC_RADIX(&s, send)) {
            seen_dp = 1;
            if (sig_digits > MAX_SIG_DIGITS) {
-               ++s;
-               while (isDIGIT(*s)) {
+               do {
                    ++s;
-               }
+               } while (isDIGIT(*s));
                break;
            }
        }
diff --git a/proto.h b/proto.h
index 85f2c11..1199789 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -3650,7 +3650,9 @@ STATIC I32        S_regcurly(const char *)
 STATIC regnode*        S_reg_node(pTHX_ struct RExC_state_t *state, U8 op)
                        __attribute__nonnull__(pTHX_1);
 
-STATIC UV      S_reg_recode(pTHX_ const char value, SV **encp);
+STATIC UV      S_reg_recode(pTHX_ const char value, SV **encp)
+                       __attribute__nonnull__(pTHX_2);
+
 STATIC regnode*        S_regpiece(pTHX_ struct RExC_state_t *state, I32 *flagp, U32 depth)
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2);
index 6b123c3..4729780 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -6434,8 +6434,7 @@ S_reg_recode(pTHX_ const char value, SV **encp)
 {
     STRLEN numlen = 1;
     SV * const sv = sv_2mortal(newSVpvn(&value, numlen));
-    const char * const s = encp && *encp ? sv_recode_to_utf8(sv, *encp)
-                                        : SvPVX(sv);
+    const char * const s = *encp ? sv_recode_to_utf8(sv, *encp) : SvPVX(sv);
     const STRLEN newlen = SvCUR(sv);
     UV uv = UNICODE_REPLACEMENT;
 
@@ -6446,8 +6445,7 @@ S_reg_recode(pTHX_ const char value, SV **encp)
 
     if (!newlen || numlen != newlen) {
        uv = UNICODE_REPLACEMENT;
-       if (encp)
-           *encp = NULL;
+       *encp = NULL;
     }
     return uv;
 }