mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
80de9591c9
commit
f61265746e
1 changed files with 15 additions and 9 deletions
|
@ -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|
|
||||
|
|
Loading…
Reference in a new issue