summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-30 17:29:19 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-30 17:29:19 +0000
commitc11e648799cf32d267875381d967e8228a07cea6 (patch)
treea138fea7cd605c02139800096905c5249bef8e27 /tool
parente680bfb1aba5438d5f0912b0712e5eb7d96239e0 (diff)
Regexp supports Unicoe 9.0.0's \X
* meta character \X matches Unicode 9.0.0 characters with some workarounds for UTR #51 Unicode Emoji, Version 4.0 emoji zwj sequences. [Feature #12831] [ruby-core:77586] The term "character" can have many meanings bytes, codepoints, combined characters, and so on. "grapheme cluster" is highest one of such words, which means user-perceived characters. Unicode Standard Annex #29 UNICODE TEXT SEGMENTATION specifies how to handle grapheme clusters (extended grapheme cluster). But some specs aren't updated to current situation because Unicode Emoji is rapidly extended without well definition. It breaks the precondition of UTR#29 "Grapheme cluster boundaries can be easily tested by looking at immediately adjacent characters". (the sentence will be removed in the next version) Though some of its detail are described in Unicode Technical Report #51 UNICODE EMOJI but it is not merged into UTR#29 yet. http://unicode.org/reports/tr29/ http://unicode.org/reports/tr51/ http://unicode.org/Public/emoji/4.0/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r--tool/downloader.rb8
-rwxr-xr-xtool/enc-unicode.rb36
2 files changed, 40 insertions, 4 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index 6c34f73..d4f958e 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -228,7 +228,13 @@ if $0 == __FILE__
dl = Downloader.const_get(dl)
ARGV.shift
ARGV.each do |name|
- name = "#{prefix}/#{File.basename(name)}" if prefix
+ if prefix
+ if name.include?('/auxiliary/')
+ name = "#{prefix}/auxiliary/#{File.basename(name)}"
+ else
+ name = "#{prefix}/#{File.basename(name)}"
+ end
+ end
dl.download(name, destdir, since, options)
end
else
diff --git a/tool/enc-unicode.rb b/tool/enc-unicode.rb
index 83bbe35..0e3ba47 100755
--- a/tool/enc-unicode.rb
+++ b/tool/enc-unicode.rb
@@ -144,7 +144,7 @@ def parse_scripts(data, categories)
categories[current] = file[:title]
(names[file[:title]] ||= []) << current
cps = []
- elsif /^([0-9a-fA-F]+)(?:..([0-9a-fA-F]+))?\s*;\s*(\w+)/ =~ line
+ elsif /^([0-9a-fA-F]+)(?:\.\.([0-9a-fA-F]+))?\s*;\s*(\w+)/ =~ line
current = $3
$2 ? cps.concat(($1.to_i(16)..$2.to_i(16)).to_a) : cps.push($1.to_i(16))
end
@@ -199,7 +199,26 @@ def parse_age(data)
ages << current
last_constname = constname
cps = []
- elsif /^([0-9a-fA-F]+)(?:..([0-9a-fA-F]+))?\s*;\s*(\d+\.\d+)/ =~ line
+ elsif /^([0-9a-fA-F]+)(?:\.\.([0-9a-fA-F]+))?\s*;\s*(\d+\.\d+)/ =~ line
+ current = $3
+ $2 ? cps.concat(($1.to_i(16)..$2.to_i(16)).to_a) : cps.push($1.to_i(16))
+ end
+ end
+ ages
+end
+
+def parse_GraphemeBreakProperty(data)
+ current = nil
+ cps = []
+ ages = []
+ data_foreach('GraphemeBreakProperty.txt') do |line|
+ if /^# Total code points: / =~ line
+ constname = constantize_Grapheme_Cluster_Break(current)
+ data[constname] = cps
+ make_const(constname, cps, "Grapheme_Cluster_Break=#{current}")
+ ages << current
+ cps = []
+ elsif /^([0-9a-fA-F]+)(?:\.\.([0-9a-fA-F]+))?\s*;\s*(\w+)/ =~ line
current = $3
$2 ? cps.concat(($1.to_i(16)..$2.to_i(16)).to_a) : cps.push($1.to_i(16))
end
@@ -209,7 +228,6 @@ end
def parse_block(data)
current = nil
- last_constname = nil
cps = []
blocks = []
data_foreach('Blocks.txt') do |line|
@@ -269,6 +287,10 @@ def constantize_agename(name)
"Age_#{name.sub(/\./, '_')}"
end
+def constantize_Grapheme_Cluster_Break(name)
+ "Grapheme_Cluster_Break_#{name}"
+end
+
def constantize_blockname(name)
"In_#{name.gsub(/\W/, '_')}"
end
@@ -381,6 +403,7 @@ end
output.ifdef :USE_UNICODE_AGE_PROPERTIES
ages = parse_age(data)
output.endif :USE_UNICODE_AGE_PROPERTIES
+graphemeBreaks = parse_GraphemeBreakProperty(data)
blocks = parse_block(data)
output.endif :USE_UNICODE_PROPERTIES
puts(<<'__HEREDOC')
@@ -393,6 +416,7 @@ props.each{|name| puts" CR_#{name},"}
output.ifdef :USE_UNICODE_AGE_PROPERTIES
ages.each{|name| puts" CR_#{constantize_agename(name)},"}
output.endif :USE_UNICODE_AGE_PROPERTIES
+graphemeBreaks.each{|name| puts" CR_#{constantize_Grapheme_Cluster_Break(name)},"}
blocks.each{|name|puts" CR_#{name},"}
output.endif :USE_UNICODE_PROPERTIES
@@ -437,6 +461,12 @@ ages.each do |name|
puts "%-40s %3d" % [name + ',', i]
end
output.endif :USE_UNICODE_AGE_PROPERTIES
+graphemeBreaks.each do |name|
+ i += 1
+ name = "graphemeclusterbreak=#{name.delete('_').downcase}"
+ name_to_index[name] = i
+ puts "%-40s %3d" % [name + ',', i]
+end
blocks.each do |name|
i += 1
name = normalize_propname(name)