ruby-changes:44902
From: duerst <ko1@a...>
Date: Sun, 4 Dec 2016 10:17:40 +0900 (JST)
Subject: [ruby-changes:44902] duerst:r56975 (trunk): Reorder codepoints in some entries of CaseUnfold_11_Table
duerst 2016-12-04 10:17:34 +0900 (Sun, 04 Dec 2016) New Revision: 56975 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56975 Log: Reorder codepoints in some entries of CaseUnfold_11_Table * enc/unicode/case-folding.rb: Reorder codepoints so that the upper-case mapping comes first. * enc/unicode/9.0.0/casefold.h: Codepoints reordered, upper-case mapping flag added. Modified files: trunk/enc/unicode/9.0.0/casefold.h trunk/enc/unicode/case-folding.rb Index: enc/unicode/case-folding.rb =================================================================== --- enc/unicode/case-folding.rb (revision 56974) +++ enc/unicode/case-folding.rb (revision 56975) @@ -16,15 +16,20 @@ class CaseFolding https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L16 module_function def hex_seq(v) - v.map {|i| "0x%04x" % i}.join(", ") + v.map { |i| "0x%04x" % i }.join(", ") end 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) - ck = cv = '' - ck = ' /* ' + Array(k).pack("U*") + ' */' if @debug - cv = ' /* ' + Array(v).map{|c|[c].pack("U*")}.join(", ") + ' */' if @debug + if type=='CaseUnfold_11' and v.length>1 + # reorder CaseUnfold_11 entries to avoid special treatment for U+03B9/U+03BC/U+A64B + item = mapping_data.map("%04X" % k[0]) + upper = item.upper if item + v = v.sort_by { |i| ("%04X"%i) == upper ? 0 : 1 } + end + ck = @debug ? ' /* ' + Array(k).pack("U*") + ' */' : '' + cv = @debug ? ' /* ' + Array(v).map{|c|[c].pack("U*")}.join(", ") + ' */' : '' dest.print(" {#{sk}#{ck}, {#{v.length}#{mapping_data.flags(k, type, v)}, {#{hex_seq(v)}#{cv}}}},\n") end data @@ -249,12 +254,16 @@ class CaseMapping https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L254 end end + def map (from) + @mappings[from] + end + def flags(from, type, to) # types: CaseFold_11, CaseUnfold_11, CaseUnfold_12, CaseUnfold_13 flags = "" from = Array(from).map {|i| "%04X" % i}.join(" ") to = Array(to).map {|i| "%04X" % i}.join(" ") - item = @mappings[from] + item = map(from) specials_index = nil specials = [] case type Index: enc/unicode/9.0.0/casefold.h =================================================================== --- enc/unicode/9.0.0/casefold.h (revision 56974) +++ enc/unicode/9.0.0/casefold.h (revision 56975) @@ -3851,10 +3851,10 @@ static const CaseUnfold_11_Type CaseUnfo https://github.com/ruby/ruby/blob/trunk/enc/unicode/9.0.0/casefold.h#L3851 {0x03b6, {1|U, {0x0396}}}, {0x03b7, {1|U, {0x0397}}}, {0x03b8, {3|U, {0x0398, 0x03d1, 0x03f4}}}, - {0x03b9, {3, {0x0345, 0x0399, 0x1fbe}}}, + {0x03b9, {3|U, {0x0399, 0x0345, 0x1fbe}}}, {0x03ba, {2|U, {0x039a, 0x03f0}}}, {0x03bb, {1|U, {0x039b}}}, - {0x03bc, {2, {0x00b5, 0x039c}}}, + {0x03bc, {2|U, {0x039c, 0x00b5}}}, {0x03bd, {1|U, {0x039d}}}, {0x03be, {1|U, {0x039e}}}, {0x03bf, {1|U, {0x039f}}}, @@ -4552,7 +4552,7 @@ static const CaseUnfold_11_Type CaseUnfo https://github.com/ruby/ruby/blob/trunk/enc/unicode/9.0.0/casefold.h#L4552 {0xa645, {1|U, {0xa644}}}, {0xa647, {1|U, {0xa646}}}, {0xa649, {1|U, {0xa648}}}, - {0xa64b, {2, {0x1c88, 0xa64a}}}, + {0xa64b, {2|U, {0xa64a, 0x1c88}}}, {0xa64d, {1|U, {0xa64c}}}, {0xa64f, {1|U, {0xa64e}}}, {0xa651, {1|U, {0xa650}}}, -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/