From 401883da45255f0b584b4803939e6458fb615ad7 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 4 Aug 2022 15:22:57 -0600 Subject: [PATCH] version::07locale.t: Use I18N::Langinfo, not POSIX::localeconv() The former is always present; the latter might not be. --- cpan/version/t/07locale.t | 17 +++++++++++++++-- t/porting/customized.dat | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cpan/version/t/07locale.t b/cpan/version/t/07locale.t index 69dafe61130f..b86466fc80e9 100644 --- a/cpan/version/t/07locale.t +++ b/cpan/version/t/07locale.t @@ -14,6 +14,19 @@ BEGIN { use_ok('version', 0.9930); } +sub radix { # Returns the radix character for the current locale. + + # Use localeconv() on earlier perls; if it is just a stub, assume a dot. + if (! $^V or $^V lt v5.37.4) { + return localeconv()->{decimal_point} || "."; + } + + # localeconv() may be a stub on some platforms. But on later perls, + # langinfo() will always exist and returns the best available value. + use if $^V && $^V ge v5.37.4, 'I18N::Langinfo' => qw(langinfo RADIXCHAR); + return langinfo(RADIXCHAR); +} + SKIP: { skip 'No locale testing for Perl < 5.6.0', 7 if $] < 5.006; skip 'No locale testing without d_setlocale', 7 @@ -38,10 +51,10 @@ SKIP: { while () { chomp; $loc = setlocale( LC_ALL, $_); - last if $loc && localeconv()->{decimal_point} eq ','; + last if $loc && radix() eq ','; } skip 'Cannot test locale handling without a comma locale', 6 - unless $loc and localeconv()->{decimal_point} eq ','; + unless $loc and radix() eq ','; setlocale(LC_NUMERIC, $loc); $ver = 1.23; # has to be floating point number diff --git a/t/porting/customized.dat b/t/porting/customized.dat index c1c29d96ebeb..7886ef1aeaae 100644 --- a/t/porting/customized.dat +++ b/t/porting/customized.dat @@ -21,5 +21,5 @@ Time::Piece cpan/Time-Piece/Piece.pm 8cec8b66183ceddb9bf2b6af35dcdd345bc9adfa Time::Piece cpan/Time-Piece/Piece.xs 543152540ee17788a638b2c5746b86c3d04401d1 Win32API::File cpan/Win32API-File/File.pm 8fd212857f821cb26648878b96e57f13bf21b99e Win32API::File cpan/Win32API-File/File.xs beb870fed4490d2faa547b4a8576b8d64d1d27c5 -version cpan/version/lib/version.pm 8080cfe1fb21d5248c8ff5133b298d249d11e8e8 -version cpan/version/t/07locale.t 6731c4a69ef8deaead7b084b69b603b7cc8a189a +version cpan/version/lib/version.pm a963b513cf812bd7f4d28b3422efd9904e70a34c +version cpan/version/t/07locale.t e3ee07d9f9159acb807a7fa29c712cc64f9b950b