Skip to content

Commit

Permalink
Reorder codepoints in some entries of CaseUnfold_11_Table
Browse files Browse the repository at this point in the history
* 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:https://ci.ruby-lang.org/ruby/trunk@56975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
duerst committed Dec 4, 2016
1 parent 1fa8bd7 commit 31fb4e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 3 additions & 3 deletions enc/unicode/9.0.0/casefold.h
Original file line number Diff line number Diff line change
Expand Up @@ -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}}},
Expand Down Expand Up @@ -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}}},
Expand Down
19 changes: 14 additions & 5 deletions enc/unicode/case-folding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ module Util
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
Expand Down Expand Up @@ -249,12 +254,16 @@ def initialize(mapping_directory)
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
Expand Down

0 comments on commit 31fb4e3

Please sign in to comment.