In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/0d94136269cd77412aa60b5660955d3f682df082?hp=ed7df46e9e6349457d5a4b7dab19ea6691587174>

- Log -----------------------------------------------------------------
commit 0d94136269cd77412aa60b5660955d3f682df082
Author: Karl Williamson <[email protected]>
Date:   Sun Oct 23 22:03:08 2016 -0600

    lib/locale.t: Skip testing known incompatible locales
    
    Some locales are incompatible with Perl.  The only multi-byte locales
    accepted are UTF-8 ones.  ISO 646 locales can have things like a '|' be
    a \w, which will create havoc with regular expressions.  This commit
    causes locale.t to not test such locales, and to note which ones are
    skipped, and why.
    
    If we were to do the tests anyway, it could create segfaults.  For
    example locales with state can have their states screwed up by Perl,
    which knows nothing about that.  One could argue that the locale should
    be immune from bad state, and not segfault, but that is not under Perl's
    control, and we will get blamed initially, anyway, when a segfault
    happens, so don't test them.
    
    The multi-byte locales are more incompatible with Perl than the 7-bit
    locales that aren't ASCII compatible.  So it could be argued that those
    should be tested, but I don't want to undertake the work to separate out
    the two causes from each other.  The ISO 646 locales are essentially
    obsolete, and hence unlikely to be encountered in practice, so there
    would be little pay off for doing that work.

M       lib/locale.t

commit 62e020bba4f0b8f5bd7eaa0b6631f69dabd93353
Author: Karl Williamson <[email protected]>
Date:   Sun Oct 23 22:02:13 2016 -0600

    lib/locale.t: Add skip(), fail() functions

M       lib/locale.t

commit cd1f7080d3051d9fde0052d36878e96e7138929c
Author: Karl Williamson <[email protected]>
Date:   Tue Oct 25 11:10:15 2016 -0600

    t/loc_tools.pl: Make find_locales accept string input
    
    Prior to this commit, in order to work properly, find_locales required
    the C enum number for a locale category.  This relaxes that to allow the
    name of the category as well.  Thus it will work seamlessly when a given
    category isn't on the platform.  Unless wrapped in an eval, or checked
    before using, it was a potential bug to call this function at all.  This
    is because it didn't properly handle a string, and trying to find the
    locale number might fail on a given platform.

M       lib/locale.t
M       t/loc_tools.pl
M       t/run/locale.t

commit e1f890227e6a6ad28b8cc6fcc6846cb1e09795d5
Author: Karl Williamson <[email protected]>
Date:   Tue Oct 25 10:49:01 2016 -0600

    t/loc_tools.pl: Add 'use strict'

M       t/loc_tools.pl

commit 6fa6c80bec193b32cfe1d30c3c80171a806c2062
Author: Karl Williamson <[email protected]>
Date:   Mon Oct 24 17:45:45 2016 -0600

    t/loc_tools.pl: Move some code earlier in the file
    
    This is a simple move, with no changes.  This will make things flow more
    logically after a future commit.

M       t/loc_tools.pl

commit 2c6c88ec63f27f7733250293ba1c0b4621f88bce
Author: Karl Williamson <[email protected]>
Date:   Sun Oct 23 21:27:33 2016 -0600

    t/loc_tools.pl: Complement sense of optional parameter
    
    Most often we want to only look at locales that are compatible with
    Perl.  Make that the default for the optional parameter.

M       ext/POSIX/t/wrappers.t
M       lib/locale_threads.t
M       t/loc_tools.pl
M       t/run/locale.t

commit 9c5fc553bd49285d24109379b377238e40f4a510
Author: Karl Williamson <[email protected]>
Date:   Sun Oct 23 21:18:20 2016 -0600

    t/loc_tools.pl: Fix not catching incompatible locales
    
    This is looking for a warning generated by the core when a setlocale is
    done to one that it deems incompatible with Perl.  However, the warning
    isn't generated unless locales are being used, as Perl mostly ignores
    locales, so even if the background one is incompatible, it doesn't
    matter.

M       t/loc_tools.pl

commit 210ad863c08686fcbbae5cbea678101fd44cc082
Author: Karl Williamson <[email protected]>
Date:   Wed Oct 26 11:02:46 2016 -0600

    utf8.c: Silence unused parameter compiler warning

