From dbd0e4b2939e30e0a6761a93e6ed7bc564ccb964 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Fri, 26 Apr 2013 04:10:16 -0300 Subject: [PATCH] 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. --- ext/POSIX/lib/POSIX.pm | 2 +- ext/POSIX/t/time.t | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm index d0bc3fd..83a9e2c 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 46e786a..472624f 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 -- 2.7.4