2018-03-08 06:55:52 +08:00
|
|
|
#! /bin/sh
|
|
|
|
|
2018-03-14 01:26:19 +08:00
|
|
|
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
|
2018-03-14 01:26:19 +08:00
|
|
|
-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)
|
2018-03-14 01:26:19 +08:00
|
|
|
wget () {
|
2021-04-17 06:00:00 +08:00
|
|
|
ref=`basename $1`
|
|
|
|
ref=`ls "$ref" 2> /dev/null || echo 01-Jan-1970`
|
|
|
|
curl -R -O --connect-timeout 55 -z "$ref" "$1"
|
2018-03-14 01:26:19 +08:00
|
|
|
}
|
2018-03-08 06:55:52 +08:00
|
|
|
|
|
|
|
echo downloading uniset tool
|
2021-04-17 06:00:00 +08:00
|
|
|
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
|
2018-03-14 01:26:19 +08:00
|
|
|
do wget http://unicode.org/Public/UNIDATA/$data
|
2018-03-08 06:55:52 +08:00
|
|
|
done
|
|
|
|
;;
|
2018-03-14 01:26:19 +08:00
|
|
|
-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
|
|
|
|
|
2018-03-14 01:26:19 +08:00
|
|
|
echo checking Unicode data files
|
2018-03-08 06:55:52 +08:00
|
|
|
for data in UnicodeData.txt Blocks.txt EastAsianWidth.txt
|
2018-03-14 01:26:19 +08:00
|
|
|
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
|