This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #37714] XSUB.h version check may fail due to locale
authorJohn Peacock <jpeacock@rowman.com>
Sun, 17 Sep 2006 16:58:58 +0000 (12:58 -0400)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 18 Sep 2006 08:35:21 +0000 (08:35 +0000)
Message-ID: <450DB712.4040703@rowman.com>

p4raw-id: //depot/perl@28864

universal.c
util.c

index 52395cc..251fbac 100644 (file)
@@ -691,10 +691,11 @@ XS(XS_version_qv)
 #ifdef USE_LOCALE_NUMERIC
                char *loc = setlocale(LC_NUMERIC, "C");
 #endif
-               const STRLEN len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVgf, SvNVX(ver));
+               STRLEN len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVgf, SvNVX(ver));
 #ifdef USE_LOCALE_NUMERIC
                setlocale(LC_NUMERIC, loc);
 #endif
+               while (tbuf[len-1] == '0' && len > 0) len--;
                version = savepvn(tbuf, len);
            }
            else
diff --git a/util.c b/util.c
index dedd81a..7e26322 100644 (file)
--- a/util.c
+++ b/util.c
@@ -4303,11 +4303,10 @@ Perl_upg_version(pTHX_ SV *ver)
     if ( SvNOK(ver) ) /* may get too much accuracy */ 
     {
        char tbuf[64];
-       STRLEN len;
 #ifdef USE_LOCALE_NUMERIC
        char *loc = setlocale(LC_NUMERIC, "C");
 #endif
-       len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver));
+       STRLEN len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver));
 #ifdef USE_LOCALE_NUMERIC
        setlocale(LC_NUMERIC, loc);
 #endif