summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-04-25 21:01:47 -0600
committerRicardo Signes <rjbs@cpan.org>2011-12-18 21:52:02 -0500
commit909d37874ccef92b27d21a593cdff97325899d07 (patch)
tree0c0b13bd2f029c1073ae457c61cc1f1f8fad2db4
parentecf16f8ce81c68e837abacea2d30af83208e8223 (diff)
downloadperl-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
-rw-r--r--toke.c4
-rw-r--r--util.c8
2 files changed, 9 insertions, 3 deletions
diff --git a/toke.c b/toke.c
index c642e7ff2f..7f8faf4b82 100644
--- a/toke.c
+++ b/toke.c
@@ -2193,11 +2193,13 @@ S_force_version(pTHX_ char *s, int guessing)
if (*d == ';' || isSPACE(*d) || *d == '{' || *d == '}' || !*d) {
SV *ver;
#ifdef USE_LOCALE_NUMERIC
- char *loc = setlocale(LC_NUMERIC, "C");
+ char *loc = savepv(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
#endif
s = scan_num(s, &pl_yylval);
#ifdef USE_LOCALE_NUMERIC
setlocale(LC_NUMERIC, loc);
+ Safefree(loc);
#endif
version = pl_yylval.opval;
ver = cSVOPx(version)->op_sv;
diff --git a/util.c b/util.c
index 316b1cc524..391528624e 100644
--- a/util.c
+++ b/util.c
@@ -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 */