#! /bin/sh -f

if make UnicodeData.txt
then	true
else	echo Could not acquire Unicode data file UnicodeData.txt
	exit 1
fi
if make NameAliases.txt
then	true
else	echo Could not acquire Unicode data file NameAliases.txt
	exit 1
fi


LC_ALL=C
export LC_ALL

# modify UnicodeData.txt according to NameAliases.txt
sed	-e "s,^\([0-9A-F]*\);\([^;]*\).*,/^\1;/ s/.*/\1;\2;;;;;;;;;;;;;/," \
	-e t -e d NameAliases.txt > mkchname.sed

# scan UnicodeData.txt:
#	0153;LATIN SMALL LIGATURE OE;...
#	0000;<control>;Cc;0;BN;;;;;N;NULL;...
# generate lines:
#	{0x0153, "LATIN SMALL LIGATURE OE"},
#	{0x0000, "NULL"},
# and give precedence to NameAliases.txt:
sed	-f mkchname.sed UnicodeData.txt |
sed	-e 's/^\([^;]*\);<control>;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;[^;]*;\([^;]*\);.*/	{0x\1, "\2"},/' \
	-e t \
	-e '/^[^;]*;</ d' \
	-e 's/^\([^;]*\);\([^;]*\);.*/	{0x\1, "\2"},/' \
	-e t \
	> charname.t
rm -f mkchname.sed
