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