diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-04-25 21:01:47 -0600 |
---|---|---|
committer | Ricardo Signes <rjbs@cpan.org> | 2011-12-18 21:52:02 -0500 |
commit | 909d37874ccef92b27d21a593cdff97325899d07 (patch) | |
tree | 0c0b13bd2f029c1073ae457c61cc1f1f8fad2db4 /util.c | |
parent | ecf16f8ce81c68e837abacea2d30af83208e8223 (diff) | |
download | perl-909d37874ccef92b27d21a593cdff97325899d07.tar.gz |
toke.c, util.c: setlocale returns new locale, not old
This means we have to call setlocale with a NULL second parameter
to get the correct old value; then call it with the new value
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -4950,14 +4950,18 @@ Perl_upg_version(pTHX_ SV *ver, bool qv) if ( SvNOK(ver) && !( SvPOK(ver) && sv_len(ver) == 3 ) ) { + STRLEN len; + /* may get too much accuracy */ char tbuf[64]; #ifdef USE_LOCALE_NUMERIC - char *loc = setlocale(LC_NUMERIC, "C"); + char *loc = savepv(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); #endif - STRLEN len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver)); + len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver)); #ifdef USE_LOCALE_NUMERIC setlocale(LC_NUMERIC, loc); + Safefree(loc); #endif while (tbuf[len-1] == '0' && len > 0) len--; if ( tbuf[len-1] == '.' ) len--; /* eat the trailing decimal */ |