1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

unicode_norm_gen.rb: freeze

* tool/unicode_norm_gen.rb: freeze strings and tables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-10-06 03:08:25 +00:00
parent 2b6fa9eb0d
commit e14440e544

View file

@ -23,8 +23,8 @@ class Integer
end end
class Array class Array
def line_slice (new_line) # joins items, 16 items per line def line_slice(new_line) # joins items, 8 items per line
each_slice(16).collect(&:join).join new_line each_slice(8).collect(&:join).join(new_line).gsub(/ +$/, '')
end end
def to_UTF8() collect(&:to_UTF8).join end def to_UTF8() collect(&:to_UTF8).join end
@ -53,7 +53,7 @@ end
class Hash class Hash
def to_hash_string def to_hash_string
collect do |key, value| collect do |key, value|
"\"#{key.to_UTF8}\"=>\"#{value.to_UTF8}\", " "\"#{key.to_UTF8}\"=>\"#{value.to_UTF8}\".freeze, "
end.line_slice "\n " end.line_slice "\n "
end end
end end
@ -143,7 +143,7 @@ open("#{OuputDataDir}/normalize_tables.rb", "w").print <<MAPPING_TABLE_FILE_END
module Normalize module Normalize
accents = "" \\ accents = "" \\
"[#{accent_array.to_regexp_chars}]" \\ "[#{accent_array.to_regexp_chars}]" \\
"" "".freeze
ACCENTS = accents ACCENTS = accents
REGEXP_D_STRING = "\#{'' # composition starters and composition exclusions REGEXP_D_STRING = "\#{'' # composition starters and composition exclusions
}" \\ }" \\
@ -154,7 +154,7 @@ module Normalize
"|\#{'' # precomposed Hangul syllables "|\#{'' # precomposed Hangul syllables
}" \\ }" \\
"[\\u{AC00}-\\u{D7A4}]" \\ "[\\u{AC00}-\\u{D7A4}]" \\
"" "".freeze
REGEXP_C_STRING = "\#{'' # composition exclusions REGEXP_C_STRING = "\#{'' # composition exclusions
}" \\ }" \\
"[#{composition_exclusions.to_regexp_chars}]\#{accents}*" \\ "[#{composition_exclusions.to_regexp_chars}]\#{accents}*" \\
@ -167,27 +167,27 @@ module Normalize
"|\#{'' # decomposed Hangul syllables "|\#{'' # decomposed Hangul syllables
}" \\ }" \\
"[\\u1100-\\u1112][\\u1161-\\u1175][\\u11A8-\\u11C2]?" \\ "[\\u1100-\\u1112][\\u1161-\\u1175][\\u11A8-\\u11C2]?" \\
"" "".freeze
REGEXP_K_STRING = "" \\ REGEXP_K_STRING = "" \\
"[#{kompatible_table.keys.to_regexp_chars}]" \\ "[#{kompatible_table.keys.to_regexp_chars}]" \\
"" "".freeze
class_table = { class_table = {
#{class_table_str} #{class_table_str}
} }
class_table.default = 0 class_table.default = 0
CLASS_TABLE = class_table CLASS_TABLE = class_table.freeze
DECOMPOSITION_TABLE = { DECOMPOSITION_TABLE = {
#{decomposition_table.to_hash_string} #{decomposition_table.to_hash_string}
} }.freeze
KOMPATIBLE_TABLE = { KOMPATIBLE_TABLE = {
#{kompatible_table.to_hash_string} #{kompatible_table.to_hash_string}
} }.freeze
COMPOSITION_TABLE = { COMPOSITION_TABLE = {
#{composition_table.to_hash_string} #{composition_table.to_hash_string}
} }.freeze
end end
MAPPING_TABLE_FILE_END MAPPING_TABLE_FILE_END