-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate-tables
More file actions
executable file
·58 lines (49 loc) · 1.68 KB
/
update-tables
File metadata and controls
executable file
·58 lines (49 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /bin/bash
#
# update-tables
# Copyright (C) 2016 Adrian Perez <aperez@igalia.com>
#
# Distributed under terms of the MIT license.
#
set -e
WIDE_URL='http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt'
ZERO_URL='http://www.unicode.org/Public/UNIDATA/extracted/DerivedGeneralCategory.txt'
# The version numbers of the files above are parsed from the files themselves.
WIDE_VER='(unknown)'
ZERO_VER='(unknown)'
srcdir=$(dirname "$0")
WIDE_FILE="${srcdir}/${WIDE_URL##*/}"
ZERO_FILE="${srcdir}/${ZERO_URL##*/}"
[[ -r ${WIDE_FILE} ]] || wget -c -O "${WIDE_FILE}" "${WIDE_URL}"
[[ -r ${ZERO_FILE} ]] || wget -c -O "${ZERO_FILE}" "${ZERO_URL}"
parse_file_version () {
local version rest line
while read -r line ; do
if [[ -z ${line} || ${line} = \#* ]] ; then
read -r line rest <<< "${line}"
if [[ ${rest} = *.txt ]] ; then
version=${rest}
elif [[ ${rest} = Date:\ 20* || ${rest} = ©\ 20* ]] ; then
version="${version}, ${rest}"
fi
continue
fi
done
echo "${version}"
}
make_readme () {
# Pick newest LuaRocks version
local V=$(find "${srcdir}/luarocks" -name 'wcwidth-[0-9]*.rockspec' \
| sed 's,^.*/wcwidth-\([0-9\.]\+\).*$,\1,' | sort -g | tail -1)
sed -e "s+@@WIDE_FILE@@+${WIDE_FILE##*/}+g" \
-e "s+@@ZERO_FILE@@+${ZERO_FILE##*/}+g" \
-e "s+@@WIDE_URL@@+${WIDE_URL}+g" \
-e "s+@@ZERO_URL@@+${ZERO_URL}+g" \
-e "s+@@WIDE_VER@@+${WIDE_VER}+g" \
-e "s+@@ZERO_VER@@+${ZERO_VER}+g" \
-e "s+@@LUAROCKS_VER@@+${V}+g"
}
WIDE_VER=$(parse_file_version < "${WIDE_FILE}")
ZERO_VER=$(parse_file_version < "${ZERO_FILE}")
make_readme < "${srcdir}/README.md.in" > "${srcdir}/README.md"
cat "${WIDE_FILE}" "${ZERO_FILE}" | "${srcdir}/generate-tables" -p"${srcdir}/wcwidth"