4 echo Generating code page translation tables.
6 codepages
=`cat index.txt`
8 if [ -n "$codepages" ]; then
14 echo '/* Automatically generated by gen-cp */'
15 echo '/* DO NOT EDIT THIS FILE! EDIT Unicode/<whatever> INSTEAD! */'
18 for i
in $codepages; do
27 /^[ ]*\(#.*\)\{,1\}$/d
30 s!#[ ]*\(.*\)!/* \1 */!
35 /[^0x0123456789ABCDEF ]/d
38 for left
in 8 9 A B C D E F
; do
39 for right
in 0 1 2 3 4 5 6 7 8 9 A B C D E F
; do
40 eval "high0x$left$right="
45 while read byte unicode comment
; do
46 if eval "[ \"\$high$byte\" ]"; then
47 table
="$table {$byte, $unicode},${comment+ }$comment
50 eval "high$byte=\"\$unicode,\${comment+ }\$comment\""
54 if [ "$highuse" ]; then
55 printf "const uint16_t highhalf_%s [] = {\n" "$i"
56 for left
in 8 9 A B C D E F
; do
57 for right
in 0 1 2 3 4 5 6 7 8 9 A B C D E F
; do
58 eval "printf \"\\t/* %s */ %s\\n\" \"0x$left$right\" \"\${high0x$left$right:-0xFFFF,}\""
63 printf "#define highhalf_%s highhalf_NULL\n\n" "$i"
66 printf "const struct table_entry table_%s [] = {\n%s\t{0, 0}\n};\n" "$i" "$table"
68 printf "#define table_%s table_NULL\n" "$i"
73 echo 'unsigned char *const aliases_'$i' [] = {'
74 head -n 2 $i.
cp |
tail -n +2 |
sed 's/ \+/ /g; s/ $//; s/\", /\",£/g; s/$/,/' |
tr "£" "\n" \
75 |
sed 's/^/£/g' |
tr "£" "\t"
81 printf "\n/*** NULL ***/\n\n"
82 printf "const uint16_t highhalf_NULL [] = {\n"
84 printf "\t0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF,\n"
87 printf "const struct table_entry table_NULL [] = {\n"
92 echo 'const struct codepage_desc codepages [] = {'
94 for i
in $codepages; do
95 echo ' {"'`head -n 1 $i.cp`'", aliases_'$i', highhalf_'$i', table_'$i'},'
98 echo ' {NULL, NULL, NULL}'
102 echo '#define N_CODEPAGES '$n |
sed 's/
//g'
104 ) |
sed 's/
//g' > ..
/src
/intl
/codepage.inc