]>
Commit | Line | Data |
---|---|---|
b79f74cd | 1 | #!/bin/sh |
601d2942 | 2 | # Copyright (C) 2000, 2001 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 | # | |
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Library General Public License as | |
8 | # published by the Free Software Foundation; either version 2 of the | |
9 | # License, or (at your option) any later version. | |
10 | # | |
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Library General Public License for more details. | |
15 | # | |
16 | # You should have received a copy of the GNU Library General Public | |
17 | # License along with the GNU C Library; see the file COPYING.LIB. If not, | |
18 | # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 | # Boston, MA 02111-1307, USA. | |
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 | |
26 | charset=$3 | |
27 | charmap=$4 | |
28 | ||
29 | GCONV_PATH=${common_objpfx}iconvdata | |
30 | export GCONV_PATH | |
31 | LC_ALL=C | |
32 | export LC_ALL | |
33 | ||
34 | set -e | |
35 | ||
36 | # Get the charmap. | |
58b668a5 | 37 | ${SHELL} tst-table-charmap.sh ${charmap:-$charset} \ |
b79f74cd UD |
38 | < ../localedata/charmaps/${charmap:-$charset} \ |
39 | > ${objpfx}tst-${charset}.charmap.table | |
40 | ||
41 | # Precompute expected differences between the two iconv directions. | |
42 | if test ${charset} = EUC-TW; then | |
43 | irreversible=${objpfx}tst-${charset}.irreversible | |
44 | grep '^0x8EA1' ${objpfx}tst-${charset}.charmap.table > ${irreversible} | |
45 | else | |
46 | irreversible=${charset}.irreversible | |
47 | fi | |
48 | ||
49 | # iconv in one direction. | |
50 | ${common_objpfx}elf/ld.so --library-path $common_objpfx \ | |
51 | ${objpfx}tst-table-from ${charset} \ | |
52 | > ${objpfx}tst-${charset}.table | |
53 | ||
54 | # iconv in the other direction. | |
55 | ${common_objpfx}elf/ld.so --library-path $common_objpfx \ | |
56 | ${objpfx}tst-table-to ${charset} | sort \ | |
57 | > ${objpfx}tst-${charset}.inverse.table | |
58 | ||
59 | # Difference between the two iconv directions. | |
60 | diff ${objpfx}tst-${charset}.table ${objpfx}tst-${charset}.inverse.table | \ | |
61 | grep '^[<>]' | sed -e 's,^. ,,' > ${objpfx}tst-${charset}.irreversible.table | |
62 | ||
63 | # Check 1: charmap and iconv forward should be identical. | |
601d2942 UD |
64 | if test ${charset} = GB18030; then |
65 | grep '0x....$' < ${objpfx}tst-${charset}.charmap.table \ | |
66 | > ${objpfx}tst-${charset}.truncated.table | |
67 | cmp -s ${objpfx}tst-${charset}.truncated.table ${objpfx}tst-${charset}.table || | |
68 | exit 1 | |
69 | else | |
70 | cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table || | |
71 | exit 1 | |
72 | fi | |
b79f74cd UD |
73 | |
74 | # Check 2: the difference between the two iconv directions. | |
75 | if test -f ${irreversible}; then | |
76 | cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u \ | |
77 | > ${objpfx}tst-${charset}.tmp.table | |
63e18f77 UD |
78 | cmp -s ${objpfx}tst-${charset}.tmp.table ${objpfx}tst-${charset}.inverse.table || |
79 | exit 1 | |
b79f74cd | 80 | else |
63e18f77 UD |
81 | cmp -s ${objpfx}tst-${charset}.table ${objpfx}tst-${charset}.inverse.table || |
82 | exit 1 | |
b79f74cd UD |
83 | fi |
84 | ||
85 | exit 0 |