summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-06-10 20:18:50 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-06-10 20:25:48 -0400
commit395e49858e6cabdc5c8ecc0647e256452bd20f64 (patch)
treec590d337eba99128faed38e8f68d2e8517fb5ab3
parent097675bf0fb77cbfa1453e5928bafec9b7f0c482 (diff)
downloadperl-395e49858e6cabdc5c8ecc0647e256452bd20f64.tar.gz
Locale tests assumed POSIX, not true in minitest.
-rw-r--r--lib/locale.pm7
-rw-r--r--t/loc_tools.pl5
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/locale.pm b/lib/locale.pm
index 52279a1693..886fb3b491 100644
--- a/lib/locale.pm
+++ b/lib/locale.pm
@@ -96,9 +96,14 @@ sub import {
$arg =~ s/^://;
+ eval { require POSIX; import POSIX 'locale_h'; };
+ unless (defined &POSIX::LC_CTYPE) {
+ return;
+ }
+
# Map our names to the ones defined by POSIX
$arg = "LC_" . uc($arg);
- use POSIX 'locale_h';
+
my $bit = eval "&POSIX::$arg";
if (defined $bit) {
# 1 is added so that the pseudo-category :characters, which is
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index 90865e4702..bac8cc7f1a 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -90,7 +90,10 @@ sub find_locales ($) { # Returns an array of all the locales we found on the
# Done this way in case this is 'required' in the caller before seeing if
# this is miniperl.
- require POSIX; import POSIX 'locale_h';
+ eval { require POSIX; import POSIX 'locale_h'; };
+ unless (defined &POSIX::LC_CTYPE) {
+ return;
+ }
_trylocale("C", $categories, \@Locale);
_trylocale("POSIX", $categories, \@Locale);