mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Embed the Emoji version
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b02f3731b6
commit
7aaf5b2878
2 changed files with 51 additions and 23 deletions
|
@ -38381,3 +38381,12 @@ uniname2ctype(const UChar *name, unsigned int len)
|
|||
#define ONIG_UNICODE_VERSION_MAJOR 10
|
||||
#define ONIG_UNICODE_VERSION_MINOR 0
|
||||
#define ONIG_UNICODE_VERSION_TEENY 0
|
||||
#if defined ONIG_UNICODE_EMOJI_VERSION_STRING && !( \
|
||||
ONIG_UNICODE_EMOJI_VERSION_MAJOR == 5 && \
|
||||
ONIG_UNICODE_EMOJI_VERSION_MINOR == 0 && \
|
||||
1)
|
||||
# error ONIG_UNICODE_EMOJI_VERSION_STRING mismatch
|
||||
#endif
|
||||
#define ONIG_UNICODE_EMOJI_VERSION_STRING "5.0"
|
||||
#define ONIG_UNICODE_EMOJI_VERSION_MAJOR 5
|
||||
#define ONIG_UNICODE_EMOJI_VERSION_MINOR 0
|
||||
|
|
|
@ -18,7 +18,11 @@ unless ARGV.size == 2
|
|||
abort "Usage: #{$0} data_directory emoji_data_directory"
|
||||
end
|
||||
|
||||
$unicode_version = File.basename(ARGV[0])[/\A[.\d]+\z/]
|
||||
pat = /(?:\A|\/)([.\d]+)\z/
|
||||
$versions = {
|
||||
:Unicode => ARGV[0][pat, 1],
|
||||
:Emoji => ARGV[1][pat, 1],
|
||||
}
|
||||
|
||||
POSIX_NAMES = %w[NEWLINE Alpha Blank Cntrl Digit Graph Lower Print XPosixPunct Space Upper XDigit Word Alnum ASCII Punct]
|
||||
|
||||
|
@ -307,18 +311,30 @@ end
|
|||
def data_foreach(name, &block)
|
||||
fn = get_file(name)
|
||||
warn "Reading #{name}"
|
||||
pat = /^# #{File.basename(name).sub(/\./, '-([\\d.]+)\\.')}/
|
||||
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
|
||||
unless /^emoji-/ =~ name
|
||||
unless pat =~ line
|
||||
raise ArgumentError, "#{name}: no Unicode version"
|
||||
end
|
||||
if !$unicode_version
|
||||
$unicode_version = $1
|
||||
elsif $unicode_version != $1
|
||||
raise ArgumentError, "#{name}: Unicode version mismatch: #$1"
|
||||
end
|
||||
line = f.gets(sep)
|
||||
unless version = line[pat, 1]
|
||||
raise ArgumentError, <<-ERROR
|
||||
#{name}: no #{type} version
|
||||
#{line.gsub(/^/, '> ')}
|
||||
ERROR
|
||||
end
|
||||
if !(v = $versions[type])
|
||||
$versions[type] = version
|
||||
elsif v != version
|
||||
raise ArgumentError, <<-ERROR
|
||||
#{name}: #{type} version mismatch: #{version} to #{v}
|
||||
#{line.gsub(/^/, '> ')}
|
||||
ERROR
|
||||
end
|
||||
f.each(&block)
|
||||
end
|
||||
|
@ -510,17 +526,20 @@ uniname2ctype(const UChar *name, unsigned int len)
|
|||
return -1;
|
||||
}
|
||||
__HEREDOC
|
||||
versions = $unicode_version.scan(/\d+/)
|
||||
print("#if defined ONIG_UNICODE_VERSION_STRING && !( \\\n")
|
||||
%w[MAJOR MINOR TEENY].zip(versions) do |n, v|
|
||||
print(" ONIG_UNICODE_VERSION_#{n} == #{v} && \\\n")
|
||||
end
|
||||
print(" 1)\n")
|
||||
print("# error ONIG_UNICODE_VERSION_STRING mismatch\n")
|
||||
print("#endif\n")
|
||||
print("#define ONIG_UNICODE_VERSION_STRING #{$unicode_version.dump}\n")
|
||||
%w[MAJOR MINOR TEENY].zip(versions) do |n, v|
|
||||
print("#define ONIG_UNICODE_VERSION_#{n} #{v}\n")
|
||||
$versions.each do |type, ver|
|
||||
name = type == :Unicode ? "ONIG_UNICODE_VERSION" : "ONIG_UNICODE_EMOJI_VERSION"
|
||||
versions = ver.scan(/\d+/)
|
||||
print("#if defined #{name}_STRING && !( \\\n")
|
||||
versions.zip(%w[MAJOR MINOR TEENY]) do |v, n|
|
||||
print(" #{name}_#{n} == #{v} && \\\n")
|
||||
end
|
||||
print(" 1)\n")
|
||||
print("# error #{name}_STRING mismatch\n")
|
||||
print("#endif\n")
|
||||
print("#define #{name}_STRING #{ver.dump}\n")
|
||||
versions.zip(%w[MAJOR MINOR TEENY]) do |v, n|
|
||||
print("#define #{name}_#{n} #{v}\n")
|
||||
end
|
||||
end
|
||||
|
||||
output.restore
|
||||
|
|
Loading…
Reference in a new issue