#! /bin/sh -f

# post-processing of scripts.tt (formerly scripts.t)
# transform
#	{0x0041, 0x005A, "Latin", "Letter"},
# ->
#	{0x0041, 0x005A, catLatin, catLetter},
# and generate index list and table of category names


sed -e 's/, "/, cat/g' -e 's/"//g' -e 's/ /_/g' -e 's/,_/, /g' scripts.tt > scripts.t

cats () {
	sed -e 's/^.*"\([^"]*\)", "\([^"]*\)"},/\1
\2/' scripts.tt |
	tr '\015' '\012' |
	sort | uniq
}

(
cats | sed -e 's, ,_,g' | cat -b |
sed -e 's, *\([0-9][0-9]*\)[ 	]*\(.*\),#define cat\2	\1,'
echo
echo 'char * category_names [] = {0,'
cats | sed -e 's/^/	"/' -e 's/$/",/'
echo '};'
) > scriptdf.t
