From 31fb4e3ec387da3764bea4772858cad55c504a28 Mon Sep 17 00:00:00 2001 From: duerst Date: Sun, 4 Dec 2016 01:17:34 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enc/unicode/9.0.0/casefold.h | 6 +++--- enc/unicode/case-folding.rb | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'enc/unicode') diff --git a/enc/unicode/9.0.0/casefold.h b/enc/unicode/9.0.0/casefold.h index 5383d251aa..9deac0469e 100644 --- a/enc/unicode/9.0.0/casefold.h +++ b/enc/unicode/9.0.0/casefold.h @@ -3851,10 +3851,10 @@ static const CaseUnfold_11_Type CaseUnfold_11_Table[] = { {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 CaseUnfold_11_Table[] = { {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}}}, diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb index 687887b9f9..aa6c6d5aba 100755 --- a/enc/unicode/case-folding.rb +++ b/enc/unicode/case-folding.rb @@ -16,15 +16,20 @@ class CaseFolding 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 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 -- cgit v1.2.3