summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2015-01-27 11:41:55 -0700
committerKarl Williamson <khw@cpan.org>2015-02-07 10:02:02 -0700
commit21732d5c67323d747a91102253591325b3569ec3 (patch)
tree8c72fd116c9cdca63ea4fb9cd4dc224c77d47949 /t
parent44129e4698cf2866be96e739c41415dda2b74567 (diff)
downloadperl-21732d5c67323d747a91102253591325b3569ec3.tar.gz
loc_tools.pl: do a 'require' before module's function call
This was failing to do the require before testing if the function in the module existed, so if the require hadn't been done by someone else, it would show as not existing, and so would fail unnecessarily. The other fix is to not assume the require has been done, so in the right circumstances, this could have an undefined function error. But all current uses had already done the require, so this bug has yet to show up.
Diffstat (limited to 't')
-rw-r--r--t/loc_tools.pl8
1 files changed, 7 insertions, 1 deletions
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index 502af602ae..6a6cdf4644 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -227,6 +227,9 @@ sub is_locale_utf8 ($) { # Return a boolean as to if core Perl thinks the input
# On z/OS, even locales marked as UTF-8 aren't.
return 0 if ord "A" != 65;
+ eval { require POSIX; import POSIX 'locale_h'; };
+ return 0 if ! defined &POSIX::LC_CTYPE;
+
my $locale = shift;
use locale;
@@ -272,8 +275,11 @@ sub find_utf8_ctype_locale (;$) { # Return the name of a locale that core Perl
# tries all locales it can find on the
# platform
my $locales_ref = shift;
- return if !defined &POSIX::LC_CTYPE;
+
if (! defined $locales_ref) {
+ eval { require POSIX; import POSIX 'locale_h'; };
+ return if ! defined &POSIX::LC_CTYPE;
+
my @locales = find_locales(&POSIX::LC_CTYPE(),
1 # Reject iffy locales.
);