This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: reduce scope of local var
authorDavid Mitchell <davem@iabyn.com>
Mon, 15 May 2017 11:51:56 +0000 (12:51 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:01 +0000 (09:11 +0100)
fix_ldbl_sprintf_bug is only used in one block of code so declare it in
that block.
Given that that block is only compiled under HAS_LDBL_SPRINTF_BUG,
which seems only to be for some obscure Irix issues from 2002,
I haven't actually tested this.

sv.c

diff --git a/sv.c b/sv.c
index 1c4f276..38eccea 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11580,12 +11580,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
        bool is_utf8 = FALSE;  /* is this item utf8?   */
         bool used_explicit_ix = FALSE;
         bool arg_missing = FALSE;
        bool is_utf8 = FALSE;  /* is this item utf8?   */
         bool used_explicit_ix = FALSE;
         bool arg_missing = FALSE;
-#ifdef HAS_LDBL_SPRINTF_BUG
-       /* This is to try to fix a bug with irix/nonstop-ux/powerux and
-          with sfio - Allen <allens@cpan.org> */
-       bool fix_ldbl_sprintf_bug = FALSE;
-#endif
-
        char esignbuf[4];
        U8 utf8buf[UTF8_MAXBYTES+1];
        STRLEN esignlen = 0;
        char esignbuf[4];
        U8 utf8buf[UTF8_MAXBYTES+1];
        STRLEN esignlen = 0;
@@ -12506,7 +12500,10 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 
            if ((intsize == 'q') && (c == 'f') &&
                ((fv < MY_DBL_MAX_BUG) && (fv > -MY_DBL_MAX_BUG)) &&
 
            if ((intsize == 'q') && (c == 'f') &&
                ((fv < MY_DBL_MAX_BUG) && (fv > -MY_DBL_MAX_BUG)) &&
-               (float_need < DBL_DIG)) {
+               (float_need < DBL_DIG))
+            {
+                bool fix_ldbl_sprintf_bug = FALSE;
+
                /* it's going to be short enough that
                 * long double precision is not needed */
 
                /* it's going to be short enough that
                 * long double precision is not needed */
 
@@ -12525,6 +12522,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                        fix_ldbl_sprintf_bug = TRUE;
                    }
                }
                        fix_ldbl_sprintf_bug = TRUE;
                    }
                }
+
                if (fix_ldbl_sprintf_bug == TRUE) {
                    double temp;
 
                if (fix_ldbl_sprintf_bug == TRUE) {
                    double temp;