| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | set -e |
| 3 | LC_ALL=C |
| 4 | export LC_ALL |
| 5 | echoscip-shell system . . echo. |
| 6 | echoscip-shell system . . echo. Generating code page translation tables. |
| 7 | codepages=`catscip-shell system . . cat. index.txt|sedscip-shell system . . sed. 's/ //g'` |
| 8 | if [scip-shell system . . `[`. -n "$codepages" ]; then |
| 9 | ( |
| 10 | n=0 |
| 11 | echoscip-shell system . . echo. '/* Automatically generated by gen-cp */scip-shell filesystem . . `/* Automatically generated by gen-cp */`.' |
| 12 | for i in $codepages; do |
| 13 | printfscip-shell system . . printf. $i' ' 1>&2 |
| 14 | echoscip-shell system . . echo. |
| 15 | echoscip-shell system . . echo. 'static_const struct table_entry table_'$i' [] = {' |
| 16 | tailscip-shell system . . tail. -n +3 $i.cp | sedscip-shell system . . sed. 's/#.*$//' | grepscip-shell system . . grep. '^0x[89a-fA-F]' | sedscip-shell system . . sed. 's/[ ][ ]*/ /g' | sedscip-shell system . . sed. 's/[ ]*$/ },/' | sedscip-shell system . . sed. 's/ /, /' | sedscip-shell system . . sed. 's/^[ ]*/ { /' | grepscip-shell system . . grep. '.*, .*,' | grepscip-shell system . . grep. -v ', 0x0*[89][0-9a-fA-F] ' || truescip-shell system . . true. |
| 17 | echoscip-shell system . . echo. ' { 0, 0 }' |
| 18 | echoscip-shell system . . echo. '};' |
| 19 | echoscip-shell system . . echo. |
| 20 | echoscip-shell system . . echo. 'static_const const_char_ptr aliases_'$i' [] = {'`headscip-shell system . . head. -2 $i.cp | tailscip-shell system . . tail. -n +2`', NULL };' |
| 21 | n=`exprscip-shell system . . expr. $n + 1` |
| 22 | done |
| 23 | echoscip-shell system . . echo. |
| 24 | echoscip-shell system . . echo. 'static_const struct codepage_desc codepages [] = {' |
| 25 | for i in $codepages; do |
| 26 | echoscip-shell system . . echo. ' { "'`headscip-shell system . . head. -1 $i.cp`'", aliases_'$i', table_'$i' },' |
| 27 | done |
| 28 | echoscip-shell system . . echo. ' { NULL, NULL, NULL }' |
| 29 | echoscip-shell system . . echo. '};' |
| 30 | echoscip-shell system . . echo. '#define N_CODEPAGES '$n | sedscip-shell system . . sed. 's/ //g' > codepage.h |
| 31 | if cmpscip-shell system . . cmp. -s ../codepage.h codepage.h; then |
| 32 | rmscip-shell system . . rm. -f codepage.h |
| 33 | else |
| 34 | mvscip-shell system . . mv. codepage.h ../codepage.h |
| 35 | fi |
| 36 | ) | sedscip-shell system . . sed. 's/ //g' > ../codepage.inc |
| 37 | echoscip-shell system . . echo. |
| 38 | echoscip-shell system . . echo. Done. |
| 39 | fi |
| 40 | echoscip-shell system . . echo. |