"Fossies" - the Fresh Open Source Software Archive

Member "links-1.03/Unicode/gen-cp" (18 Apr 2011, 895 Bytes) of archive /linux/www/links-1.03.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "gen-cp": 2.8_vs_1.03.

    1 #!/bin/sh
    2 LC_ALL=C
    3 export LC_ALL
    4 echo
    5 echo Generating code page translation tables.
    6 codepages=`cat index.txt|sed 's/
//g'`
    7 if [ -n "$codepages" ]; then
    8 (
    9 n=0
   10 echo '/* Automatically generated by gen-cp */'
   11 for i in $codepages; do
   12     echo -n $i' ' 1>&2
   13     echo
   14     echo 'struct table_entry table_'$i' [] = {'
   15     tail -n +3 $i.cp | sed 's/#.*$//' | grep '^0x[89a-zA-Z]' | sed 's/[     ][  ]*/ /g' | sed 's/[  ]*$/ },/' | sed 's/ /, /' | sed 's/^[   ]*/ { /' | grep '.*,.*,'
   16     echo '  { 0, 0 }'
   17     echo '};'
   18     echo
   19     echo 'unsigned char *aliases_'$i' [] = {'`head -2 $i.cp | tail -n +2`', NULL };'
   20     n=`expr $n + 1`
   21 done
   22 echo
   23 echo 'struct codepage_desc codepages [] = {'
   24 for i in $codepages; do
   25     echo '  { "'`head -1 $i.cp`'", aliases_'$i', table_'$i' },'
   26 done
   27 echo '  { NULL, NULL, NULL }'
   28 echo '};'
   29 echo '#define N_CODEPAGES '$n | sed 's/
//g' > ../codepage.h
   30 ) | sed 's/
//g' > ../codepage.inc
   31 echo
   32 echo Done.
   33 fi
   34 echo