This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: [perl #129766] Internal cleanup in numeric.c
authorAndy Lester <andy@petdance.com>
Fri, 30 Sep 2016 16:20:47 +0000 (10:20 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 19 Oct 2016 04:21:30 +0000 (22:21 -0600)
No functional changes

numeric.c

index 0c73749..7e05966 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -1022,7 +1022,7 @@ Perl_grok_number_flags(pTHX_ const char *pv, STRLEN len, UV *valuep, U32 flags)
   if ((s + 2 < send) && strchr("inqs#", toFOLD(*s))) {
       /* Really detect inf/nan. Start at d, not s, since the above
        * code might have already consumed the "1." or "1". */
-      int infnan = Perl_grok_infnan(aTHX_ &d, send);
+      const int infnan = Perl_grok_infnan(aTHX_ &d, send);
       if ((infnan & IS_NUMBER_INFINITY)) {
           return (numtype | infnan); /* Keep sign for infinity. */
       }
@@ -1089,7 +1089,7 @@ Perl_grok_atoUV(const char *pv, UV *valptr, const char** endptr)
                 /* This could be unrolled like in grok_number(), but
                  * the expected uses of this are not speed-needy, and
                  * unlikely to need full 64-bitness. */
-                U8 digit = *s++ - '0';
+                const U8 digit = *s++ - '0';
                 if (val < uv_max_div_10 ||
                     (val == uv_max_div_10 && digit <= uv_max_mod_10)) {
                     val = val * 10 + digit;
@@ -1221,9 +1221,6 @@ Perl_my_atof(pTHX_ const char* s)
         DECLARATION_FOR_LC_NUMERIC_MANIPULATION;
         STORE_LC_NUMERIC_SET_TO_NEEDED();
         if (PL_numeric_radix_sv && IN_LC(LC_NUMERIC)) {
-            const char *standard = NULL, *local = NULL;
-            bool use_standard_radix;
-
             /* Look through the string for the first thing that looks like a
              * decimal point: either the value in the current locale or the
              * standard fallback of '.'. The one which appears earliest in the
@@ -1231,10 +1228,9 @@ Perl_my_atof(pTHX_ const char* s)
              * that we have to determine this beforehand because on some
              * systems, Perl_atof2 is just a wrapper around the system's atof.
              * */
-            standard = strchr(s, '.');
-            local = strstr(s, SvPV_nolen(PL_numeric_radix_sv));
-
-            use_standard_radix = standard && (!local || standard < local);
+            const char * const standard = strchr(s, '.');
+            const char * const local = strstr(s, SvPV_nolen(PL_numeric_radix_sv));
+            const bool use_standard_radix = standard && (!local || standard < local);
 
             if (use_standard_radix)
                 SET_NUMERIC_STANDARD();
@@ -1266,7 +1262,7 @@ S_my_atof_infnan(pTHX_ const char* s, bool negative, const char* send, NV* value
 {
     const char *p0 = negative ? s - 1 : s;
     const char *p = p0;
-    int infnan = grok_infnan(&p, send);
+    const int infnan = grok_infnan(&p, send);
     if (infnan && p != p0) {
         /* If we can generate inf/nan directly, let's do so. */
 #ifdef NV_INF
@@ -1428,9 +1424,9 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value)
 
 #if defined(NV_INF) || defined(NV_NAN)
     {
-        const char* endp;
+        char* endp;
         if ((endp = S_my_atof_infnan(aTHX_ s, negative, send, value)))
-            return (char*)endp;
+            return endp;
     }
 #endif