summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Fraser <fraserbn@gmail.com>2013-04-26 04:10:16 -0300
committerBrian Fraser <fraserbn@gmail.com>2014-01-18 12:56:12 -0300
commitdbd0e4b2939e30e0a6761a93e6ed7bc564ccb964 (patch)
treea47e091af9a1702478213f66954e244790043b46
parent05fc2f9f4339d5d042aa53504a2b1a549d42ffb6 (diff)
downloadperl-dbd0e4b2939e30e0a6761a93e6ed7bc564ccb964.tar.gz
ext/POSIX/t/time.t: Conditionalize the use of setlocale/LC_TIME
On Android, all locales are simply disabled, which broke the assumption that LC_TIME is always available.
-rw-r--r--ext/POSIX/lib/POSIX.pm2
-rw-r--r--ext/POSIX/t/time.t11
2 files changed, 9 insertions, 4 deletions
diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm
index d0bc3fd065..83a9e2c4e9 100644
--- a/ext/POSIX/lib/POSIX.pm
+++ b/ext/POSIX/lib/POSIX.pm
@@ -4,7 +4,7 @@ use warnings;
our ($AUTOLOAD, %SIGRT);
-our $VERSION = '1.38';
+our $VERSION = '1.38_01';
require XSLoader;
diff --git a/ext/POSIX/t/time.t b/ext/POSIX/t/time.t
index 46e786ada7..472624f3e0 100644
--- a/ext/POSIX/t/time.t
+++ b/ext/POSIX/t/time.t
@@ -47,8 +47,11 @@ is(asctime(POSIX::localtime(12345678)), ctime(12345678),
"asctime() and ctime() at 12345678");
# Careful! strftime() is locale sensitive. Let's take care of that
-my $orig_loc = setlocale(LC_TIME) || die "Cannot get locale information: $!";
-setlocale(LC_TIME, "C") || die "Cannot setlocale() to C: $!";
+my $orig_loc = 'C';
+if ( $Config{d_setlocale} ) {
+ $orig_loc = setlocale(LC_TIME) || die "Cannot get locale information: $!";
+ setlocale(LC_TIME, "C") || die "Cannot setlocale() to C: $!";
+}
my $jan_16 = 15 * 86400;
is(ctime($jan_16), strftime("%a %b %d %H:%M:%S %Y\n", CORE::localtime($jan_16)),
"get ctime() equal to strftime()");
@@ -69,7 +72,9 @@ is(ord strftime($ss, POSIX::localtime(time)),
223, 'Format string has correct character');
unlike($ss, qr/\w/, 'Still not internally UTF-8 encoded');
-setlocale(LC_TIME, $orig_loc) || die "Cannot setlocale() back to orig: $!";
+if ( $Config{d_setlocale} ) {
+ setlocale(LC_TIME, $orig_loc) || die "Cannot setlocale() back to orig: $!";
+}
# clock() seems to have different definitions of what it does between POSIX
# and BSD. Cygwin, Win32, and Linux lean the BSD way. So, the tests just