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