In perl.git, the branch smoke-me/khw-alpine has been updated <https://perl5.git.perl.org/perl.git/commitdiff/adc761b954808b41d4a00197605d450162ffbda7?hp=428a2d898b65fb1eb0d85080e60b830e9879ca28>
- Log ----------------------------------------------------------------- commit adc761b954808b41d4a00197605d450162ffbda7 Author: Karl Williamson <[email protected]> Date: Thu Feb 7 22:11:08 2019 -0700 smoke4 ----------------------------------------------------------------------- Summary of changes: lib/locale.t | 6 ++++-- perl.h | 45 +++++++++++++++++++++++++-------------------- t/loc_tools.pl | 5 +++++ t/run/locale.t | 18 +++++++++--------- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/lib/locale.t b/lib/locale.t index 57bc418ae8..8020eb8849 100644 --- a/lib/locale.t +++ b/lib/locale.t @@ -2543,7 +2543,9 @@ foreach $test_num ($first_locales_test_number..$final_locales_test_number) { $test_num = $final_locales_test_number; -unless ( $os =~ m!^(dragonfly|openbsd|bitrig|mirbsd)$! ) { +if ( $Config{d_setlocale_accepts_any_locale_name} eq 'false' + && $os !~ m!^(dragonfly|bitrig|mirbsd)$! ) +{ # perl #115808 use warnings; my $warned = 0; @@ -2551,7 +2553,7 @@ unless ( $os =~ m!^(dragonfly|openbsd|bitrig|mirbsd)$! ) { $warned = $_[0] =~ /uninitialized/; }; my $z = "y" . setlocale(&POSIX::LC_ALL, "xyzzy"); - ok($warned, "variable set to setlocale(BAD LOCALE) is considered uninitialized"); + ok($warned, "variable set to setlocale(\"invalid locale name\") is considered uninitialized"); } # Test that tainting and case changing works on utf8 strings. These tests are diff --git a/perl.h b/perl.h index dd66b120af..aea054437f 100644 --- a/perl.h +++ b/perl.h @@ -719,8 +719,25 @@ # include <xlocale.h> #endif -#if !defined(NO_LOCALE) && defined(HAS_SETLOCALE) +#if ! defined(NO_LOCALE) \ + && ! defined(NO_POSIX_2008_LOCALE) \ + && defined(HAS_NEWLOCALE) \ + && defined(LC_ALL_MASK) \ + && defined(HAS_FREELOCALE) + + /* For simplicity, the code is written to assume that any platform advanced + * enough to have the Posix 2008 locale functions has LC_ALL. The test + * above makes sure that assumption is valid */ + +# define HAS_POSIX_2008_LOCALE +# define USE_LOCALE +#endif + +#if ! defined(USE_LOCALE) && ! defined(NO_LOCALE) && defined(HAS_SETLOCALE) # define USE_LOCALE +#endif + +#ifdef USE_LOCALE # define HAS_SKIP_LOCALE_INIT /* Solely for XS code to test for this capability */ # if !defined(NO_LOCALE_COLLATE) && defined(LC_COLLATE) \ @@ -757,31 +774,19 @@ # if !defined(NO_LOCALE_TELEPHONE) && defined(LC_TELEPHONE) # define USE_LOCALE_TELEPHONE # endif -#endif /* !NO_LOCALE && HAS_SETLOCALE */ /* XXX The next few defines are unfortunately duplicated in makedef.pl, and - * changes here MUST also be made there */ + * changes here XXX MUST also be made there */ -#ifdef USE_LOCALE /* These locale things are all subject to change */ -# if defined(HAS_NEWLOCALE) \ - && defined(LC_ALL_MASK) \ - && defined(HAS_FREELOCALE) \ - && defined(HAS_USELOCALE) \ - && ! defined(NO_POSIX_2008_LOCALE) - - /* For simplicity, the code is written to assume that any platform advanced - * enough to have the Posix 2008 locale functions has LC_ALL. The test - * above makes sure that assumption is valid */ - -# define HAS_POSIX_2008_LOCALE -# endif +# if ! defined(HAS_SETLOCALE) && defined(HAS_POSIX_2008_LOCALE) +# define USE_POSIX_2008_LOCALE /* If compiled with * -DUSE_THREAD_SAFE_LOCALE, will do so even * on unthreaded builds */ -# if (defined(USE_ITHREADS) || defined(USE_THREAD_SAFE_LOCALE)) \ - && ( defined(HAS_POSIX_2008_LOCALE) \ - || (defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400)) \ - && ! defined(NO_THREAD_SAFE_LOCALE) +# elif (defined(USE_ITHREADS) || defined(USE_THREAD_SAFE_LOCALE)) \ + && ( defined(HAS_POSIX_2008_LOCALE) \ + || (defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400)) \ + && ! defined(NO_THREAD_SAFE_LOCALE) # ifndef USE_THREAD_SAFE_LOCALE # define USE_THREAD_SAFE_LOCALE # endif diff --git a/t/loc_tools.pl b/t/loc_tools.pl index 955cc90b1f..67d4783e94 100644 --- a/t/loc_tools.pl +++ b/t/loc_tools.pl @@ -331,6 +331,11 @@ sub find_locales ($;$) { _trylocale("C", $categories, \@Locale, $allow_incompatible); _trylocale("POSIX", $categories, \@Locale, $allow_incompatible); _trylocale("C.UTF-8", $categories, \@Locale, $allow_incompatible); + + # There's no point in looking at anything more if we know that setlocale + # will return success on any garbage or non-garbage name. + return sort @Locale if $Config{d_setlocale_accepts_any_locale_name} eq 'true'; + foreach (1..16) { _trylocale("ISO8859-$_", $categories, \@Locale, $allow_incompatible); _trylocale("iso8859$_", $categories, \@Locale, $allow_incompatible); diff --git a/t/run/locale.t b/t/run/locale.t index 0296c9af67..6fba22f868 100644 --- a/t/run/locale.t +++ b/t/run/locale.t @@ -68,7 +68,7 @@ EOF my $non_C_locale; foreach my $locale (@locales) { - next if $locale eq "C" || $locale eq 'POSIX'; + next if $locale eq "C" || $locale eq 'POSIX' || $locale eq "C.UTF-8"; $non_C_locale = $locale; last; } @@ -460,15 +460,15 @@ EOF } SKIP: { - # Note: a Configure probe could be written to give us the syntax to - # use, but khw doesn't think it's worth it. If the POSIX 2008 locale - # functions are being used, the syntax becomes mostly irrelevant, so - # do the test anyway if they are - # it's a lot of trouble to figure out in a perl script - if ($^O eq 'openbsd' && ( $Config{useithreads} ne 'define' - || ! ${^SAFE_LOCALES})) + # Note: the setlocale Configure probe could be enhanced to give us the + # syntax to use, but khw doesn't think it's worth it a this time, as + # the current outliers seem to be skipped by the test just below + # anyway. If the POSIX 2008 locale functions are being used, the + # syntax becomes mostly irrelevant, so do the test anyway if they are. + # It's a lot of trouble to figure out in a perl script. + if ($Config{d_setlocale_accepts_any_locale_name} eq 'true') { - skip("The setlocale() syntax used is invalid on this platform", 2); + skip("Can't distinguish between valid and invalid locale names on this system", 2); } my @valid_categories = valid_locale_categories(); -- Perl5 Master Repository
