From f61265746e54ad1706e382630679a855d919d6c0 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 20 Oct 2014 03:42:42 +0000 Subject: [PATCH] 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 --- tool/unicode_norm_gen.rb | 24 +++++++++++++++--------- 1 file 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 /^