Skip to content

Commit 901d2d9

Browse files
khwilliamsonLeont
authored andcommitted
version::07locale.t: Use I18N::Langinfo, not POSIX::localeconv()
The former is always present on recent perl versions; the latter might not be.
1 parent 11248b8 commit 901d2d9

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

t/07locale.t

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ BEGIN {
1414
use_ok('version', 0.9931);
1515
}
1616

17+
sub radix { # Returns the radix character for the current locale.
18+
19+
# Use localeconv() on earlier perls; if it is just a stub, assume a dot.
20+
if (! $^V or $^V lt v5.37.4) {
21+
return localeconv()->{decimal_point} || ".";
22+
}
23+
24+
# localeconv() may be a stub on some platforms. But on later perls,
25+
# langinfo() will always exist and returns the best available value.
26+
use if $^V && $^V ge v5.37.4, 'I18N::Langinfo' => qw(langinfo RADIXCHAR);
27+
return langinfo(RADIXCHAR);
28+
}
29+
1730
SKIP: {
1831
skip 'No locale testing for Perl < 5.6.0', 7 if $] < 5.006;
1932
skip 'No locale testing without d_setlocale', 7
@@ -36,10 +49,10 @@ SKIP: {
3649
while (<DATA>) {
3750
chomp;
3851
$loc = setlocale( LC_ALL, $_);
39-
last if $loc && localeconv()->{decimal_point} eq ',';
52+
last if $loc && radix() eq ',';
4053
}
4154
skip 'Cannot test locale handling without a comma locale', 6
42-
unless $loc and localeconv()->{decimal_point} eq ',';
55+
unless $loc and radix() eq ',';
4356

4457
setlocale(LC_NUMERIC, $loc);
4558
$ver = 1.23; # has to be floating point number

0 commit comments

Comments
 (0)