From 73fc293b284e8476f4358f5194765c845ece9427 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 20 Jan 2014 11:38:44 -0700 Subject: t/loc_tools.pl: Extract out finding locales from locale.t Several different test files need to find the locales on the system, and each currently has rolled its own methods to do that. This commit creates a new file t/loc_tools.pl which is designed to be a common place for these tools. lib/locale.t did the most thorough job of finding locales, so t/loc_tools.pl is built upon what it had, which is now deleted from locale.t. The code in t/loc_tools.pl was copied from lib/locale.t with white space changes and changes to make this be a subroutine, and helper functions renamed to begin with an underscore, and changing the hard-coded list to be in a DATA section so it doesn't have to be actually used unless necessary. --- lib/locale.t | 202 ++--------------------------------------------------------- 1 file changed, 5 insertions(+), 197 deletions(-) (limited to 'lib/locale.t') diff --git a/lib/locale.t b/lib/locale.t index 89153202ce..57c9d0637d 100644 --- a/lib/locale.t +++ b/lib/locale.t @@ -19,6 +19,7 @@ BEGIN { print "1..0\n"; exit; } + require './loc_tools.pl'; $| = 1; } @@ -479,210 +480,17 @@ my $final_without_setlocale = $test_num; debug "# Scanning for locales...\n"; -# Note that it's okay that some languages have their native names -# capitalized here even though that's not "right". They are lowercased -# anyway later during the scanning process (and besides, some clueless -# vendor might have them capitalized erroneously anyway). - -my $locales = </dev/null|")) { - while () { - # It seems that /usr/bin/locale steadfastly outputs 8 bit data, which - # ain't great when we're running this testPERL_UNICODE= so that utf8 - # locales will cause all IO hadles to default to (assume) utf8 - next unless utf8::valid($_); - chomp; - trylocale($_); - } - close(LOCALES); -} elsif ($^O eq 'VMS' && defined($ENV{'SYS$I18N_LOCALE'}) && -d 'SYS$I18N_LOCALE') { -# The SYS$I18N_LOCALE logical name search list was not present on -# VAX VMS V5.5-12, but was on AXP && VAX VMS V6.2 as well as later versions. - opendir(LOCALES, "SYS\$I18N_LOCALE:"); - while ($_ = readdir(LOCALES)) { - chomp; - trylocale($_); - } - close(LOCALES); -} elsif (($^O eq 'openbsd' || $^O eq 'bitrig' ) && -e '/usr/share/locale') { - - # OpenBSD doesn't have a locale executable, so reading /usr/share/locale - # is much easier and faster than the last resort method. - - opendir(LOCALES, '/usr/share/locale'); - while ($_ = readdir(LOCALES)) { - chomp; - trylocale($_); - } - close(LOCALES); -} else { - - # This is going to be slow. - - foreach my $locale (split(/\n/, $locales)) { - my ($locale_name, $language_codes, $country_codes, $encodings) = - split(/:/, $locale); - my @enc = decode_encodings($encodings); - foreach my $loc (split(/ /, $locale_name)) { - trylocale($loc); - foreach my $enc (@enc) { - trylocale("$loc.$enc"); - } - $loc = lc $loc; - foreach my $enc (@enc) { - trylocale("$loc.$enc"); - } - } - foreach my $lang (split(/ /, $language_codes)) { - trylocale($lang); - foreach my $country (split(/ /, $country_codes)) { - my $lc = "${lang}_${country}"; - trylocale($lc); - foreach my $enc (@enc) { - trylocale("$lc.$enc"); - } - my $lC = "${lang}_\U${country}"; - trylocale($lC); - foreach my $enc (@enc) { - trylocale("$lC.$enc"); - } - } - } - } -} - setlocale(&POSIX::LC_ALL, "C"); -@Locale = sort @Locale; +my @Locale = find_locales(); debug "# Locales =\n"; for ( @Locale ) { debug "# $_\n"; } +my %posixes; + my %Problem; my %Okay; my %Testing; @@ -799,7 +607,7 @@ my $not_necessarily_a_problem_test_number; my $first_casing_test_number; my %setlocale_failed; # List of locales that setlocale() didn't work on -foreach $Locale (@Locale) { +foreach my $Locale (@Locale) { $locales_test_number = $first_locales_test_number - 1; debug "#\n"; debug "# Locale = $Locale\n"; -- cgit v1.2.1