This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/loc_tools.pl: Fix bug with locale tests in win32
authorKarl Williamson <khw@cpan.org>
Mon, 9 Mar 2015 18:18:27 +0000 (12:18 -0600)
committerKarl Williamson <khw@cpan.org>
Mon, 9 Mar 2015 18:25:33 +0000 (12:25 -0600)
This bug was introduced by commit
128e4113466e835078eb016709e5d23b86be3120.

Win32 doesn't have an LC_MESSAGES, so calls using that name failed.

t/loc_tools.pl

index 9e4320b..ae8ff64 100644 (file)
@@ -79,9 +79,15 @@ sub _decode_encodings {
 my %category_name;
 eval { require POSIX; import POSIX 'locale_h'; };
 unless ($@) {
+    my $number_for_missing_category = 0;
     foreach my $name (qw(ALL COLLATE CTYPE MESSAGES MONETARY NUMERIC TIME)) {
         my $number = eval "&POSIX::LC_$name";
-        next if $@;
+
+        # Use a negative number if the platform doesn't support this category,
+        # so we have an entry for all ones that might be specified in calls to
+        # us.
+        $number = --$number_for_missing_category if $@;
+
         $category_name{$number} = "$name";
     }
 }