#!/bin/sh
set -e
LC_ALL=C
export LC_ALL
echo
echo Generating Unicode upcase table.
for file in upcase locase; do
	(
	echo '/* Automatically generated by gen-upc */'
	echo
	echo "static_const struct { unsigned short o; unsigned short n; } unicode_$file [] = {"
	(
		if [ $file = upcase ]; then
			echo '00A0 0020'
		fi
		cat $file.uni
	) | sed 's/^\([0-9A-Z]*\) \([0-9A-Z]*\)$/	{ 0x\1, 0x\2 },/' | sort
	echo '};'
	) > ../$file.inc
done
echo Done.
echo