2005-09-15 09:58:31 -04:00
|
|
|
|
#!/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 */'
|
|
|
|
|
echo '/* DO NOT EDIT THIS FILE! EDIT Unicode/<whatever> INSTEAD! */'
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
for i in $codepages; do
|
|
|
|
|
echo -n $i' ' 1>&2
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "/*** $i ***/"
|
|
|
|
|
echo
|
|
|
|
|
|
2006-09-24 09:55:29 -04:00
|
|
|
|
sed '1,2d
|
|
|
|
|
/^[ ]*\(#.*\)\{,1\}$/d
|
|
|
|
|
h
|
|
|
|
|
s/^[^#]*//
|
|
|
|
|
s!#[ ]*\(.*\)!/* \1 */!
|
|
|
|
|
x
|
|
|
|
|
s/#.*//
|
|
|
|
|
y/Xabcdef/xABCDEF/
|
|
|
|
|
/^0x[01234567]/d
|
|
|
|
|
/[^0x0123456789ABCDEF ]/d
|
|
|
|
|
G
|
|
|
|
|
s/\n//' "$i.cp" | {
|
|
|
|
|
for left in 8 9 A B C D E F; do
|
|
|
|
|
for right in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do
|
|
|
|
|
eval "high0x$left$right="
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
table=
|
|
|
|
|
highuse=
|
|
|
|
|
while read byte unicode comment; do
|
|
|
|
|
if eval "[ \"\$high$byte\" ]"; then
|
|
|
|
|
table="$table {$byte, $unicode},${comment+ }$comment
|
|
|
|
|
"
|
|
|
|
|
else
|
|
|
|
|
eval "high$byte=\"\$unicode,\${comment+ }\$comment\""
|
|
|
|
|
highuse=1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
if [ "$highuse" ]; then
|
|
|
|
|
printf "const uint16_t highhalf_%s [] = {\n" "$i"
|
|
|
|
|
for left in 8 9 A B C D E F; do
|
|
|
|
|
for right in 0 1 2 3 4 5 6 7 8 9 A B C D E F; do
|
|
|
|
|
eval "printf \"\\t/* %s */ %s\\n\" \"0x$left$right\" \"\${high0x$left$right:-0xFFFF,}\""
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
printf "};\n\n"
|
|
|
|
|
else
|
|
|
|
|
printf "#define highhalf_%s highhalf_NULL\n\n" "$i"
|
|
|
|
|
fi
|
|
|
|
|
if [ "$table" ]; then
|
|
|
|
|
printf "const struct table_entry table_%s [] = {\n%s\t{0, 0}\n};\n" "$i" "$table"
|
|
|
|
|
else
|
|
|
|
|
printf "#define table_%s table_NULL\n" "$i"
|
|
|
|
|
fi
|
|
|
|
|
printf "\n"
|
|
|
|
|
}
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
2006-09-24 04:59:23 -04:00
|
|
|
|
echo 'unsigned char *const aliases_'$i' [] = {'
|
2005-09-15 09:58:31 -04:00
|
|
|
|
head -n 2 $i.cp | tail -n +2 | sed 's/ \+/ /g; s/ $//; s/\", /\",<2C>/g; s/$/,/' | tr "<22>" "\n" \
|
|
|
|
|
| sed 's/^/<2F>/g' | tr "<22>" "\t"
|
|
|
|
|
echo ' NULL
|
|
|
|
|
};'
|
|
|
|
|
n=`expr $n + 1`
|
|
|
|
|
done
|
|
|
|
|
|
2006-09-24 09:55:29 -04:00
|
|
|
|
printf "\n/*** NULL ***/\n\n"
|
|
|
|
|
printf "const uint16_t highhalf_NULL [] = {\n"
|
|
|
|
|
for r in `seq 16`; do
|
|
|
|
|
printf "\t0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xFFFF,0xFFFF,0xFFFF,0xFFFF,\n"
|
|
|
|
|
done
|
|
|
|
|
printf "};\n\n"
|
|
|
|
|
printf "const struct table_entry table_NULL [] = {\n"
|
|
|
|
|
printf "\t{0, 0}\n"
|
|
|
|
|
printf "};\n"
|
|
|
|
|
|
2005-09-15 09:58:31 -04:00
|
|
|
|
echo
|
2006-09-24 04:59:23 -04:00
|
|
|
|
echo 'const struct codepage_desc codepages [] = {'
|
2005-09-15 09:58:31 -04:00
|
|
|
|
|
|
|
|
|
for i in $codepages; do
|
2006-09-24 09:55:29 -04:00
|
|
|
|
echo ' {"'`head -n 1 $i.cp`'", aliases_'$i', highhalf_'$i', table_'$i'},'
|
2005-09-15 09:58:31 -04:00
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo ' {NULL, NULL, NULL}'
|
|
|
|
|
echo '};'
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo '#define N_CODEPAGES '$n | sed 's/
//g'
|
|
|
|
|
|
|
|
|
|
) | sed 's/
//g' > ../src/intl/codepage.inc
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo Done.
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo
|