#! /bin/sh
#
# Test for Japanese encoding
#
LOG=`pwd`/test-log
echo '  *** starting ' $0 >>$LOG
TARGET=$srcdir/data/ja-spec
IDX=ja-idx1

EXEC=no

lc_all=$LC_ALL
lc_ctype=$LC_CTYPE
lang=$LANG

for ctype in "$lc_all" "$lc_ctype" "$lang"; do
    if test -n "$ctype" -a "$ctype" = "C"; then
        ctype="en"
        break
    fi
    cand=`echo "$ctype" | LC_ALL="C" perl -nle 'print $1 if /^(..)/'`
    if test -n "$cand"; then
        ctype=$cand
        break
    fi
done

case $ctype in 
	ja*)
		EXEC=yes
		;;
esac
if [ $EXEC = 'no' ]
then
        echo "Skipping because of LANG does not begin with ja: $0" >> $LOG
	exit 77
fi

if test ! -d $IDX; then
    mkdir $IDX
else
    rm -f $IDX/NMZ.*
fi

../scripts/mknmz -O $IDX $TARGET >> $LOG
exit $?
