summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2017-09-07 16:33:09 -0600
committerKarl Williamson <khw@cpan.org>2017-09-09 21:27:46 -0600
commitd9e2553cbadc371a615c0363a9d9424817047189 (patch)
tree5229753726d8193e7314711fd65e6a090fe37890 /ext
parentf741678155ebcc9639c420c23996e89e67bb0a4b (diff)
downloadperl-d9e2553cbadc371a615c0363a9d9424817047189.tar.gz
I18N-Langinfo: Use new fcn Perl_langinfo()
This automatically fixes the bug where it always returned a dot for the decimal point character.
Diffstat (limited to 'ext')
-rw-r--r--ext/I18N-Langinfo/Langinfo.pm6
-rw-r--r--ext/I18N-Langinfo/Langinfo.xs2
-rw-r--r--ext/I18N-Langinfo/t/Langinfo.t25
3 files changed, 29 insertions, 4 deletions
diff --git a/ext/I18N-Langinfo/Langinfo.pm b/ext/I18N-Langinfo/Langinfo.pm
index 033d8de1d7..1b1a480ec5 100644
--- a/ext/I18N-Langinfo/Langinfo.pm
+++ b/ext/I18N-Langinfo/Langinfo.pm
@@ -72,7 +72,7 @@ our @EXPORT_OK = qw(
YESSTR
);
-our $VERSION = '0.13';
+our $VERSION = '0.14';
XSLoader::load();
@@ -90,7 +90,9 @@ I18N::Langinfo - query locale information
=head1 DESCRIPTION
The langinfo() function queries various locale information that can be
-used to localize output and user interfaces. The langinfo() requires
+used to localize output and user interfaces. It uses the current underlying
+locale, regardless of whether or not it was called from within the scope of
+S<C<use locale>>. The langinfo() requires
one numeric argument that identifies the locale constant to query:
if no argument is supplied, C<$_> is used. The numeric constants
appropriate to be used as arguments are exportable from I18N::Langinfo.
diff --git a/ext/I18N-Langinfo/Langinfo.xs b/ext/I18N-Langinfo/Langinfo.xs
index 582b7fa634..aae48c2b28 100644
--- a/ext/I18N-Langinfo/Langinfo.xs
+++ b/ext/I18N-Langinfo/Langinfo.xs
@@ -27,7 +27,7 @@ langinfo(code)
SETERRNO(EINVAL, LIB_INVARG);
RETVAL = &PL_sv_undef;
} else {
- RETVAL = newSVpv(nl_langinfo(code), 0);
+ RETVAL = newSVpv(Perl_langinfo(code), 0);
}
#else
croak("nl_langinfo() not implemented on this architecture");
diff --git a/ext/I18N-Langinfo/t/Langinfo.t b/ext/I18N-Langinfo/t/Langinfo.t
index 25d30e6fb3..10a660e6d6 100644
--- a/ext/I18N-Langinfo/t/Langinfo.t
+++ b/ext/I18N-Langinfo/t/Langinfo.t
@@ -2,6 +2,7 @@
use strict;
use Config;
use Test::More;
+require "../../t/loc_tools.pl";
plan skip_all => "I18N::Langinfo or POSIX unavailable"
if $Config{'extensions'} !~ m!\bI18N/Langinfo\b!;
@@ -20,7 +21,7 @@ my %want =
my @want = sort keys %want;
-plan tests => 1 + 3 * @constants + keys(@want);
+plan tests => 1 + 3 * @constants + keys(@want) + 1;
use_ok('I18N::Langinfo', 'langinfo', @constants);
@@ -46,3 +47,25 @@ for my $i (1..@want) {
is (langinfo(&$try), $want{$try}, "$try => '$want{$try}'");
}
}
+
+my $comma_locale;
+for (find_locales( [ 'LC_NUMERIC' ] )) {
+ use POSIX;
+ use locale;
+ setlocale(LC_NUMERIC, $_) or next;
+ my $in = 4.2; # avoid any constant folding bugs
+ my $s = sprintf("%g", $in);
+ if ($s eq "4,2") {
+ $comma_locale = $_;
+ last;
+ }
+}
+
+SKIP: {
+ skip "Couldn't find a locale with a comma decimal pt", 1
+ unless $comma_locale;
+
+ no strict 'refs';
+ is (langinfo(&RADIXCHAR), ",",
+ "Returns ',' for decimal pt for locale '$comma_locale'");
+}