newlib-cygwin/newlib/libc/string/mkunidata

74 lines
2.0 KiB
Plaintext
Raw Normal View History

2018-03-08 06:55:52 +08:00
#! /bin/sh
echo Generating Unicode width data for newlib/libc/string/wcwidth.c
2018-03-08 06:55:52 +08:00
cd `dirname $0`
PATH="$PATH":. # ensure access to uniset tool
#############################################################################
# checks and (with option -u) downloads
case "$1" in
-h) echo "Usage: $0 [-h|-u|-i]"
echo "Generate width data tables ambiguous.t, combining.t, wide.t"
echo "from local Unicode files UnicodeData.txt, Blocks.txt, EastAsianWidth.txt."
echo ""
echo "Options:"
echo " -u download files from unicode.org first, download uniset tool"
echo " -i copy files from /usr/share/unicode/ucd first"
echo " -h show this"
exit
;;
2018-03-08 06:55:52 +08:00
-u)
wget () {
ref=`basename $1`
ref=`ls "$ref" 2> /dev/null || echo 01-Jan-1970`
curl -R -O --connect-timeout 55 -z "$ref" "$1"
}
2018-03-08 06:55:52 +08:00
echo downloading uniset tool
wget https://www.cl.cam.ac.uk/~mgk25/download/uniset.tar.gz
2018-03-08 06:55:52 +08:00
gzip -dc uniset.tar.gz | tar xvf - uniset
echo downloading data from unicode.org
for data in UnicodeData.txt Blocks.txt EastAsianWidth.txt
do wget http://unicode.org/Public/UNIDATA/$data
2018-03-08 06:55:52 +08:00
done
;;
-i)
echo copying data from /usr/share/unicode/ucd
for data in UnicodeData.txt Blocks.txt EastAsianWidth.txt
do cp /usr/share/unicode/ucd/$data .
done
2018-03-08 06:55:52 +08:00
;;
esac
echo checking uniset tool
type uniset || exit 9
echo checking Unicode data files
2018-03-08 06:55:52 +08:00
for data in UnicodeData.txt Blocks.txt EastAsianWidth.txt
do if [ -r $data ]
then true
else echo $data not available, skipping table generation
exit
fi
2018-03-08 06:55:52 +08:00
done
echo generating from Unicode version `sed -e 's,[^.0-9],,g' -e 1q Blocks.txt`
#############################################################################
# table generation
echo generating combining characters table
uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B +D7B0-D7C6 +D7CB-D7FB c > combining.t
echo generating ambiguous width characters table
sh ./mkwidthA && uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c > ambiguous.t
echo generating wide characters table
sh ./mkwide
#############################################################################
# end