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