vutil.c: Use existing macros instead of reinventing them
authorKarl Williamson <khw@cpan.org>
Sat, 4 Jan 2014 17:53:17 +0000 (18:53 +0100)
committerKarl Williamson <public@khwilliamson.com>
Sat, 4 Jan 2014 20:33:06 +0000 (13:33 -0700)
If there had been documentation referring to these macros, I would have
known they existed instead of reinventing them (not as well as the
originals).

vutil.c

diff --git a/vutil.c b/vutil.c
index 06680dd..6cbfc72 100644 (file)
--- a/vutil.c
+++ b/vutil.c
@@ -564,13 +564,7 @@ Perl_upg_version(pTHX_ SV *ver, bool qv)
        char tbuf[64];
        SV *sv = SvNVX(ver) > 10e50 ? newSV(64) : 0;
        char *buf;
-#ifdef USE_LOCALE_NUMERIC
-       char *loc = NULL;
-       if (! PL_numeric_standard) {
-           loc = savepv(setlocale(LC_NUMERIC, NULL));
-           setlocale(LC_NUMERIC, "C");
-       }
-#endif
+        STORE_NUMERIC_LOCAL_SET_STANDARD();
        if (sv) {
            Perl_sv_catpvf(aTHX_ sv, "%.9"NVff, SvNVX(ver));
            len = SvCUR(sv);
@@ -580,12 +574,7 @@ Perl_upg_version(pTHX_ SV *ver, bool qv)
            len = my_snprintf(tbuf, sizeof(tbuf), "%.9"NVff, SvNVX(ver));
            buf = tbuf;
        }
-#ifdef USE_LOCALE_NUMERIC
-       if (loc) {
-           setlocale(LC_NUMERIC, loc);
-           Safefree(loc);
-       }
-#endif
+        RESTORE_NUMERIC_LOCAL();
        while (buf[len-1] == '0' && len > 0) len--;
        if ( buf[len-1] == '.' ) len--; /* eat the trailing decimal */
        version = savepvn(buf, len);