Re: [ID 20001125.004] OK: perl v5.7.0 +DEVEL7825 on i686-linux 2.2.17 (UNINSTALLED)
[p5sagit/p5-mst-13.2.git] / t / pragma / locale.t
1 #!./perl -wT
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     unshift @INC, '.';
7     require Config; import Config;
8     if (!$Config{d_setlocale} || $Config{ccflags} =~ /\bD?NO_LOCALE\b/) {
9         print "1..0\n";
10         exit;
11     }
12 }
13
14 use strict;
15
16 my $debug = 1;
17
18 sub debug {
19     print @_ if $debug;
20 }
21
22 sub debugf {
23     printf @_ if $debug;
24 }
25
26 my $have_setlocale = 0;
27 eval {
28     require POSIX;
29     import POSIX ':locale_h';
30     $have_setlocale++;
31 };
32
33 # Visual C's CRT goes silly on strings of the form "en_US.ISO8859-1"
34 # and mingw32 uses said silly CRT
35 $have_setlocale = 0 if $^O eq 'MSWin32' && $Config{cc} =~ /^(cl|gcc)/i;
36
37 my $last = $have_setlocale ? 116 : 98;
38
39 print "1..$last\n";
40
41 use vars qw(&LC_ALL);
42
43 my $a = 'abc %';
44
45 sub ok {
46     my ($n, $result) = @_;
47
48     print 'not ' unless ($result);
49     print "ok $n\n";
50 }
51
52 # First we'll do a lot of taint checking for locales.
53 # This is the easiest to test, actually, as any locale,
54 # even the default locale will taint under 'use locale'.
55
56 sub is_tainted { # hello, camel two.
57     no warnings 'uninitialized' ;
58     my $dummy;
59     not eval { $dummy = join("", @_), kill 0; 1 }
60 }
61
62 sub check_taint ($$) {
63     ok $_[0], is_tainted($_[1]);
64 }
65
66 sub check_taint_not ($$) {
67     ok $_[0], not is_tainted($_[1]);
68 }
69
70 use locale;     # engage locale and therefore locale taint.
71
72 check_taint_not   1, $a;
73
74 check_taint       2, uc($a);
75 check_taint       3, "\U$a";
76 check_taint       4, ucfirst($a);
77 check_taint       5, "\u$a";
78 check_taint       6, lc($a);
79 check_taint       7, "\L$a";
80 check_taint       8, lcfirst($a);
81 check_taint       9, "\l$a";
82
83 check_taint      10, sprintf('%e', 123.456);
84 check_taint      11, sprintf('%f', 123.456);
85 check_taint      12, sprintf('%g', 123.456);
86 check_taint_not  13, sprintf('%d', 123.456);
87 check_taint_not  14, sprintf('%x', 123.456);
88
89 $_ = $a;        # untaint $_
90
91 $_ = uc($a);    # taint $_
92
93 check_taint      15, $_;
94
95 /(\w)/; # taint $&, $`, $', $+, $1.
96 check_taint      16, $&;
97 check_taint      17, $`;
98 check_taint      18, $';
99 check_taint      19, $+;
100 check_taint      20, $1;
101 check_taint_not  21, $2;
102
103 /(.)/;  # untaint $&, $`, $', $+, $1.
104 check_taint_not  22, $&;
105 check_taint_not  23, $`;
106 check_taint_not  24, $';
107 check_taint_not  25, $+;
108 check_taint_not  26, $1;
109 check_taint_not  27, $2;
110
111 /(\W)/; # taint $&, $`, $', $+, $1.
112 check_taint      28, $&;
113 check_taint      29, $`;
114 check_taint      30, $';
115 check_taint      31, $+;
116 check_taint      32, $1;
117 check_taint_not  33, $2;
118
119 /(\s)/; # taint $&, $`, $', $+, $1.
120 check_taint      34, $&;
121 check_taint      35, $`;
122 check_taint      36, $';
123 check_taint      37, $+;
124 check_taint      38, $1;
125 check_taint_not  39, $2;
126
127 /(\S)/; # taint $&, $`, $', $+, $1.
128 check_taint      40, $&;
129 check_taint      41, $`;
130 check_taint      42, $';
131 check_taint      43, $+;
132 check_taint      44, $1;
133 check_taint_not  45, $2;
134
135 $_ = $a;        # untaint $_
136
137 check_taint_not  46, $_;
138
139 /(b)/;          # this must not taint
140 check_taint_not  47, $&;
141 check_taint_not  48, $`;
142 check_taint_not  49, $';
143 check_taint_not  50, $+;
144 check_taint_not  51, $1;
145 check_taint_not  52, $2;
146
147 $_ = $a;        # untaint $_
148
149 check_taint_not  53, $_;
150
151 $b = uc($a);    # taint $b
152 s/(.+)/$b/;     # this must taint only the $_
153
154 check_taint      54, $_;
155 check_taint_not  55, $&;
156 check_taint_not  56, $`;
157 check_taint_not  57, $';
158 check_taint_not  58, $+;
159 check_taint_not  59, $1;
160 check_taint_not  60, $2;
161
162 $_ = $a;        # untaint $_
163
164 s/(.+)/b/;      # this must not taint
165 check_taint_not  61, $_;
166 check_taint_not  62, $&;
167 check_taint_not  63, $`;
168 check_taint_not  64, $';
169 check_taint_not  65, $+;
170 check_taint_not  66, $1;
171 check_taint_not  67, $2;
172
173 $b = $a;        # untaint $b
174
175 ($b = $a) =~ s/\w/$&/;
176 check_taint      68, $b;        # $b should be tainted.
177 check_taint_not  69, $a;        # $a should be not.
178
179 $_ = $a;        # untaint $_
180
181 s/(\w)/\l$1/;   # this must taint
182 check_taint      70, $_;
183 check_taint      71, $&;
184 check_taint      72, $`;
185 check_taint      73, $';
186 check_taint      74, $+;
187 check_taint      75, $1;
188 check_taint_not  76, $2;
189
190 $_ = $a;        # untaint $_
191
192 s/(\w)/\L$1/;   # this must taint
193 check_taint      77, $_;
194 check_taint      78, $&;
195 check_taint      79, $`;
196 check_taint      80, $';
197 check_taint      81, $+;
198 check_taint      82, $1;
199 check_taint_not  83, $2;
200
201 $_ = $a;        # untaint $_
202
203 s/(\w)/\u$1/;   # this must taint
204 check_taint      84, $_;
205 check_taint      85, $&;
206 check_taint      86, $`;
207 check_taint      87, $';
208 check_taint      88, $+;
209 check_taint      89, $1;
210 check_taint_not  90, $2;
211
212 $_ = $a;        # untaint $_
213
214 s/(\w)/\U$1/;   # this must taint
215 check_taint      91, $_;
216 check_taint      92, $&;
217 check_taint      93, $`;
218 check_taint      94, $';
219 check_taint      95, $+;
220 check_taint      96, $1;
221 check_taint_not  97, $2;
222
223 # After all this tainting $a should be cool.
224
225 check_taint_not  98, $a;
226
227 # I think we've seen quite enough of taint.
228 # Let us do some *real* locale work now,
229 # unless setlocale() is missing (i.e. minitest).
230
231 exit unless $have_setlocale;
232
233 # Find locales.
234
235 debug "# Scanning for locales...\n";
236
237 # Note that it's okay that some languages have their native names
238 # capitalized here even though that's not "right".  They are lowercased
239 # anyway later during the scanning process (and besides, some clueless
240 # vendor might have them capitalized errorneously anyway).
241
242 my $locales = <<EOF;
243 Afrikaans:af:za:1 15
244 Arabic:ar:dz eg sa:6 arabic8
245 Brezhoneg Breton:br:fr:1 15
246 Bulgarski Bulgarian:bg:bg:5
247 Chinese:zh:cn tw:cn.EUC eucCN eucTW euc.CN euc.TW Big5 GB2312 tw.EUC
248 Hrvatski Croatian:hr:hr:2
249 Cymraeg Welsh:cy:cy:1 14 15
250 Czech:cs:cz:2
251 Dansk Danish:dk:da:1 15
252 Nederlands Dutch:nl:be nl:1 15
253 English American British:en:au ca gb ie nz us uk zw:1 15 cp850
254 Esperanto:eo:eo:3
255 Eesti Estonian:et:ee:4 6 13
256 Suomi Finnish:fi:fi:1 15
257 Flamish::fl:1 15
258 Deutsch German:de:at be ch de lu:1 15
259 Euskaraz Basque:eu:es fr:1 15
260 Galego Galician:gl:es:1 15
261 Ellada Greek:el:gr:7 g8
262 Frysk:fy:nl:1 15
263 Greenlandic:kl:gl:4 6
264 Hebrew:iw:il:8 hebrew8
265 Hungarian:hu:hu:2
266 Indonesian:in:id:1 15
267 Gaeilge Irish:ga:IE:1 14 15
268 Italiano Italian:it:ch it:1 15
269 Nihongo Japanese:ja:jp:euc eucJP jp.EUC sjis
270 Korean:ko:kr:
271 Latine Latin:la:va:1 15
272 Latvian:lv:lv:4 6 13
273 Lithuanian:lt:lt:4 6 13
274 Macedonian:mk:mk:1 15
275 Maltese:mt:mt:3
276 Moldovan:mo:mo:2
277 Norsk Norwegian:no no\@nynorsk:no:1 15
278 Occitan:oc:es:1 15
279 Polski Polish:pl:pl:2
280 Rumanian:ro:ro:2
281 Russki Russian:ru:ru su ua:5 koi8 koi8r KOI8-R koi8u cp1251 cp866
282 Serbski Serbian:sr:yu:5
283 Slovak:sk:sk:2
284 Slovene Slovenian:sl:si:2
285 Sqhip Albanian:sq:sq:1 15
286 Svenska Swedish:sv:fi se:1 15
287 Thai:th:th:11 tis620
288 Turkish:tr:tr:9 turkish8
289 Yiddish:yi::1 15
290 EOF
291
292 if ($^O eq 'os390') {
293     # These cause heartburn.  Broken locales?
294     $locales =~ s/Svenska Swedish:sv:fi se:1 15\n//;
295     $locales =~ s/Thai:th:th:11 tis620\n//;
296 }
297
298 sub in_utf8 () { $^H & 0x08 }
299
300 if (in_utf8) {
301     require "pragma/locale/utf8";
302 } else {
303     require "pragma/locale/latin1";
304 }
305
306 my @Locale;
307 my $Locale;
308 my @Alnum_;
309
310 sub getalnum_ {
311     sort grep /\w/, map { chr } 0..255
312 }
313
314 sub trylocale {
315     my $locale = shift;
316     if (setlocale(LC_ALL, $locale)) {
317         push @Locale, $locale;
318     }
319 }
320
321 sub decode_encodings {
322     my @enc;
323
324     foreach (split(/ /, shift)) {
325         if (/^(\d+)$/) {
326             push @enc, "ISO8859-$1";
327             push @enc, "iso8859$1";     # HP
328             if ($1 eq '1') {
329                  push @enc, "roman8";   # HP
330             }
331         } else {
332             push @enc, $_;
333             push @enc, "$_.UTF-8";
334         }
335     }
336     if ($^O eq 'os390') {
337         push @enc, qw(IBM-037 IBM-819 IBM-1047);
338     }
339
340     return @enc;
341 }
342
343 trylocale("C");
344 trylocale("POSIX");
345 foreach (0..15) {
346     trylocale("ISO8859-$_");
347     trylocale("iso8859$_");
348     trylocale("iso8859-$_");
349     trylocale("iso_8859_$_");
350     trylocale("isolatin$_");
351     trylocale("isolatin-$_");
352     trylocale("iso_latin_$_");
353 }
354
355 # Sanitize the environment so that we can run the external 'locale'
356 # program without the taint mode getting grumpy.
357
358 # $ENV{PATH} is special in VMS.
359 delete $ENV{PATH} if $^O ne 'VMS' or $Config{d_setenv};
360
361 # Other subversive stuff.
362 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
363
364 if (-x "/usr/bin/locale" && open(LOCALES, "/usr/bin/locale -a 2>/dev/null|")) {
365     while (<LOCALES>) {
366         chomp;
367         trylocale($_);
368     }
369     close(LOCALES);
370 } elsif ($^O eq 'VMS' && defined($ENV{'SYS$I18N_LOCALE'}) && -d 'SYS$I18N_LOCALE') {
371 # The SYS$I18N_LOCALE logical name search list was not present on 
372 # VAX VMS V5.5-12, but was on AXP && VAX VMS V6.2 as well as later versions.
373     opendir(LOCALES, "SYS\$I18N_LOCALE:");
374     while ($_ = readdir(LOCALES)) {
375         chomp;
376         trylocale($_);
377     }
378     close(LOCALES);
379 } else {
380
381     # This is going to be slow.
382
383     foreach my $locale (split(/\n/, $locales)) {
384         my ($locale_name, $language_codes, $country_codes, $encodings) =
385             split(/:/, $locale);
386         my @enc = decode_encodings($encodings);
387         foreach my $loc (split(/ /, $locale_name)) {
388             trylocale($loc);
389             foreach my $enc (@enc) {
390                 trylocale("$loc.$enc");
391             }
392             $loc = lc $loc;
393             foreach my $enc (@enc) {
394                 trylocale("$loc.$enc");
395             }
396         }
397         foreach my $lang (split(/ /, $language_codes)) {
398             trylocale($lang);
399             foreach my $country (split(/ /, $country_codes)) {
400                 my $lc = "${lang}_${country}";
401                 trylocale($lc);
402                 foreach my $enc (@enc) {
403                     trylocale("$lc.$enc");
404                 }
405                 my $lC = "${lang}_\U${country}";
406                 trylocale($lC);
407                 foreach my $enc (@enc) {
408                     trylocale("$lC.$enc");
409                 }
410             }
411         }
412     }
413 }
414
415 setlocale(LC_ALL, "C");
416
417 sub utf8locale { $_[0] =~ /utf-?8/i }
418
419 @Locale = sort @Locale;
420
421 debug "# Locales = @Locale\n";
422
423 my %Problem;
424 my %Okay;
425 my %Testing;
426 my @Neoalpha;
427 my %Neoalpha;
428
429 sub tryneoalpha {
430     my ($Locale, $i, $test) = @_;
431     debug "# testing $i with locale '$Locale'\n"
432         unless $Testing{$i}{$Locale}++;
433     unless ($test) {
434         $Problem{$i}{$Locale} = 1;
435         debug "# failed $i with locale '$Locale'\n";
436     } else {
437         push @{$Okay{$i}}, $Locale;
438     }
439 }
440
441 foreach $Locale (@Locale) {
442     debug "# Locale = $Locale\n";
443     @Alnum_ = getalnum_();
444     debug "# \\w = @Alnum_\n";
445
446     unless (setlocale(LC_ALL, $Locale)) {
447         foreach (99..103) {
448             $Problem{$_}{$Locale} = -1;
449         }
450         next;
451     }
452
453     # Sieve the uppercase and the lowercase.
454     
455     my %UPPER = ();
456     my %lower = ();
457     my %BoThCaSe = ();
458     for (@Alnum_) {
459         if (/[^\d_]/) { # skip digits and the _
460             if (uc($_) eq $_) {
461                 $UPPER{$_} = $_;
462             }
463             if (lc($_) eq $_) {
464                 $lower{$_} = $_;
465             }
466         }
467     }
468     foreach (keys %UPPER) {
469         $BoThCaSe{$_}++ if exists $lower{$_};
470     }
471     foreach (keys %lower) {
472         $BoThCaSe{$_}++ if exists $UPPER{$_};
473     }
474     foreach (keys %BoThCaSe) {
475         delete $UPPER{$_};
476         delete $lower{$_};
477     }
478
479     debug "# UPPER    = ", join(" ", sort keys %UPPER   ), "\n";
480     debug "# lower    = ", join(" ", sort keys %lower   ), "\n";
481     debug "# BoThCaSe = ", join(" ", sort keys %BoThCaSe), "\n";
482
483     # Find the alphabets that are not alphabets in the default locale.
484
485     {
486         no locale;
487     
488         @Neoalpha = ();
489         for (keys %UPPER, keys %lower) {
490             push(@Neoalpha, $_) if (/\W/);
491             $Neoalpha{$_} = $_;
492         }
493     }
494
495     @Neoalpha = sort @Neoalpha;
496
497     debug "# Neoalpha = @Neoalpha\n";
498
499     if (@Neoalpha == 0) {
500         # If we have no Neoalphas the remaining tests are no-ops.
501         debug "# no Neoalpha, skipping tests 99..102 for locale '$Locale'\n";
502         foreach (99..102) {
503             push @{$Okay{$_}}, $Locale;
504         }
505     } else {
506
507         # Test \w.
508     
509         if (utf8locale($Locale)) {
510             # Until the polymorphic regexen arrive.
511             debug "# skipping UTF-8 locale '$Locale'\n";
512         } else {
513             my $word = join('', @Neoalpha);
514
515             $word =~ /^(\w+)$/;
516
517             tryneoalpha($Locale, 99, $1 eq $word);
518         }
519
520         # Cross-check the whole 8-bit character set.
521
522         for (map { chr } 0..255) {
523             tryneoalpha($Locale, 100,
524                         (/\w/ xor /\W/) ||
525                         (/\d/ xor /\D/) ||
526                         (/\s/ xor /\S/));
527         }
528
529         # Test for read-only scalars' locale vs non-locale comparisons.
530
531         {
532             no locale;
533             $a = "qwerty";
534             {
535                 use locale;
536                 tryneoalpha($Locale, 101, ($a cmp "qwerty") == 0);
537             }
538         }
539
540         {
541             my ($from, $to, $lesser, $greater,
542                 @test, %test, $test, $yes, $no, $sign);
543
544             for (0..9) {
545                 # Select a slice.
546                 $from = int(($_*@Alnum_)/10);
547                 $to = $from + int(@Alnum_/10);
548                 $to = $#Alnum_ if ($to > $#Alnum_);
549                 $lesser  = join('', @Alnum_[$from..$to]);
550                 # Select a slice one character on.
551                 $from++; $to++;
552                 $to = $#Alnum_ if ($to > $#Alnum_);
553                 $greater = join('', @Alnum_[$from..$to]);
554                 ($yes, $no, $sign) = ($lesser lt $greater
555                                       ? ("    ", "not ", 1)
556                                       : ("not ", "    ", -1));
557                 # all these tests should FAIL (return 0).
558                 # Exact lt or gt cannot be tested because
559                 # in some locales, say, eacute and E may test equal.
560                 @test = 
561                     (
562                      $no.'    ($lesser  le $greater)',  # 1
563                      'not      ($lesser  ne $greater)', # 2
564                      '         ($lesser  eq $greater)', # 3
565                      $yes.'    ($lesser  ge $greater)', # 4
566                      $yes.'    ($lesser  ge $greater)', # 5
567                      $yes.'    ($greater le $lesser )', # 7
568                      'not      ($greater ne $lesser )', # 8
569                      '         ($greater eq $lesser )', # 9
570                      $no.'     ($greater ge $lesser )', # 10
571                      'not (($lesser cmp $greater) == -$sign)' # 12
572                      );
573                 @test{@test} = 0 x @test;
574                 $test = 0;
575                 for my $ti (@test) {
576                     $test{$ti} = eval $ti;
577                     $test ||= $test{$ti}
578                 }
579                 tryneoalpha($Locale, 102, $test == 0);
580                 if ($test) {
581                     debug "# lesser  = '$lesser'\n";
582                     debug "# greater = '$greater'\n";
583                     debug "# lesser cmp greater = ",
584                           $lesser cmp $greater, "\n";
585                     debug "# greater cmp lesser = ",
586                           $greater cmp $lesser, "\n";
587                     debug "# (greater) from = $from, to = $to\n";
588                     for my $ti (@test) {
589                         debugf("# %-40s %-4s", $ti,
590                                $test{$ti} ? 'FAIL' : 'ok');
591                         if ($ti =~ /\(\.*(\$.+ +cmp +\$[^\)]+)\.*\)/) {
592                             debugf("(%s == %4d)", $1, eval $1);
593                         }
594                         debug "\n#";
595                     }
596
597                     last;
598                 }
599             }
600         }
601     }
602
603     use locale;
604
605     my ($x, $y) = (1.23, 1.23);
606
607     my $a = "$x";
608     printf ''; # printf used to reset locale to "C"
609     my $b = "$y";
610
611     debug "# 103..107: a = $a, b = $b, Locale = $Locale\n";
612
613     tryneoalpha($Locale, 103, $a eq $b);
614
615     my $c = "$x";
616     my $z = sprintf ''; # sprintf used to reset locale to "C"
617     my $d = "$y";
618
619     debug "# 104..107: c = $c, d = $d, Locale = $Locale\n";
620
621     tryneoalpha($Locale, 104, $c eq $d); 
622
623     {
624         use warnings;
625         my $w = 0;
626         local $SIG{__WARN__} = sub { $w++ };
627
628         # the == (among other ops) used to warn for locales
629         # that had something else than "." as the radix character
630
631         tryneoalpha($Locale, 105, $c == 1.23);
632
633         tryneoalpha($Locale, 106, $c == $x);
634
635         tryneoalpha($Locale, 107, $c == $d);
636
637         {
638             no locale;
639         
640             my $e = "$x";
641
642             debug "# 108..110: e = $e, Locale = $Locale\n";
643
644             tryneoalpha($Locale, 108, $e == 1.23);
645
646             tryneoalpha($Locale, 109, $e == $x);
647             
648             tryneoalpha($Locale, 110, $e == $c);
649         }
650         
651         tryneoalpha($Locale, 111, $w == 0);
652
653         my $f = "1.23";
654
655         debug "# 112..114: f = $f, locale = $Locale\n";
656
657         tryneoalpha($Locale, 112, $f == 1.23);
658
659         tryneoalpha($Locale, 113, $f == $x);
660         
661         tryneoalpha($Locale, 114, $f == $c);
662     }
663
664     debug "# testing 115 with locale '$Locale'\n";
665     # Does taking lc separately differ from taking
666     # the lc "in-line"?  (This was the bug 19990704.002, change #3568.)
667     # The bug was in the caching of the 'o'-magic.
668     {
669         use locale;
670
671         sub lcA {
672             my $lc0 = lc $_[0];
673             my $lc1 = lc $_[1];
674             return $lc0 cmp $lc1;
675         }
676
677         sub lcB {
678             return lc($_[0]) cmp lc($_[1]);
679         }
680
681         my $x = "ab";
682         my $y = "aa";
683         my $z = "AB";
684
685         tryneoalpha($Locale, 115,
686                     lcA($x, $y) == 1 && lcB($x, $y) == 1 ||
687                     lcA($x, $z) == 0 && lcB($x, $z) == 0);
688     }
689
690     debug "# testing 116 with locale '$Locale'\n";
691     # Does lc of an UPPER (if different from the UPPER) match
692     # case-insensitively the UPPER, and does the UPPER match
693     # case-insensitively the lc of the UPPER.  And vice versa.
694     if (utf8locale($Locale)) {
695         # Until the polymorphic regexen arrive.
696         debug "# skipping UTF-8 locale '$Locale'\n";
697     } else {
698         use locale;
699
700         my @f = ();
701         foreach my $x (keys %UPPER) {
702             my $y = lc $x;
703             next unless uc $y eq $x;
704             push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
705         }
706         foreach my $x (keys %lower) {
707             my $y = uc $x;
708             next unless lc $y eq $x;
709             push @f, $x unless $x =~ /$y/i && $y =~ /$x/i;
710         }
711         tryneoalpha($Locale, 116, @f == 0);
712         if (@f) {
713             print "# failed 116 locale '$Locale' characters @f\n"
714         }
715     }
716
717 }
718
719 # Recount the errors.
720
721 foreach (99..$last) {
722     if ($Problem{$_} || !defined $Okay{$_} || !@{$Okay{$_}}) {
723         if ($_ == 102) {
724             print "# The failure of test 102 is not necessarily fatal.\n";
725             print "# It usually indicates a problem in the enviroment,\n";
726             print "# not in Perl itself.\n";
727         }
728         print "not ";
729     }
730     print "ok $_\n";
731 }
732
733 # Give final advice.
734
735 my $didwarn = 0;
736
737 foreach (99..$last) {
738     if ($Problem{$_}) {
739         my @f = sort keys %{ $Problem{$_} };
740         my $f = join(" ", @f);
741         $f =~ s/(.{50,60}) /$1\n#\t/g;
742         print
743             "#\n",
744             "# The locale ", (@f == 1 ? "definition" : "definitions"), "\n#\n",
745             "#\t", $f, "\n#\n",
746             "# on your system may have errors because the locale test $_\n",
747             "# failed in ", (@f == 1 ? "that locale" : "those locales"),
748             ".\n";
749         print <<EOW;
750 #
751 # If your users are not using these locales you are safe for the moment,
752 # but please report this failure first to perlbug\@perl.com using the
753 # perlbug script (as described in the INSTALL file) so that the exact
754 # details of the failures can be sorted out first and then your operating
755 # system supplier can be alerted about these anomalies.
756 #
757 EOW
758         $didwarn = 1;
759     }
760 }
761
762 # Tell which locales were okay and which were not.
763
764 if ($didwarn) {
765     my (@s, @F);
766     
767     foreach my $l (@Locale) {
768         my $p = 0;
769         foreach my $t (102..$last) {
770             $p++ if $Problem{$t}{$l};
771         }
772         push @s, $l if $p == 0;
773       push @F, $l unless $p == 0;
774     }
775     
776     if (@s) {
777         my $s = join(" ", @s);
778         $s =~ s/(.{50,60}) /$1\n#\t/g;
779
780         warn
781             "# The following locales\n#\n",
782             "#\t", $s, "\n#\n",
783             "# tested okay.\n#\n",
784     } else {
785         warn "# None of your locales were fully okay.\n";
786     }
787
788     if (@F) {
789         my $F = join(" ", @F);
790         $F =~ s/(.{50,60}) /$1\n#\t/g;
791
792         warn
793           "# The following locales\n#\n",
794             "#\t", $F, "\n#\n",
795           "# had problems.\n#\n",
796     } else {
797         warn "# None of your locales were broken.\n";
798     }
799 }
800
801 # eof