2 # Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
4 # Contributed by Bruno Haible <haible@clisp.cons.org>, 2000.
7 # The GNU C Library is free software; you can redistribute it and/or
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.
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
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with the GNU C Library; if not, write to the Free
19 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 # Checks that the iconv() implementation (in both directions) for a
23 # stateless encoding agrees with the charmap table.
27 cross_test_wrapper="$3"
31 GCONV_PATH=${common_objpfx}iconvdata
39 ${SHELL} tst-table-charmap.sh ${charmap:-$charset} \
40 < ../localedata/charmaps/${charmap:-$charset} \
41 > ${objpfx}tst-${charset}.charmap.table
42 # When the charset is GB18030, truncate this table because for this encoding,
43 # the tst-table-from and tst-table-to programs scan the Unicode BMP only.
44 if test ${charset} = GB18030; then
45 grep '0x....$' < ${objpfx}tst-${charset}.charmap.table \
46 > ${objpfx}tst-${charset}.truncated.table
47 mv ${objpfx}tst-${charset}.truncated.table ${objpfx}tst-${charset}.charmap.table
50 # Precomputed expexted differences between the charmap and iconv forward.
51 precomposed=${charset}.precomposed
53 # Precompute expected differences between the charmap and iconv backward.
54 if test ${charset} = EUC-TW; then
55 irreversible=${objpfx}tst-${charset}.irreversible
56 (grep '^0x8EA1' ${objpfx}tst-${charset}.charmap.table
57 cat ${charset}.irreversible
60 irreversible=${charset}.irreversible
63 # iconv in one direction.
64 ${cross_test_wrapper} ${common_objpfx}elf/ld.so --library-path $common_objpfx \
65 ${objpfx}tst-table-from ${charset} \
66 > ${objpfx}tst-${charset}.table
68 # iconv in the other direction.
69 ${cross_test_wrapper} ${common_objpfx}elf/ld.so --library-path $common_objpfx \
70 ${objpfx}tst-table-to ${charset} | sort \
71 > ${objpfx}tst-${charset}.inverse.table
73 # Difference between the charmap and iconv backward.
74 diff ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table | \
75 grep '^[<>]' | sed -e 's,^. ,,' > ${objpfx}tst-${charset}.irreversible.table
77 # Check 1: charmap and iconv forward should be identical, except for
78 # precomposed characters.
79 if test -f ${precomposed}; then
80 cat ${objpfx}tst-${charset}.table ${precomposed} | sort | uniq -u \
81 > ${objpfx}tst-${charset}.tmp.table
82 cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.tmp.table ||
85 cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table ||
89 # Check 2: the difference between the charmap and iconv backward.
90 if test -f ${irreversible}; then
91 cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u \
92 > ${objpfx}tst-${charset}.tmp.table
93 cmp -s ${objpfx}tst-${charset}.tmp.table ${objpfx}tst-${charset}.inverse.table ||
96 cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table ||