From 7d2084be0f4e81cf3b3ba03de26a617c53d5f821 Mon Sep 17 00:00:00 2001 From: elfham <38372058+elfham@users.noreply.github.com> Date: Thu, 24 Aug 2023 01:19:09 +0900 Subject: [PATCH] EastAsianWidth.txt Format Change after Unicode 15.1.0 (#585) * fix bin/generate_east_asian_width for Unicode 15.1.0 * fix a regexp of parsing EastAsianWidth.txt line * Fix to use MatchData#[] instead of Regexp::last_match --- bin/generate_east_asian_width | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/bin/generate_east_asian_width b/bin/generate_east_asian_width index 0484e38433..1172f422a5 100755 --- a/bin/generate_east_asian_width +++ b/bin/generate_east_asian_width @@ -8,16 +8,11 @@ end open(ARGV.first, 'rt') do |f| list = [] f.each_line do |line| - next if line.start_with?(?#) - line.chomp!.sub!(/ .*/, '') - next if line.empty? - range, type = line.chomp.split(';') - type = type.to_sym - if range =~ /\h+\.\.\h+/ - first, last = range.split('..').map{ |_| _.to_i(16) } - else - first = last = range.to_i(16) - end + next unless m = line.match(/^(\h+)(?:\.\.(\h+))?\s*;\s*(\w+)\s+#.+/) + + first = m[1].to_i(16) + last = m[2]&.to_i(16) || first + type = m[3].to_sym if !list.empty? and (list.last[:range].last + 1) == first and list.last[:type] == type list.last[:range] = (list.last[:range].first..last) else