#! /bin/sh

# check uniqueness of character mnemonics

mnemodupats () {
	sed -e 's:\({".*"\), .*:\1:' -e t -e d $* |
	sort | uniq -d
}

files=${*-mnemos.??[!~]}

tmp=/tmp/mnemodupats

LC_ALL=C
export LC_ALL

mnemodupats $files > $tmp

cat $tmp |
while read pat
do	if fgrep -e "$pat" $files |
		sed -e 's:[ 	]*/\*.*::' -e 's:.*{".*",[ 	]*:printf %X\\\\n :' |
		sh | sort | uniq -u | grep . > /dev/null
	then
		fgrep -e "$pat" $files
	fi
done > $tmp.diff

set - `wc -l $tmp.diff`
err=$1
if [ "$err" -ne 0 ]
then	cat $tmp.diff
fi
rm -f $tmp.diff

echo $err inconsistent duplicate mnemonics
exit $err

