summaryrefslogtreecommitdiff
path: root/Unicode/gen-cp
diff options
context:
space:
mode:
Diffstat (limited to 'Unicode/gen-cp')
-rwxr-xr-xUnicode/gen-cp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Unicode/gen-cp b/Unicode/gen-cp
new file mode 100755
index 0000000..628c0e3
--- /dev/null
+++ b/Unicode/gen-cp
@@ -0,0 +1,34 @@
+#!/bin/sh
+LC_ALL=C
+export LC_ALL
+echo
+echo Generating code page translation tables.
+codepages=`cat index.txt|sed 's/ //g'`
+if [ -n "$codepages" ]; then
+(
+n=0
+echo '/* Automatically generated by gen-cp */'
+for i in $codepages; do
+ echo -n $i' ' 1>&2
+ echo
+ echo 'static 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 'static unsigned char *aliases_'$i' [] = {'`head -2 $i.cp | tail -n +2`', NULL };'
+ n=`expr $n + 1`
+done
+echo
+echo 'static 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