зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
49079911ba
Коммит
c3554cdea6
|
@ -1,3 +1,8 @@
|
|||
Mon Feb 15 14:43:28 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* enc/unicode/case-folding.rb: Added debugging option
|
||||
(with Kimihito Matsui)
|
||||
|
||||
Sun Feb 14 17:31:50 2016 Lars Kanis <lars@greiz-reinsdorf.de>
|
||||
|
||||
* lib/mkmf.rb (with_{cpp,c,ld}flags): copy caller strings not to
|
||||
|
@ -87,7 +92,7 @@ Mon Feb 8 20:43:57 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
|||
|
||||
* string.c, enc/unicode.c: Disassociating ONIGENC_CASE_FOLD flag from
|
||||
ONIGENC_CASE_DOWNCASE.
|
||||
(with Kimihito Matsui)
|
||||
(with Kimihito Matsui)
|
||||
|
||||
Mon Feb 8 13:00:17 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
|
@ -133,7 +138,6 @@ Sun Feb 7 11:44:03 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
|||
to pass as parameters; not yet implemented or used.
|
||||
(with Kimihito Matsui)
|
||||
|
||||
|
||||
Sun Feb 7 11:16:00 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* common.mk: using new option in recipe for enc/unicode/casefold.h
|
||||
|
|
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче