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