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