From 76c00565052368f693bc4e18e8e40b614f744d74 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 14 Sep 2022 18:03:48 +0900 Subject: [PATCH] Follow emoji data files header change The header of emoji data files in UCD, which were moved at 13.0.0, has been changed since 14.0.0. It seems to be the same as other files in UCD. --- tool/enc-unicode.rb | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tool/enc-unicode.rb b/tool/enc-unicode.rb index 93f6e869f8..6fb0f36d5b 100755 --- a/tool/enc-unicode.rb +++ b/tool/enc-unicode.rb @@ -311,18 +311,19 @@ end def data_foreach(name, &block) fn = get_file(name) warn "Reading #{name}" - if /^emoji/ =~ name - sep = "" - pat = /^# #{Regexp.quote(File.basename(name))}.*^# Version: ([\d.]+)/m - type = :Emoji - else - sep = "\n" - pat = /^# #{File.basename(name).sub(/\./, '-([\\d.]+)\\.')}/ - type = :Unicode - end File.open(fn, 'rb') do |f| - line = f.gets(sep) - unless version = line[pat, 1] + if /^emoji/ =~ name + line = f.gets("") + # Headers till Emoji 13 + version = line[/^# #{Regexp.quote(File.basename(name))}.*^# Version: ([\d.]+)/m, 1] + type = :Emoji + else + # Headers since Emoji 14 or other Unicode data + line = f.gets("\n") + type = :Unicode + end + version ||= line[/^# #{File.basename(name).sub(/\./, '-([\\d.]+)\\.')}/, 1] + unless version raise ArgumentError, <<-ERROR #{name}: no #{type} version #{line.gsub(/^/, '> ')} @@ -330,7 +331,7 @@ def data_foreach(name, &block) end if !(v = $versions[type]) $versions[type] = version - elsif v != version + elsif v != version and "#{v}.0" != version raise ArgumentError, <<-ERROR #{name}: #{type} version mismatch: #{version} to #{v} #{line.gsub(/^/, '> ')}