mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enc/unicode/case-folding.rb: Fixing parameter passing.
(with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5cbe9fe5c4
commit
e40d117339
2 changed files with 20 additions and 15 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Feb 7 14:12:32 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
|
* enc/unicode/case-folding.rb: Fixing parameter passing.
|
||||||
|
(with Kimihito Matsui)
|
||||||
|
|
||||||
Sun Feb 7 11:44:03 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
Sun Feb 7 11:44:03 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||||
|
|
||||||
* enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy
|
* enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy
|
||||||
|
|
|
@ -15,21 +15,21 @@ class CaseFolding
|
||||||
v.map {|i| "0x%04x" % i}.join(", ")
|
v.map {|i| "0x%04x" % i}.join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_table_1(dest, data)
|
def print_table_1(dest, mapping_data, data)
|
||||||
for k, v in data = data.sort
|
for k, v in data = data.sort
|
||||||
sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k)
|
sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k)
|
||||||
dest.print(" {#{sk}, {#{v.length}, {#{hex_seq(v)}}}},\n")
|
dest.print(" {#{sk}, {#{v.length}#{mapping_data.flags(k)}, {#{hex_seq(v)}}}},\n")
|
||||||
end
|
end
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_table(dest, type, data)
|
def print_table(dest, type, mapping_data, data)
|
||||||
dest.print("static const #{type}_Type #{type}_Table[] = {\n")
|
dest.print("static const #{type}_Type #{type}_Table[] = {\n")
|
||||||
i = 0
|
i = 0
|
||||||
ret = data.inject([]) do |a, (n, d)|
|
ret = data.inject([]) do |a, (n, d)|
|
||||||
dest.print("#define #{n} (*(#{type}_Type (*)[#{d.size}])(#{type}_Table+#{i}))\n")
|
dest.print("#define #{n} (*(#{type}_Type (*)[#{d.size}])(#{type}_Table+#{i}))\n")
|
||||||
i += d.size
|
i += d.size
|
||||||
a.concat(print_table_1(dest, d))
|
a.concat(print_table_1(dest, mapping_data, d))
|
||||||
end
|
end
|
||||||
dest.print("};\n\n")
|
dest.print("};\n\n")
|
||||||
ret
|
ret
|
||||||
|
@ -85,7 +85,7 @@ class CaseFolding
|
||||||
"#{code} <= MAX_CODE_VALUE && #{code} >= MIN_CODE_VALUE"
|
"#{code} <= MAX_CODE_VALUE && #{code} >= MIN_CODE_VALUE"
|
||||||
end
|
end
|
||||||
|
|
||||||
def lookup_hash(key, type, data, mapping_data)
|
def lookup_hash(key, type, data)
|
||||||
hash = "onigenc_unicode_#{key}_hash"
|
hash = "onigenc_unicode_#{key}_hash"
|
||||||
lookup = "onigenc_unicode_#{key}_lookup"
|
lookup = "onigenc_unicode_#{key}_lookup"
|
||||||
arity = Array(data[0][0]).size
|
arity = Array(data[0][0]).size
|
||||||
|
@ -149,25 +149,25 @@ class CaseFolding
|
||||||
|
|
||||||
# CaseFold + CaseFold_Locale
|
# CaseFold + CaseFold_Locale
|
||||||
name = "CaseFold_11"
|
name = "CaseFold_11"
|
||||||
data = print_table(dest, name, "CaseFold"=>fold, "CaseFold_Locale"=>fold_locale)
|
data = print_table(dest, name, mapping_data, "CaseFold"=>fold, "CaseFold_Locale"=>fold_locale)
|
||||||
dest.print lookup_hash(name, "CodePointList3", data, mapping_data)
|
dest.print lookup_hash(name, "CodePointList3", data)
|
||||||
|
|
||||||
# print unfolding data
|
# print unfolding data
|
||||||
|
|
||||||
# CaseUnfold_11 + CaseUnfold_11_Locale
|
# CaseUnfold_11 + CaseUnfold_11_Locale
|
||||||
name = "CaseUnfold_11"
|
name = "CaseUnfold_11"
|
||||||
data = print_table(dest, name, name=>unfold[0], "#{name}_Locale"=>unfold_locale[0])
|
data = print_table(dest, name, mapping_data, name=>unfold[0], "#{name}_Locale"=>unfold_locale[0])
|
||||||
dest.print lookup_hash(name, "CodePointList3", data, mapping_data)
|
dest.print lookup_hash(name, "CodePointList3", data)
|
||||||
|
|
||||||
# CaseUnfold_12 + CaseUnfold_12_Locale
|
# CaseUnfold_12 + CaseUnfold_12_Locale
|
||||||
name = "CaseUnfold_12"
|
name = "CaseUnfold_12"
|
||||||
data = print_table(dest, name, name=>unfold[1], "#{name}_Locale"=>unfold_locale[1])
|
data = print_table(dest, name, mapping_data, name=>unfold[1], "#{name}_Locale"=>unfold_locale[1])
|
||||||
dest.print lookup_hash(name, "CodePointList2", data, mapping_data)
|
dest.print lookup_hash(name, "CodePointList2", data)
|
||||||
|
|
||||||
# CaseUnfold_13
|
# CaseUnfold_13
|
||||||
name = "CaseUnfold_13"
|
name = "CaseUnfold_13"
|
||||||
data = print_table(dest, name, name=>unfold[2])
|
data = print_table(dest, name, mapping_data, name=>unfold[2])
|
||||||
dest.print lookup_hash(name, "CodePointList2", data, mapping_data)
|
dest.print lookup_hash(name, "CodePointList2", data)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load(*args)
|
def self.load(*args)
|
||||||
|
@ -179,7 +179,7 @@ class CaseMapping
|
||||||
def initialize (mapping_directory)
|
def initialize (mapping_directory)
|
||||||
end
|
end
|
||||||
|
|
||||||
def mapping_flags(from)
|
def flags(from)
|
||||||
"" # preliminary implementation
|
"" # preliminary implementation
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ class CaseMapping
|
||||||
end
|
end
|
||||||
|
|
||||||
class CaseMappingDummy
|
class CaseMappingDummy
|
||||||
def mapping_flags(from)
|
def flags(from)
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue