#!/bin/sh
set -e
LC_ALL=C
export LC_ALL
echo
echo Generating entity table.
(
cat entities.lnx | sed 's/
$//' | grep '^[ 	]*{"' | sort >tmp
N=`cat tmp | wc -l`
echo '/* Automatically generated by gen-ent */'
echo
echo 'static_const struct { const char *s; int c; } entities ['`expr $N + 1`'] = {'
cat tmp
echo '  {NULL,	0}'
echo '};'
echo
echo '#define N_ENTITIES' $N
) > ../entity.inc
rm -f tmp
echo Done.
echo
