1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-07-01 02:05:33 +00:00
elinks/Unicode/gen-cp
Kalle Olavi Niemitalo 62d6db44aa Bug 381: Make codepage data const.
Before:

   text	   data	    bss	    dec	    hex	filename
  25726	  62992	   3343	  92061	  1679d	src/intl/charsets.o
 653856	 120020	  82144	 856020	  d0fd4	src/elinks

After:

   text	   data	    bss	    dec	    hex	filename
  60190	  28528	   3311	  92029	  1677d	src/intl/charsets.o
 688320	  85556	  82112	 855988	  d0fb4	src/elinks

So 34464 bytes were moved from the data section to the text section
and should be more likely to get shared between ELinks processes.

Measured on i686-pc-linux-gnu with: --disable-xbel --disable-nls
--disable-cookies --disable-formhist --disable-globhist
--disable-mailcap --disable-mimetypes --disable-smb --disable-mouse
--disable-sysmouse --disable-leds --disable-marks --disable-css
--enable-small --enable-utf-8 --without-gpm --without-bzlib
--without-idn --without-spidermonkey --without-lua --without-gnutls
--without-openssl CFLAGS="-O2 -ggdb -Wall"
2006-09-24 11:59:23 +03:00

69 lines
1.3 KiB
Bash
Executable File

#!/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
echo 'const struct table_entry table_'$i' [] = {'
# TODO: Comments inside of the structure are ugliness in a pure clean
# form, and my aesthetical feeling shivers upon glancing at it. However
# we should handle commentless records. A loop with read inside would
# be ideal, I suppose. --pasky
tail -n +3 $i.cp | sed 's/# *\(.*\) *$/\/* \1 *\/ /' | grep '^0x[89a-zA-Z]' \
| sed 's/[ ][ ]*/ /g' | sed 's/[ ]*$/ },/' | sed 's/ /, /' \
| sed 's/^[ ]*/ {/' | grep '.*,.*,'
echo ' {0, 0}'
echo '};'
echo
echo 'unsigned char *const aliases_'$i' [] = {'
head -n 2 $i.cp | tail -n +2 | sed 's/ \+/ /g; s/ $//; s/\", /\",£/g; s/$/,/' | tr "£" "\n" \
| sed 's/^/£/g' | tr "£" "\t"
echo ' NULL
};'
n=`expr $n + 1`
done
echo
echo 'const struct codepage_desc codepages [] = {'
for i in $codepages; do
echo ' {"'`head -n 1 $i.cp`'", aliases_'$i', table_'$i'},'
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