In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/77ab507a50e98cdaad622ae961429fb3bc4c9c11?hp=c75442a5078b1a434861fbfa4b477a8ecce2558b>

- Log -----------------------------------------------------------------
commit 77ab507a50e98cdaad622ae961429fb3bc4c9c11
Author: Karl Williamson <[email protected]>
Date:   Tue Nov 29 11:28:52 2016 -0700

    lib/locale.t: Improve test when NUL isn't a control
    
    Commit 535a3fb3ec9051c531a7797f1de40cbfc39e3f7f changed lib/locale.t to
    not fail on locales that don't have NUL be a control.  It did this by
    skipping the failing test.  However, I realized later that there is a
    way to handle the situation without skipping a test, and that is to add
    NUL to the list of controls if it isn't already there.
-----------------------------------------------------------------------

Summary of changes:
 lib/locale.t | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/lib/locale.t b/lib/locale.t
index 2f3123d..b49197b 100644
--- a/lib/locale.t
+++ b/lib/locale.t
@@ -1797,25 +1797,36 @@ foreach my $Locale (@Locale) {
 
         use locale;
 
-        my @sorted_controls = sort @{$posixes{'cntrl'}};
-        my $output = "";
-        for my $control (@sorted_controls) {
-            $output .= " " . disp_chars($control);
-        }
-        debug "sorted :cntrl: = $output\n";
+        my @sorted_controls;
 
         ++$locales_test_number;
         $test_names{$locales_test_number}
-                = 'Skip in locales where \0 is not considered a control;'
-                . ' otherwise verify that \0 sorts before any other control';
-        if ("\0" !~ /[[:cntrl:]]/) {
+                = 'Skip in locales where there are no controls;'
+                . ' otherwise verify that \0 sorts before any (other) control';
+        if (! $posixes{'cntrl'}) {
             report_result($Locale, $locales_test_number, 1);
+
+            # We use all code points for the tests below since there aren't
+            # any controls
+            push @sorted_controls, chr $_ for 1..255;
+            @sorted_controls = sort @sorted_controls;
         }
         else {
+            @sorted_controls = @{$posixes{'cntrl'}};
+            push @sorted_controls, "\0",
+                                unless grep { $_ eq "\0" } @sorted_controls;
+            @sorted_controls = sort @sorted_controls;
+            my $output = "";
+            for my $control (@sorted_controls) {
+                $output .= " " . disp_chars($control);
+            }
+            debug "sorted :cntrl: (plus NUL) = $output\n";
             my $ok = $sorted_controls[0] eq "\0";
             report_result($Locale, $locales_test_number, $ok);
-            shift @sorted_controls;
+
+            shift @sorted_controls if $ok;
         }
+
         my $lowest_control = $sorted_controls[0];
 
         ++$locales_test_number;

--
Perl5 Master Repository

Reply via email to