[前][次][番号順一覧][スレッド一覧]

ruby-changes:53805

From: nobu <ko1@a...>
Date: Tue, 27 Nov 2018 15:44:09 +0900 (JST)
Subject: [ruby-changes:53805] nobu:r66023 (trunk): Embed the Emoji version

nobu	2018-11-27 15:44:02 +0900 (Tue, 27 Nov 2018)

  New Revision: 66023

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66023

  Log:
    Embed the Emoji version

  Modified files:
    trunk/enc/unicode/10.0.0/name2ctype.h
    trunk/tool/enc-unicode.rb
Index: tool/enc-unicode.rb
===================================================================
--- tool/enc-unicode.rb	(revision 66022)
+++ tool/enc-unicode.rb	(revision 66023)
@@ -18,7 +18,11 @@ unless ARGV.size == 2 https://github.com/ruby/ruby/blob/trunk/tool/enc-unicode.rb#L18
   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 https://github.com/ruby/ruby/blob/trunk/tool/enc-unicode.rb#L311
 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, unsigne https://github.com/ruby/ruby/blob/trunk/tool/enc-unicode.rb#L526
   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
Index: enc/unicode/10.0.0/name2ctype.h
===================================================================
--- enc/unicode/10.0.0/name2ctype.h	(revision 66022)
+++ enc/unicode/10.0.0/name2ctype.h	(revision 66023)
@@ -38381,3 +38381,12 @@ uniname2ctype(const UChar *name, unsigne https://github.com/ruby/ruby/blob/trunk/enc/unicode/10.0.0/name2ctype.h#L38381
 #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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]