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.
This commit is contained in:
Nobuyoshi Nakada 2022-09-14 18:03:48 +09:00
Родитель 6898984f1c
Коммит 76c0056505
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7CD2805BFA3770C6
1 изменённых файлов: 13 добавлений и 12 удалений

Просмотреть файл

@ -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(/^/, '> ')}