summaryrefslogtreecommitdiff
path: root/enc/unicode
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-07 02:44:14 (GMT)
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-07 02:44:14 (GMT)
commit5cbe9fe5c4c1a8f9a077663cd3e754dc89b39b59 (patch)
treef0d2c8ae6a83e2b0711162467d6d2c83c28f660c /enc/unicode
parent3890bb60a92918af998456359a0db642250fa13e (diff)
* enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy
to pass as parameters; not yet implemented or used. (with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode')
-rwxr-xr-xenc/unicode/case-folding.rb37
1 files changed, 29 insertions, 8 deletions
diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb
index 6f801cc..68275c7 100755
--- a/enc/unicode/case-folding.rb
+++ b/enc/unicode/case-folding.rb
@@ -85,7 +85,7 @@ class CaseFolding
"#{code} <= MAX_CODE_VALUE && #{code} >= MIN_CODE_VALUE"
end
- def lookup_hash(key, type, data)
+ def lookup_hash(key, type, data, mapping_data)
hash = "onigenc_unicode_#{key}_hash"
lookup = "onigenc_unicode_#{key}_lookup"
arity = Array(data[0][0]).size
@@ -140,7 +140,7 @@ class CaseFolding
src
end
- def display(dest)
+ def display(dest, mapping_data)
# print the header
dest.print("/* DO NOT EDIT THIS FILE. */\n")
dest.print("/* Generated by enc/unicode/case-folding.rb */\n\n")
@@ -150,24 +150,24 @@ class CaseFolding
# CaseFold + CaseFold_Locale
name = "CaseFold_11"
data = print_table(dest, name, "CaseFold"=>fold, "CaseFold_Locale"=>fold_locale)
- dest.print lookup_hash(name, "CodePointList3", data)
+ dest.print lookup_hash(name, "CodePointList3", data, mapping_data)
# print unfolding data
# CaseUnfold_11 + CaseUnfold_11_Locale
name = "CaseUnfold_11"
data = print_table(dest, name, name=>unfold[0], "#{name}_Locale"=>unfold_locale[0])
- dest.print lookup_hash(name, "CodePointList3", data)
+ dest.print lookup_hash(name, "CodePointList3", data, mapping_data)
# CaseUnfold_12 + CaseUnfold_12_Locale
name = "CaseUnfold_12"
data = print_table(dest, name, name=>unfold[1], "#{name}_Locale"=>unfold_locale[1])
- dest.print lookup_hash(name, "CodePointList2", data)
+ dest.print lookup_hash(name, "CodePointList2", data, mapping_data)
# CaseUnfold_13
name = "CaseUnfold_13"
data = print_table(dest, name, name=>unfold[2])
- dest.print lookup_hash(name, "CodePointList2", data)
+ dest.print lookup_hash(name, "CodePointList2", data, mapping_data)
end
def self.load(*args)
@@ -175,6 +175,25 @@ class CaseFolding
end
end
+class CaseMapping
+ def initialize (mapping_directory)
+ end
+
+ def mapping_flags(from)
+ "" # preliminary implementation
+ end
+
+ def self.load(*args)
+ new(*args)
+ end
+end
+
+class CaseMappingDummy
+ def mapping_flags(from)
+ ""
+ end
+end
+
if $0 == __FILE__
require 'optparse'
dest = nil
@@ -198,15 +217,17 @@ if $0 == __FILE__
exit
end
filename = File.expand_path("CaseFolding.txt", mapping_directory)
+ mapping_data = CaseMapping.load(mapping_directory)
end
filename ||= ARGV[0] || 'CaseFolding.txt'
+ mapping_data ||= CaseMappingDummy.new
data = CaseFolding.load(filename)
if dest
open(dest, "wb") do |f|
- data.display(f)
+ data.display(f, mapping_data)
end
else
- data.display(STDOUT)
+ data.display(STDOUT, mapping_data)
end
end