M       utf8.c

commit 60b45a7d8e4f80dd40a123909c6545a886ab9ee4
Author: Karl Williamson <[email protected]>
Date:   Tue Oct 25 11:32:38 2016 -0600

    locale.c: Use meaningful initialization msg
    
    This string is initialized to keep it out of BSS.  It is supposed to be
    overwritten by the first call to it.  Use a message that informs the
    user if there is a bug and the overwriting doesn't work properly.  This
    commit is the result of some freebsd releases that don't properly
    implement strlcpy.

M       locale.c

commit cc9eaeb0a26002a9b1dbeca65710fe618235263c
Author: Karl Williamson <[email protected]>
Date:   Wed Oct 26 12:09:36 2016 -0600

    locale.c: Output warning if debugging and 'no warnings'
    
    This message is helpful if called with -DL, even if warnings are off

M       locale.c
-----------------------------------------------------------------------

Summary of changes:
 ext/POSIX/t/wrappers.t |   4 +-
 lib/locale.t           |  52 ++++++++++-
 lib/locale_threads.t   |   3 +-
 locale.c               |  21 +++--
 t/loc_tools.pl         | 245 +++++++++++++++++++++++++++++++------------------
 t/run/locale.t         |   5 +-
 utf8.c                 |   4 +
 7 files changed, 226 insertions(+), 108 deletions(-)

diff --git a/ext/POSIX/t/wrappers.t b/ext/POSIX/t/wrappers.t
index f09b92595f..2be966061d 100644
--- a/ext/POSIX/t/wrappers.t
+++ b/ext/POSIX/t/wrappers.t
@@ -28,9 +28,7 @@ if (locales_enabled('LC_MESSAGES')) {
     local $! = 1;
     my $english_message = "$!"; # Should be C locale since not in scope of
                                 # "use locale"
-    for $non_english_locale (find_locales(&POSIX::LC_MESSAGES,
-                                          'reasonable_locales_only'))
-    {
+    for $non_english_locale (find_locales(&POSIX::LC_MESSAGES)) {
         use locale;
         setlocale(&POSIX::LC_MESSAGES, $non_english_locale);
         $! = 1;
diff --git a/lib/locale.t b/lib/locale.t
index e8cedbca5a..4a2cb75234 100644
--- a/lib/locale.t
+++ b/lib/locale.t
@@ -103,6 +103,14 @@ sub ok {
     return ($result) ? 1 : 0;
 }
 
+sub skip {
+    return ok 1, "skipped: " . shift;
+}
+
+sub fail {
+    return ok 0, shift;
+}
+
 # First we'll do a lot of taint checking for locales.
 # This is the easiest to test, actually, as any locale,
 # even the default locale will taint under 'use locale'.
@@ -742,7 +750,46 @@ debug "Scanning for locales...\n";
 
 require POSIX; import POSIX ':locale_h';
 
-my @Locale = find_locales([ &POSIX::LC_CTYPE, &POSIX::LC_NUMERIC, 
&POSIX::LC_ALL ]);
+my @Locale = find_locales([ 'LC_CTYPE', 'LC_NUMERIC', 'LC_ALL' ]);
+my @include_incompatible_locales = find_locales('LC_CTYPE',
+                                                'even incompatible locales');
+
+# The locales included in the incompatible list that aren't in the compatible
+# one.
+my @incompatible_locales;
+
+if (@Locale < @include_incompatible_locales) {
+    my %seen;
+    @seen{@Locale} = ();
+
+    foreach my $item (@include_incompatible_locales) {
+        push @incompatible_locales, $item unless exists $seen{$item};
+    }
+
+    # For each bad locale, switch into it to find out why it's incompatible
+    for my $bad_locale (@incompatible_locales) {
+        my @warnings;
+
+        use warnings 'locale';
+
+        local $SIG{__WARN__} = sub {
+            my $warning = $_[0];
+            chomp $warning;
+            push @warnings, ($warning =~ s/\n/\n# /sgr);
+        };
+
+        setlocale(&POSIX::LC_CTYPE, $bad_locale);
+
+        my $message = "testing of locale '$bad_locale' is skipped";
+        if (@warnings) {
+            skip $message . ":\n# " . join "\n# ", @warnings;
+        }
+        else {
+            fail $message . ", because it is was found to be incompatible with"
+                          . " Perl, but could not discern reason";
+        }
+    }
+}
 
 debug "Locales =\n";
 for ( @Locale ) {
@@ -932,7 +979,8 @@ sub report_multi_result {
     report_result($Locale, $i, @$results_ref == 0, $message);
 }
 
-my $first_locales_test_number = $final_without_setlocale + 1;
+my $first_locales_test_number = $final_without_setlocale
+                              + 1 + @incompatible_locales;
 my $locales_test_number;
 my $not_necessarily_a_problem_test_number;
 my $first_casing_test_number;
diff --git a/lib/locale_threads.t b/lib/locale_threads.t
index 5559f91bed..72d322ee37 100644
--- a/lib/locale_threads.t
+++ b/lib/locale_threads.t
@@ -14,8 +14,7 @@ BEGIN {
 }
 
 SKIP: { # perl #127708
-    my @locales = grep { $_ !~ / ^ C \b | POSIX /x } 
find_locales('LC_MESSAGES',
-                                                        
'non-problematic-only');
+    my @locales = grep { $_ !~ / ^ C \b | POSIX /x } 
find_locales('LC_MESSAGES');
     skip("No valid locale to test with", 1) unless @locales;
 
     # reset the locale environment
diff --git a/locale.c b/locale.c
index d04258740c..15cccd9a2b 100644
--- a/locale.c
+++ b/locale.c
@@ -328,8 +328,9 @@ Perl_new_ctype(pTHX_ const char *newctype)
          * NUL */
         char bad_chars_list[ (94 * 4) + (3 * 5) + 1 ];
 
-        bool check_for_problems = ckWARN_d(WARN_LOCALE); /* No warnings means
-                                                            no check */
+        /* Don't check for problems if we are suppressing the warnings */
+        bool check_for_problems = ckWARN_d(WARN_LOCALE)
+                               || UNLIKELY(DEBUG_L_TEST);
         bool multi_byte_locale = FALSE;     /* Assume is a single-byte locale
                                                to start */
         unsigned int bad_count = 0;         /* Count of bad characters */
@@ -418,11 +419,12 @@ Perl_new_ctype(pTHX_ const char *newctype)
                               ? bad_chars_list
                               : ""
                             );
-            /* If we are actually in the scope of the locale, output the
-             * message now.  Otherwise we save it to be output at the first
-             * operation using this locale, if that actually happens.  Most
-             * programs don't use locales, so they are immune to bad ones */
-            if (IN_LC(LC_CTYPE)) {
+            /* If we are actually in the scope of the locale or are debugging,
+             * output the message now.  Otherwise we save it to be output at
+             * the first operation using this locale, if that actually happens.
+             * Most programs don't use locales, so they are immune to bad ones.
+             * */
+            if (IN_LC(LC_CTYPE) || UNLIKELY(DEBUG_L_TEST)) {
 
                 /* We have to save 'newctype' because the setlocale() just
                  * below may destroy it.  The next setlocale() further down
@@ -2670,8 +2672,9 @@ Perl__setlocale_debug_string(const int category,        
/* category number,
 
     /* initialise to a non-null value to keep it out of BSS and so keep
      * -DPERL_GLOBAL_STRUCT_PRIVATE happy */
-    static char ret[128] = "x";
-
+    static char ret[128] = "If you can read this, thank your buggy C"
+                           " library strlcpy(), and change your hints file"
+                           " to undef it";
     my_strlcpy(ret, "setlocale(", sizeof(ret));
 
     switch (category) {
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index bead7c74d1..50b36d5056 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -11,21 +11,67 @@
 # Functions whose names begin with underscore are internal helper functions
 # for this file, and are not to be used by outside callers.
 
+use strict;
+
 eval { require POSIX; import POSIX 'locale_h'; };
-$has_locale_h = ! $@;
+my $has_locale_h = ! $@;
+
+# LC_ALL can be -1 on some platforms.  And, in fact the implementors could
+# legally use any integer to represent any category.  But it makes the most
+# sense for them to have used small integers.  Below, we create new locale
+# numbers for ones missing from this machine.  We make them very negative,
+# hopefully more negative than anything likely to be a valid category on the
+# platform, but also below is a check to be sure that our guess is valid.
+my $max_bad_category_number = -1000000;
+
+# Initialize this hash so that it looks like e.g.,
+#   6 => 'CTYPE',
+# where 6 is the value of &POSIX::LC_CTYPE
+my %category_name;
+my %category_number;
+unless ($@) {
+    my $number_for_missing_category = $max_bad_category_number;
+    foreach my $name (qw(ALL COLLATE CTYPE MESSAGES MONETARY NUMERIC TIME)) {
+        my $number = eval "&POSIX::LC_$name";
+
+        if ($@) {
+            # Use a negative number (smaller than any legitimate category
+            # number) if the platform doesn't support this category, so we
+            # have an entry for all the ones that might be specified in calls
+            # to us.
+            $number = $number_for_missing_category-- if $@;
+        }
+        elsif (   $number !~ / ^ -? \d+ $ /x
+               || $number <=  $max_bad_category_number)
+        {
+            # We think this should be an int.  And it has to be larger than
+            # any of our synthetic numbers.
+            die "Unexpected locale category number '$number' for LC_$name"
+        }
+
+        $category_name{$number} = "$name";
+        $category_number{$name} = $number;
+    }
+}
 
 sub _trylocale ($$$$) { # For use only by other functions in this file!
 
     # Adds the locale given by the first parameter to the list given by the
-    # 3rd iff the platform supports the locale in each of the categories given
-    # by the 2nd parameter, which is either a single category or a reference
-    # to a list of categories The 4th parameter is true if to reject locales
-    # that aren't apparently fully compatible with Perl.
+    # 3rd iff the platform supports the locale in each of the category numbers
+    # given by the 2nd parameter, which is either a single category or a
+    # reference to a list of categories.  The list must be sorted so that
+    # CTYPE is first, COLLATE is last unless ALL is present, in which case
+    # that comes after COLLATE.  This is because locale.c detects bad locales
+    # only with CTYPE, and COLLATE on some platforms can core dump if it is a
+    # bad locale.
+    #
+    # The 4th parameter is true if to accept locales that aren't apparently
+    # fully compatible with Perl.
 
     my $locale = shift;
     my $categories = shift;
     my $list = shift;
-    my $only_plays_well = shift;
+    my $allow_incompatible = shift;
 
     return if ! $locale || grep { $locale eq $_ } @$list;
 
@@ -41,9 +87,15 @@ sub _trylocale ($$$$) { # For use only by other functions in 
this file!
         $plays_well = 0 if $_[0] =~ /Locale .* may not work well/i
     };
 
+    # Incompatible locales aren't warned about unless using locales.
+    use locale;
+
     foreach my $category (@$categories) {
+        die "category '$category' must instead be a number"
+                                            unless $category =~ / ^ -? \d+ $ 
/x;
+
         return unless setlocale($category, $locale);
-        return if $only_plays_well && ! $plays_well;
+        return if ! $plays_well && ! $allow_incompatible;
     }
 
     if ($badutf8) {
@@ -80,58 +132,27 @@ sub _decode_encodings { # For use only by other functions 
in this file!
     return @enc;
 }
 
-# LC_ALL can be -1 on some platforms.  And, in fact the implementors could
-# legally use any integer to represent any category.  But it makes the most
-# sense for them to have used small integers.  Below, we create new locale
-# numbers for ones missing from this machine.  We make them very negative,
-# hopefully more negative than anything likely to be a valid category on the
-# platform, but also below is a check to be sure that our guess is valid.
-my $max_bad_category_number = -1000000;
-
-# Initialize this hash so that it looks like e.g.,
-#   6 => 'CTYPE',
-# where 6 is the value of &POSIX::LC_CTYPE
-my %category_name;
-unless ($@) {
-    my $number_for_missing_category = $max_bad_category_number;
-    foreach my $name (qw(ALL COLLATE CTYPE MESSAGES MONETARY NUMERIC TIME)) {
-        my $number = eval "&POSIX::LC_$name";
-
-        if ($@) {
-            # Use a negative number (smaller than any legitimate category
-            # number) if the platform doesn't support this category, so we
-            # have an entry for all the ones that might be specified in calls
-            # to us.
-            $number = $number_for_missing_category-- if $@;
-        }
-        elsif (   $number !~ / ^ -? \d+ $ /x
-               || $number <=  $max_bad_category_number)
-        {
-            # We think this should be an int.  And it has to be larger than
-            # any of our synthetic numbers.
-            die "Unexpected locale category number '$number' for LC_$name"
-        }
-
-        $category_name{$number} = "$name";
-    }
-}
-
 sub locales_enabled(;$) {
     # Returns 0 if no locale handling is available on this platform; otherwise
     # 1.
     #
     # The optional parameter is a reference to a list of individual POSIX
-    # locale categories.  If present, this function also returns 0 if any of
-    # them are individually not available on this platform; otherwise 1.
-    # Actually, it is acceptable for the list to be just a simple scalar
-    # denoting a single category.
+    # locale categories.  If any of the individual categories specified by the
+    # optional parameter is all digits (and an optional leading minus), it is
+    # taken to be the C enum for the category (e.g., &POSIX::LC_CTYPE).
+    # Otherwise it should be a string name of the category, like 'LC_TIME'.
+    # The initial 'LC_' is optional.  It is a fatal error to call this with
+    # something that isn't a known category to the platform.
     #
-    # If any of the individual categories specified by the optional parameter
-    # is all digits (and an optional leading minus), it is taken to be the C
-    # enum for the category (e.g., &POSIX::LC_CTYPE).  Otherwise it should be
-    # a string name of the category, like 'LC_TIME'.  The initial 'LC_' is
-    # optional.  It is a fatal error to call this with something that isn't a
-    # known category
+    # This optional parameter denotes which POSIX locale categories must be
+    # available on the platform.  If any aren't available, this function
+    # returns 0; otherwise it returns 1 and changes the list for the caller so
+    # that any category names are converted into their equivalent numbers, and
+    # sorts it to match the expectations of _trylocale.
+    #
+    # It is acceptable for the second parameter to be just a simple scalar
+    # denoting a single category (either name or number).  No conversion into
+    # a number is done in this case.
 
     use Config;
 
@@ -143,10 +164,24 @@ sub locales_enabled(;$) {
 
     # Done with the global possibilities.  Now check if any passed in category
     # is disabled.
+
     my $categories_ref = shift;
+    my $return_categories_numbers = 0;
+    my @categories_numbers;
+    my $has_LC_ALL = 0;
+    my $has_LC_COLLATE = 0;
+
     if (defined $categories_ref) {
-        $categories_ref = [ $categories_ref ] if ! ref $categories_ref;
-        my @local_categories_copy = @$categories_ref;
+        my @local_categories_copy;
+
+        if (ref $categories_ref) {
+            @local_categories_copy = @$$categories_ref;
+            $return_categories_numbers = 1;
+        }
+        else {  # Single category passed in
+            @local_categories_copy = $categories_ref;
+        }
+
         for my $category_name_or_number (@local_categories_copy) {
             my $name;
             my $number;
@@ -174,25 +209,60 @@ sub locales_enabled(;$) {
 
             eval "defined &POSIX::LC_$name";
             return 0 if $@;
+
+            if ($return_categories_numbers) {
+                if ($name eq 'CTYPE') {
+                    unshift @categories_numbers, $number;   # Always first
+                }
+                elsif ($name eq 'ALL') {
+                    $has_LC_ALL = 1;
+                }
+                elsif ($name eq 'COLLATE') {
+                    $has_LC_COLLATE = 1;
+                }
+                else {
+                    push @categories_numbers, $number;
+                }
+            }
+        }
+    }
+
+    if ($return_categories_numbers) {
+
+        # COLLATE comes after all other locales except ALL, which comes last
+        if ($has_LC_COLLATE) {
+            push @categories_numbers, $category_number{'COLLATE'};
         }
+        if ($has_LC_ALL) {
+            push @categories_numbers, $category_number{'ALL'};
+        }
+        $$categories_ref = \@categories_numbers;
     }
 
     return 1;
 }
 
 
-sub find_locales ($;$) {  # Returns an array of all the locales we found on the
-                          # system.  If the optional 2nd parameter is
-                          # non-zero, the list is restricted to those locales
-                          # that play well with Perl.
-                          # The first parameter is either a single locale
-                          # category or a reference to a list of categories to
-                          # find valid locales for it (or in the case of
-                          # multiple) for all of them.
+sub find_locales ($;$) {
+
+    # Returns an array of all the locales we found on the system.  If the
+    # optional 2nd parameter is non-zero, the list includes all found locales;
+    # otherwise it is restricted to those locales that play well with Perl, as
+    # far as we can easily determine.
+    #
+    # The first parameter is either a single locale category or a reference to
+    # a list of categories to find valid locales for it (or in the case of
+    # multiple) for all of them.  Each category can be a name (like 'LC_ALL'
+    # or simply 'ALL') or the C enum value for the category.
+
     my $categories = shift;
-    my $only_plays_well = shift // 0;
+    my $allow_incompatible = shift // 0;
+
+    $categories = [ $categories ] unless ref $categories;
+    return unless locales_enabled(\$categories);
 
-    return unless locales_enabled($categories);
+    # Note, the subroutine call above converts the $categories into a form
+    # suitable for _trylocale().
 
     # Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1"
     # and mingw32 uses said silly CRT
@@ -206,16 +276,17 @@ sub find_locales ($;$) {  # Returns an array of all the 
locales we found on the
     # UWIN seems to loop after taint tests, just skip for now
     return if ($^O =~ /^uwin/);
 
-    _trylocale("C", $categories, \@Locale, $only_plays_well);
-    _trylocale("POSIX", $categories, \@Locale, $only_plays_well);
+    my @Locale;
+    _trylocale("C", $categories, \@Locale, $allow_incompatible);
+    _trylocale("POSIX", $categories, \@Locale, $allow_incompatible);
     foreach (0..15) {
-        _trylocale("ISO8859-$_", $categories, \@Locale, $only_plays_well);
-        _trylocale("iso8859$_", $categories, \@Locale, $only_plays_well);
-        _trylocale("iso8859-$_", $categories, \@Locale, $only_plays_well);
-        _trylocale("iso_8859_$_", $categories, \@Locale, $only_plays_well);
-        _trylocale("isolatin$_", $categories, \@Locale, $only_plays_well);
-        _trylocale("isolatin-$_", $categories, \@Locale, $only_plays_well);
-        _trylocale("iso_latin_$_", $categories, \@Locale, $only_plays_well);
+        _trylocale("ISO8859-$_", $categories, \@Locale, $allow_incompatible);
+        _trylocale("iso8859$_", $categories, \@Locale, $allow_incompatible);
+        _trylocale("iso8859-$_", $categories, \@Locale, $allow_incompatible);
+        _trylocale("iso_8859_$_", $categories, \@Locale, $allow_incompatible);
+        _trylocale("isolatin$_", $categories, \@Locale, $allow_incompatible);
+        _trylocale("isolatin-$_", $categories, \@Locale, $allow_incompatible);
+        _trylocale("iso_latin_$_", $categories, \@Locale, $allow_incompatible);
     }
 
     # Sanitize the environment so that we can run the external 'locale'
@@ -236,7 +307,7 @@ sub find_locales ($;$) {  # Returns an array of all the 
locales we found on the
             # locales will cause all IO hadles to default to (assume) utf8
             next unless utf8::valid($_);
             chomp;
-            _trylocale($_, $categories, \@Locale, $only_plays_well);
+            _trylocale($_, $categories, \@Locale, $allow_incompatible);
         }
         close(LOCALES);
     } elsif ($^O eq 'VMS'
@@ -248,7 +319,7 @@ sub find_locales ($;$) {  # Returns an array of all the 
locales we found on the
         opendir(LOCALES, "SYS\$I18N_LOCALE:");
         while ($_ = readdir(LOCALES)) {
             chomp;
-            _trylocale($_, $categories, \@Locale, $only_plays_well);
+            _trylocale($_, $categories, \@Locale, $allow_incompatible);
         }
         close(LOCALES);
     } elsif (($^O eq 'openbsd' || $^O eq 'bitrig' ) && -e '/usr/share/locale') 
{
@@ -260,7 +331,7 @@ sub find_locales ($;$) {  # Returns an array of all the 
locales we found on the
         opendir(LOCALES, '/usr/share/locale');
         while ($_ = readdir(LOCALES)) {
             chomp;
-            _trylocale($_, $categories, \@Locale, $only_plays_well);
+            _trylocale($_, $categories, \@Locale, $allow_incompatible);
         }
         close(LOCALES);
     } else { # Final fallback.  Try our list of locales hard-coded here
@@ -284,31 +355,31 @@ sub find_locales ($;$) {  # Returns an array of all the 
locales we found on the
                 split /:/, $line;
             my @enc = _decode_encodings($encodings);
             foreach my $loc (split(/ /, $locale_name)) {
-                _trylocale($loc, $categories, \@Locale, $only_plays_well);
+                _trylocale($loc, $categories, \@Locale, $allow_incompatible);
                 foreach my $enc (@enc) {
                     _trylocale("$loc.$enc", $categories, \@Locale,
-                                                            $only_plays_well);
+                                                            
$allow_incompatible);
                 }
                 $loc = lc $loc;
                 foreach my $enc (@enc) {
                     _trylocale("$loc.$enc", $categories, \@Locale,
-                                                            $only_plays_well);
+                                                            
$allow_incompatible);
                 }
             }
             foreach my $lang (split(/ /, $language_codes)) {
-                _trylocale($lang, $categories, \@Locale, $only_plays_well);
+                _trylocale($lang, $categories, \@Locale, $allow_incompatible);
                 foreach my $country (split(/ /, $country_codes)) {
                     my $lc = "${lang}_${country}";
-                    _trylocale($lc, $categories, \@Locale, $only_plays_well);
+                    _trylocale($lc, $categories, \@Locale, 
$allow_incompatible);
                     foreach my $enc (@enc) {
                         _trylocale("$lc.$enc", $categories, \@Locale,
-                                                            $only_plays_well);
+                                                            
$allow_incompatible);
                     }
                     my $lC = "${lang}_\U${country}";
-                    _trylocale($lC, $categories, \@Locale, $only_plays_well);
+                    _trylocale($lC, $categories, \@Locale, 
$allow_incompatible);
                     foreach my $enc (@enc) {
                         _trylocale("$lC.$enc", $categories, \@Locale,
-                                                            $only_plays_well);
+                                                            
$allow_incompatible);
                     }
                 }
             }
@@ -378,9 +449,7 @@ sub find_utf8_ctype_locale (;$) { # Return the name of a 
locale that core Perl
 
     if (! defined $locales_ref) {
 
-        my @locales = find_locales(&POSIX::LC_CTYPE(),
-                                   1 # Reject iffy locales.
-                                  );
+        my @locales = find_locales(&POSIX::LC_CTYPE());
         $locales_ref = \@locales;
     }
 
diff --git a/t/run/locale.t b/t/run/locale.t
index 33c16b2a30..4a1ddef9f3 100644
--- a/t/run/locale.t
+++ b/t/run/locale.t
@@ -21,10 +21,7 @@ BEGIN {
 }
 use Config;
 my $have_strtod = $Config{d_strtod} eq 'define';
-my @locales = eval { find_locales( [ &LC_ALL, &LC_CTYPE, &LC_NUMERIC ],
-                                  1 # Only return locales that work well with
-                                    # Perl
-                                 ) };
+my @locales = find_locales( [ 'LC_ALL', 'LC_CTYPE', 'LC_NUMERIC' ]);
 skip_all("no locales available") unless @locales;
 
 # reset the locale environment
diff --git a/utf8.c b/utf8.c
index f017f7199a..80bafadea5 100644
--- a/utf8.c
+++ b/utf8.c
@@ -535,6 +535,10 @@ S_is_utf8_overlong_given_start_byte_ok(const U8 * const s, 
const STRLEN len)
         return TRUE;
     }
 
+#else
+
+    PERL_UNUSED_ARG(len);
+
 #endif
 
     return FALSE;

--
Perl5 Master Repository

Reply via email to