This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #132158) abort compilation if we see an error compiling a form
[perl5.git] / lib / locale.pm
index 53c01ff..02e4bb2 100644 (file)
@@ -1,6 +1,6 @@
 package locale;
 
-our $VERSION = '1.06';
+our $VERSION = '1.09';
 use Config;
 
 $Carp::Internal{ (__PACKAGE__) } = 1;
@@ -9,6 +9,17 @@ $Carp::Internal{ (__PACKAGE__) } = 1;
 
 locale - Perl pragma to use or avoid POSIX locales for built-in operations
 
+=head1 WARNING
+
+DO NOT USE this pragma in scripts that have multiple
+L<threads|threads> active.  The locale is not local to a single thread.
+Another thread may change the locale at any time, which could cause at a
+minimum that a given thread is operating in a locale it isn't expecting
+to be in.  On some platforms, segfaults can also occur.  The locale
+change need not be explicit; some operations cause perl to change the
+locale itself.  You are vulnerable simply by having done a C<"use
+locale">.
+
 =head1 SYNOPSIS
 
     @x = sort @y;      # Native-platform/Unicode code point sort order
@@ -97,15 +108,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
             my $LC = "LC_" . uc($arg);
 
             my $bit = eval "&POSIX::$LC";
-            if (defined $bit) {
+            if (defined $bit) { # XXX Should we warn that this category isn't
+                                # supported on this platform, or make it
+                                # always be the C locale?
 
                 # Verify our assumption.
                 if (! ($bit >= 0 && $bit < 31)) {