diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-27 06:44:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-27 06:44:02 +0000 |
commit | 7aaf5b2878210d4df03a84be8d514a553839a5ba (patch) | |
tree | 74d07844a3691bd47fc96b0f59e79850c79f6159 | |
parent | b02f3731b64555457c608f93d2f6d61e0e4e75c6 (diff) |
Embed the Emoji version
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | enc/unicode/10.0.0/name2ctype.h | 9 | ||||
-rwxr-xr-x | tool/enc-unicode.rb | 65 |
2 files changed, 51 insertions, 23 deletions
diff --git a/enc/unicode/10.0.0/name2ctype.h b/enc/unicode/10.0.0/name2ctype.h index 680560707f..dc23d54ab8 100644 --- a/enc/unicode/10.0.0/name2ctype.h +++ b/enc/unicode/10.0.0/name2ctype.h @@ -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 diff --git a/tool/enc-unicode.rb b/tool/enc-unicode.rb index b0819c35ab..f64cecb881 100755 --- a/tool/enc-unicode.rb +++ b/tool/enc-unicode.rb @@ -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 |