]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - iconvdata/tst-table.sh
Update copyright notices with scripts/update-copyrights.
[thirdparty/glibc.git] / iconvdata / tst-table.sh
index e38b88ee37c6e4af48485e4dd6c9ee51a620247d..59166ca51136106e2e83a211da123923fca98804 100755 (executable)
@@ -1,30 +1,31 @@
 #!/bin/sh
-# Copyright (C) 2000 Free Software Foundation, Inc.
+# Copyright (C) 2000-2013 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 # Contributed by Bruno Haible <haible@clisp.cons.org>, 2000.
 #
+
 # The GNU C Library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
 # The GNU C Library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with the GNU C Library; see the file COPYING.LIB.  If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
 
 # Checks that the iconv() implementation (in both directions) for a
 # stateless encoding agrees with the charmap table.
 
 common_objpfx=$1
 objpfx=$2
-charset=$3
-charmap=$4
+run_program_prefix=$3
+charset=$4
+charmap=$5
 
 GCONV_PATH=${common_objpfx}iconvdata
 export GCONV_PATH
@@ -34,44 +35,64 @@ export LC_ALL
 set -e
 
 # Get the charmap.
-${SHELL} tst-table-charmap.sh ${charmap:-$charset} \
+./tst-table-charmap.sh ${charmap:-$charset} \
   < ../localedata/charmaps/${charmap:-$charset} \
   > ${objpfx}tst-${charset}.charmap.table
+# When the charset is GB18030, truncate this table because for this encoding,
+# the tst-table-from and tst-table-to programs scan the Unicode BMP only.
+if test ${charset} = GB18030; then
+  grep '0x....$' < ${objpfx}tst-${charset}.charmap.table \
+    > ${objpfx}tst-${charset}.truncated.table
+  mv ${objpfx}tst-${charset}.truncated.table ${objpfx}tst-${charset}.charmap.table
+fi
 
-# Precompute expected differences between the two iconv directions.
+# Precomputed expexted differences between the charmap and iconv forward.
+precomposed=${charset}.precomposed
+
+# Precompute expected differences between the charmap and iconv backward.
 if test ${charset} = EUC-TW; then
   irreversible=${objpfx}tst-${charset}.irreversible
-  grep '^0x8EA1' ${objpfx}tst-${charset}.charmap.table > ${irreversible}
+  (grep '^0x8EA1' ${objpfx}tst-${charset}.charmap.table
+   cat ${charset}.irreversible
+  ) > ${irreversible}
 else
   irreversible=${charset}.irreversible
 fi
 
 # iconv in one direction.
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${run_program_prefix} \
 ${objpfx}tst-table-from ${charset} \
   > ${objpfx}tst-${charset}.table
 
 # iconv in the other direction.
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${run_program_prefix} \
 ${objpfx}tst-table-to ${charset} | sort \
   > ${objpfx}tst-${charset}.inverse.table
 
-# Difference between the two iconv directions.
-diff ${objpfx}tst-${charset}.table ${objpfx}tst-${charset}.inverse.table | \
+# Difference between the charmap and iconv backward.
+diff ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table | \
   grep '^[<>]' | sed -e 's,^. ,,' > ${objpfx}tst-${charset}.irreversible.table
 
-# Check 1: charmap and iconv forward should be identical.
-cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table ||
-exit 1
+# Check 1: charmap and iconv forward should be identical, except for
+# precomposed characters.
+if test -f ${precomposed}; then
+  cat ${objpfx}tst-${charset}.table ${precomposed} | sort | uniq -u \
+    > ${objpfx}tst-${charset}.tmp.table
+  cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.tmp.table ||
+  exit 1
+else
+  cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.table ||
+  exit 1
+fi
 
-# Check 2: the difference between the two iconv directions.
+# Check 2: the difference between the charmap and iconv backward.
 if test -f ${irreversible}; then
   cat ${objpfx}tst-${charset}.charmap.table ${irreversible} | sort | uniq -u \
     > ${objpfx}tst-${charset}.tmp.table
   cmp -s ${objpfx}tst-${charset}.tmp.table ${objpfx}tst-${charset}.inverse.table ||
   exit 1
 else
-  cmp -s ${objpfx}tst-${charset}.table ${objpfx}tst-${charset}.inverse.table ||
+  cmp -s ${objpfx}tst-${charset}.charmap.table ${objpfx}tst-${charset}.inverse.table ||
   exit 1
 fi