ext/POSIX/t/time.t: Conditionalize the use of setlocale/LC_TIME
authorBrian Fraser <fraserbn@gmail.com>
Fri, 26 Apr 2013 07:10:16 +0000 (04:10 -0300)
committerBrian Fraser <fraserbn@gmail.com>
Sat, 18 Jan 2014 15:56:12 +0000 (12:56 -0300)
On Android, all locales are simply disabled, which broke the assumption
that LC_TIME is always available.

ext/POSIX/lib/POSIX.pm
ext/POSIX/t/time.t

index d0bc3fd..83a9e2c 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 
 our ($AUTOLOAD, %SIGRT);
 
-our $VERSION = '1.38';
+our $VERSION = '1.38_01';
 
 require XSLoader;
 
index 46e786a..472624f 100644 (file)
@@ -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