diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-20 03:42:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-20 03:42:42 +0000 |
commit | f61265746e54ad1706e382630679a855d919d6c0 (patch) | |
tree | d0c10c06291a77d22c7c272a049ffa2244178774 /tool | |
parent | 80de9591c945891ce736e34711491a87b003d76a (diff) |
tool/unicode_norm_gen.rb: for 1.8.5 BASERUBY
* tool/unicode_norm_gen.rb: get rid of new features for 1.8.5
BASERUBY.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r-- | tool/unicode_norm_gen.rb | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tool/unicode_norm_gen.rb b/tool/unicode_norm_gen.rb index b2991d6bd7..b728abbf49 100644 --- a/tool/unicode_norm_gen.rb +++ b/tool/unicode_norm_gen.rb @@ -24,10 +24,14 @@ end class Array def line_slice(new_line) # joins items, 8 items per line - each_slice(8).collect(&:join).join(new_line).gsub(/ +$/, '') + ary = [] + 0.step(size-1, 8) {|i| + ary << self[i, 8].join('') + } + ary.join(new_line).gsub(/ +$/, '') end - def to_UTF8() collect(&:to_UTF8).join end + def to_UTF8() collect {|c| c.to_UTF8}.join('') end def to_regexp_chars # converts an array of Integers to character ranges sort.inject([]) do |ranges, value| @@ -59,8 +63,9 @@ class Hash end # read the file 'CompositionExclusions.txt' -composition_exclusions = IO.readlines("#{InputDataDir}/CompositionExclusions.txt"). - grep(/^[A-Z0-9]{4,5}/) {|line| line.split(' ').first.hex} +composition_exclusions = File.open("#{InputDataDir}/CompositionExclusions.txt") {|f| + f.grep(/^[A-Z0-9]{4,5}/) {|line| line.hex} +} decomposition_table = {} kompatible_table = {} @@ -72,9 +77,9 @@ IO.foreach("#{InputDataDir}/UnicodeData.txt") do |line| case decomposition when /^[0-9A-F]/ - decomposition_table[codepoint.hex] = decomposition.split(' ').collect(&:hex) + decomposition_table[codepoint.hex] = decomposition.split(' ').collect {|w| w.hex} when /^</ - kompatible_table[codepoint.hex] = decomposition.split(' ').drop(1).collect(&:hex) + kompatible_table[codepoint.hex] = decomposition.split(' ')[1..-1].collect {|w| w.hex} end CombiningClass[codepoint.hex] = char_class.to_i if char_class != "0" @@ -94,11 +99,12 @@ end.invert # recalculate composition_exclusions composition_exclusions = decomposition_table.keys - composition_table.values -accent_array = CombiningClass.keys + composition_table.keys.collect(&:last) +accent_array = CombiningClass.keys + composition_table.keys.collect {|key| key.last} -composition_starters = composition_table.keys.collect(&:first) +composition_starters = composition_table.keys.collect {|key| key.first} -hangul_no_trailing = 0xAC00.step(0xD7A3, 28).to_a +hangul_no_trailing = [] +0xAC00.step(0xD7A3, 28) {|c| hangul_no_trailing << c} # expand decomposition table values decomposition_table.each do |key, value| |