Skip to content

Commit 6886e2b

Browse files
committed
update-tables: Improve char width table parsing
Make the script used to parse EastAsianWidth more robust, mapping ambiguous width characters to double-width ones.
1 parent 1b91aa9 commit 6886e2b

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
timeout 120 busted -c
4848
- name: Coverage Report
4949
run: |
50+
source env/bin/activate
5051
luacov-coveralls --dryrun -e '.luarocks/' -e spec/ -e luarocks/ -i wcwidth/ -i wcwidth.lua -o coveralls.json -v
5152
- name: Coveralls
5253
uses: coverallsapp/github-action@v2

update-tables

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,21 @@ wide_table () {
7575
local tmpfile="${TMPDIR:-/tmp}/update-tables-$$-${RANDOM}"
7676
echo "-- Autogenerated from ${WIDE_FILE##*/}"
7777
echo 'return {'
78-
while read -r item rest ; do
79-
if [[ -z ${item} || ${item} = \#* ]] ; then
78+
while read -r line ; do
79+
if [[ -z ${line} || ${line} = \#* ]] ; then
80+
read -r line rest <<< "${line}"
8081
if [[ ${rest} = *.txt ]] ; then
8182
WIDE_VER=${rest}
8283
elif [[ ${rest} = Date:\ 20* || ${rest} = ©\ 20* ]] ; then
8384
WIDE_VER="${WIDE_VER}, ${rest}"
8485
fi
8586
continue
8687
fi
87-
range=${item%;*}
88-
flags=${item#*;}
89-
if [[ ${flags} = W* || ${flags} = F* ]] ; then
90-
format_range "${range}"
91-
fi
88+
read -r -a items <<< "${line}"
89+
case ${items[2]} in
90+
F | W | A )
91+
format_range "${items[0]}" ;;
92+
esac
9293
done > "${tmpfile}"
9394
sort "${tmpfile}"
9495
rm "${tmpfile}"

0 commit comments

Comments
 (0)