#!/bin/sh echo echo Generating code page translation tables. codepages=`cat index.txt` if [ -n "$codepages" ]; then ( n=0 echo '/* Automatically generated by gen-cp */' for i in $codepages; do echo -n $i' ' 1>&2 echo echo 'struct table_entry table_'$i' [] = {' tail -n +3 $i.cp | sed 's/#.*$//' | grep '^0x[89a-zA-Z]' | sed 's/[ ][ ]*/ /g' | sed 's/[ ]*$/ },/' | sed 's/ /, /' | sed 's/^[ ]*/ { /' | grep '.*,.*,' echo ' { 0, 0 }' echo '};' echo echo 'unsigned char *aliases_'$i' [] = {'`head -2 $i.cp | tail -n +2`', NULL };' n=`expr $n + 1` done echo echo 'struct codepage_desc codepages [] = {' for i in $codepages; do echo ' { "'`head -1 $i.cp`'", aliases_'$i', table_'$i' },' done echo ' { NULL, NULL, NULL }' echo '};' echo '#define N_CODEPAGES '$n | sed 's/ //g' > ../codepage.h ) | sed 's/ //g' > ../codepage.inc echo echo Done. fi echo