#!/bin/sh
# Simple check of a stateful encoding.
# Usage: check-stateful SRCDIR CHARSET
srcdir="$1"
charset="$2"
set -e
# For systems with severe filename restrictions allow for
# an alternate filename.
UNAME=${UNAME-`uname 2>/dev/null`}
case X$UNAME in
  *-DOS) filename=`echo "$charset" | sed "s|ISO-|ISO/|;s|2022-|2022|"` ;;
  *)     filename="$charset" ;;
esac
../src/iconv_no_i18n -f "$charset" -t UTF-8 < "${srcdir}"/"$filename"-snippet > tmp-snippet
cmp "${srcdir}"/"$filename"-snippet.UTF-8 tmp-snippet
../src/iconv_no_i18n -f UTF-8 -t "$charset" < "${srcdir}"/"$filename"-snippet.UTF-8 > tmp-snippet
cmp "${srcdir}"/"$filename"-snippet tmp-snippet
rm -f tmp-snippet
exit 0
