1#!/bin/sh 2# Complete check of a stateless encoding. 3# Usage: check-stateless SRCDIR CHARSET 4srcdir="$1" 5charset="$2" 6set -e 7 8# iconv in one direction. 9./table-from "$charset" > tmp-"$charset".TXT 10 11# iconv in the other direction. 12./table-to "$charset" | sort > tmp-"$charset".INVERSE.TXT 13 14# Check 1: charmap and iconv forward should be identical. 15cmp "${srcdir}"/"$charset".TXT tmp-"$charset".TXT 2> /dev/null 16 17# Check 2: the difference between the charmap and iconv backward. 18sed -e '/ .* 0x/d' < "${srcdir}"/"$charset".TXT > tmp-noprecomposed-"$charset".TXT 19if test -f "${srcdir}"/"$charset".IRREVERSIBLE.TXT; then 20 cat tmp-noprecomposed-"$charset".TXT "${srcdir}"/"$charset".IRREVERSIBLE.TXT | sort | uniq -u > tmp-orig-"$charset".INVERSE.TXT 21else 22 cp tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXT 23fi 24cmp tmp-orig-"$charset".INVERSE.TXT tmp-"$charset".INVERSE.TXT 2> /dev/null 25 26rm -f tmp-"$charset".TXT tmp-"$charset".INVERSE.TXT tmp-noprecomposed-"$charset".TXT tmp-orig-"$charset".INVERSE.TXT 27exit 0 28# For a new encoding: 29# You can create the "$charset".TXT like this: 30# ./table-from "$charset" > "$charset".TXT 31# You can create the "$charset".IRREVERSIBLE.TXT like this: 32# ./table-to "$charset" | sort > "$charset".INVERSE.TXT 33# diff "$charset".TXT "$charset".INVERSE.TXT | grep '^[<>]' | sed -e 's,^. ,,' > "$charset".IRREVERSIBLE.TXT 34