diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1999-06-17 22:42:03 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1999-06-17 22:42:03 +0000 |
commit | 097ee67dff1c60f201bc09435bc6eaeeafcd8123 (patch) | |
tree | 16efe7bbad1c2e935c57baa65ede283aa053c621 /dump.c | |
parent | 908f8bc1445ea9eef07cec82a8241c080da1cc4e (diff) | |
download | perl-097ee67dff1c60f201bc09435bc6eaeeafcd8123.tar.gz |
Fixed two long-standing locale bugs.
Both problems were related to numeric locale which
controls the radix character aka the decimal separator.
(1) printf (and sprintf) were resetting the numeric locale to C.
(2) Using locale-numerically formatted floating point
numbers (e.g. "1,23") together with -w caused warnings about
"isn't numeric". The operations were working fine, though,
because atof() was using the local locale.
Both problems reported by Stefan Vogtner.
Introduced a wrapper for atof() that attempts to convert
the string both ways. This helps Perl to understand
numbers like this "4.56" even when using a local locale
makes atof() understand only numbers like this "7,89".
Remaining related problems, both of which existed before
this patch and continue to exist after this patch:
(a) The behaviour of print() is _not_ as documented by perllocale.
Instead of always using the C locale, print() does use the
local locale, just like the *printf() do. This may be fixable
now that switching to-and-fro between locales has been made
more consistent, but fixing print() would change existing
behaviour. perllocale is not changed by this patch.
(b) If a number has been stringified (say, via "$number") under
a local locale, the cached string value persists even under
"no locale". This may or may not be a problem: operations
work fine because the original number is still there, but
that the string form keeps its locale-ish outlook may be
somewhat confusing.
p4raw-id: //depot/cfgperl@3542
Diffstat (limited to 'dump.c')
-rw-r--r-- | dump.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -277,8 +277,9 @@ Perl_sv_peek(pTHX_ SV *sv) } } else if (SvNOKp(sv)) { - SET_NUMERIC_STANDARD(); + RESTORE_NUMERIC_STANDARD(); Perl_sv_catpvf(aTHX_ t, "(%g)",SvNVX(sv)); + RESTORE_NUMERIC_LOCAL(); } else if (SvIOKp(sv)) { /* XXXX: IV, UV? */ if (SvIsUV(sv)) @@ -895,8 +896,9 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo PerlIO_putc(file, '\n'); } if (type >= SVt_PVNV || type == SVt_NV) { - SET_NUMERIC_STANDARD(); + RESTORE_NUMERIC_STANDARD(); Perl_dump_indent(aTHX_ level, file, " NV = %.*g\n", DBL_DIG, SvNVX(sv)); + RESTORE_NUMERIC_LOCAL(); } if (SvROK(sv)) { Perl_dump_indent(aTHX_ level, file, " RV = 0x%lx\n", (long)SvRV(sv)); |