]>
Commit | Line | Data |
---|---|---|
b79f74cd | 1 | #!/bin/sh |
568035b7 | 2 | # Copyright (C) 2000-2013 Free Software Foundation, Inc. |
b79f74cd UD |
3 | # This file is part of the GNU C Library. |
4 | # Contributed by Bruno Haible <haible@clisp.cons.org>, 2000. | |
5 | # | |
41bdb6e2 | 6 | |
b79f74cd | 7 | # The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
8 | # modify it under the terms of the GNU Lesser General Public |
9 | # License as published by the Free Software Foundation; either | |
10 | # version 2.1 of the License, or (at your option) any later version. | |
11 | ||
b79f74cd UD |
12 | # The GNU C Library is distributed in the hope that it will be useful, |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 AJ |
15 | # Lesser General Public License for more details. |
16 | ||
17 | # You should have received a copy of the GNU Lesser General Public | |
59ba27a6 PE |
18 | # License along with the GNU C Library; if not, see |
19 | # <http://www.gnu.org/licenses/>. | |
b79f74cd UD |
20 | |
21 | # Checks that the iconv() implementation (in both directions) for a | |
22 | # stateless encoding agrees with the charmap table. | |
23 | ||
24 | common_objpfx=$1 | |
25 | objpfx=$2 | |
740b3dbe | 26 | test_program_prefix=$3 |
e40a0d21 JM |
27 | charset=$4 |
28 | charmap=$5 | |
b79f74cd UD |
29 | |
30 | GCONV_PATH=${common_objpfx}iconvdata | |
31 | export GCONV_PATH | |
32 | LC_ALL=C | |
33 | export LC_ALL | |
34 | ||
35 | set -e | |
36 | ||
37 | # Get the charmap. | |
54399c08 | 38 | ./tst-table-charmap.sh ${charmap:-$charset} \ |
b79f74cd UD |
39 | < ../localedata/charmaps/${charmap:-$charset} \ |
40 | > ${objpfx}tst-${charset}.charmap.table | |
be479a6d UD |
41 | # When the charset is GB18030, truncate this table because for this encoding, |
42 | # the tst-table-from and tst-table-to programs scan the Unicode BMP only. | |
43 | if test ${charset} = GB18030; then | |
44 | grep '0x....$' < ${objpfx}tst-${charset}.charmap.table \ | |
45 | > ${objpfx}tst-${charset}.truncated.table | |
46 | mv ${objpfx}tst-${charset}.truncated.table ${objpfx}tst-${charset}.charmap.table | |
47 | fi | |
b79f74cd | 48 | |
9813858f UD |
49 | # Precomputed expexted differences between the charmap and iconv forward. |
50 | precomposed=${charset}.precomposed | |
51 | ||
52 | # Precompute expected differences between the charmap and iconv backward. | |
b79f74cd UD |
53 | if test ${charset} = EUC-TW; then |
54 | irreversible=${objpfx}tst-${charset}.irreversible | |
289ac9dd UD |
55 | (grep '^0x8EA1' ${objpfx}tst-${charset}.charmap.table |
56 | cat ${charset}.irreversible | |
57 | ) > ${irreversible} | |
b79f74cd UD |
58 | else |
59 | irreversible=${charset}.irreversible | |
60 | fi | |
61 | ||
62 | # iconv in one direction. | |
740b3dbe | 63 | ${test_program_prefix} \ |
b79f74cd UD |
64 | ${objpfx}tst-table-from ${charset} \ |
65 | > ${objpfx}tst-${charset}.table | |
66 | ||
67 | # iconv in the other direction. | |
740b3dbe | 68 | ${test_program_prefix} \ |
b79f74cd UD |
69 | ${objpfx}tst-table-to ${charset} | sort \ |
70 | > ${objpfx}tst-${charset}.inverse.table | |
71 | ||
9813858f UD |
72 | # Difference between the charmap and iconv backward. |
73 | diff ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table | \ | |
b79f74cd UD |
74 | grep '^[<>]' | sed -e 's,^. ,,' > ${objpfx}tst-${charset}.irreversible.table |
75 | ||
9813858f UD |
76 | # Check 1: charmap and iconv forward should be identical, except for |
77 | # precomposed characters. | |
be479a6d UD |
78 | if test -f ${precomposed}; then |
79 | cat ${objpfx}tst-${charset}.table ${precomposed} | sort | uniq -u \ | |
80 | > ${objpfx}tst-${charset}.tmp.table | |
81 | cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.tmp.table || | |
601d2942 UD |
82 | exit 1 |
83 | else | |
be479a6d UD |
84 | cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table || |
85 | exit 1 | |
601d2942 | 86 | fi |
b79f74cd | 87 | |
9813858f | 88 | # Check 2: the difference between the charmap and iconv backward. |
b79f74cd UD |
89 | if test -f ${irreversible}; then |
90 | cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u \ | |
91 | > ${objpfx}tst-${charset}.tmp.table | |
63e18f77 UD |
92 | cmp -s ${objpfx}tst-${charset}.tmp.table ${objpfx}tst-${charset}.inverse.table || |
93 | exit 1 | |
b79f74cd | 94 | else |
9813858f | 95 | cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table || |
63e18f77 | 96 | exit 1 |
b79f74cd UD |
97 | fi |
98 | ||
99 | exit 0 |