summaryrefslogtreecommitdiff
path: root/enc/unicode
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-15 05:43:55 (GMT)
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-15 05:43:55 (GMT)
commitc3554cdea6a1a4993034e1846546d9cb4c0a933d (patch)
tree31e37ffb3ac2ea3c029269365a029d05e92b4217 /enc/unicode
parent49079911ba45098a7d3f910bb4bf0e0bcc9dad49 (diff)
* enc/unicode/case-folding.rb: Added debugging option
(with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode')
-rwxr-xr-xenc/unicode/case-folding.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb
index dddc366..c8c9710 100755
--- a/enc/unicode/case-folding.rb
+++ b/enc/unicode/case-folding.rb
@@ -8,6 +8,7 @@
# $ wget http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
# $ wget http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt
# $ ruby case-folding.rb -m . -o casefold.h
+# using -d or --debug will include UTF-8 characters in comments for debugging
class CaseFolding
module Util
@@ -20,7 +21,10 @@ class CaseFolding
def print_table_1(dest, type, mapping_data, data)
for k, v in data = data.sort
sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k)
- dest.print(" {#{sk}, {#{v.length}#{mapping_data.flags(k, type, v)}, {#{hex_seq(v)}}}},\n")
+ ck = cv = ''
+ ck = ' /* ' + Array(k).pack("U*") + ' */' if @debug
+ cv = ' /* ' + Array(v).map{|c|[c].pack("U*")}.join(", ") + ' */' if @debug
+ dest.print(" {#{sk}#{ck}, {#{v.length}#{mapping_data.flags(k, type, v)}, {#{hex_seq(v)}#{cv}}}},\n")
end
data
end
@@ -47,6 +51,7 @@ class CaseFolding
@fold = fold = {}
@unfold = unfold = [{}, {}, {}]
+ @debug = false
turkic = []
IO.foreach(filename) do |line|
@@ -172,6 +177,10 @@ class CaseFolding
dest.print lookup_hash(name, "CodePointList2", data)
end
+ def debug!
+ @debug = true
+ end
+
def self.load(*args)
new.load(*args)
end
@@ -237,6 +246,7 @@ if $0 == __FILE__
dest = nil
mapping_directory = nil
mapping_data = nil
+ debug = false
fold_1 = false
ARGV.options do |opt|
opt.banner << " [INPUT]"
@@ -246,6 +256,9 @@ if $0 == __FILE__
opt.on('--mapping-data-directory=DIRECTORY', '-m', 'data DIRECTORY of mapping files') { |directory|
mapping_directory = directory
}
+ opt.on('--debug', '-d') {
+ debug = true
+ }
opt.parse!
abort(opt.to_s) if ARGV.size > 1
end
@@ -261,6 +274,7 @@ if $0 == __FILE__
mapping_data ||= CaseMappingDummy.new
data = CaseFolding.load(filename)
+ data.debug! if debug
if dest
open(dest, "wb") do |f|
data.display(f, mapping_data)