diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-05-03 13:55:34 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2014-05-03 13:55:34 +0200 |
commit | 624cbb5da392e9403984dd1cf368c0d408b1c2a8 (patch) | |
tree | 489c049ac849bb5bbce7d32e4df477872c58373d /tex/context/base/sort-ini.lua | |
parent | 088de88944c1f2254250bb448c7371a87ff7ee39 (diff) | |
download | context-624cbb5da392e9403984dd1cf368c0d408b1c2a8.tar.gz |
2014-01-03 00:42:00
Diffstat (limited to 'tex/context/base/sort-ini.lua')
-rw-r--r-- | tex/context/base/sort-ini.lua | 54 |
1 files changed, 15 insertions, 39 deletions
diff --git a/tex/context/base/sort-ini.lua b/tex/context/base/sort-ini.lua index d279f1253..479d1c489 100644 --- a/tex/context/base/sort-ini.lua +++ b/tex/context/base/sort-ini.lua @@ -82,7 +82,7 @@ local v_first = variables.first local v_last = variables.last local validmethods = table.tohash { - "ch", -- raw character (for tracing) + -- "ch", -- raw character "mm", -- minus mapping "zm", -- zero mapping "pm", -- plus mapping @@ -120,7 +120,7 @@ local sorters = sorters local constants = sorters.constants local data, language, method, digits -local replacements, m_mappings, z_mappings, p_mappings, entries, orders, lower, upper, method, sequence, usedinsequence +local replacements, m_mappings, z_mappings, p_mappings, entries, orders, lower, upper, method, sequence local thefirstofsplit local mte = { -- todo: assign to t @@ -334,9 +334,6 @@ local function setlanguage(l,m,d,u) end end data.sequence = sequence - usedinsequence = table.tohash(sequence) - data.usedinsequence = usedinsequence --- usedinsequence.ch = true -- better just store the string if trace_tests then report_sorters("using sort sequence: % t",sequence) end @@ -375,9 +372,7 @@ local function basicsort(sort_a,sort_b) return 0 end --- todo: compile compare function - -local function basic(a,b) -- trace ea and eb +function comparers.basic(a,b) -- trace ea and eb local ea, eb = a.split, b.split local na, nb = #ea, #eb if na == 0 and nb == 0 then @@ -437,12 +432,6 @@ local function basic(a,b) -- trace ea and eb end end -comparers.basic = basic - -function sorters.basicsorter(a,b) - return basic(a,b) == -1 -end - local function numify(s) s = digitsoffset + tonumber(s) -- alternatively we can create range if s > digitsmaximum then @@ -488,7 +477,7 @@ sorters.firstofsplit = firstofsplit -- for the moment we use an inefficient bunch of tables but once -- we know what combinations make sense we can optimize this -function splitters.utf(str,checked) -- we could append m and u but this is cleaner, s is for tracing +function splitters.utf(str) -- we could append m and u but this is cleaner, s is for tracing if #replacements > 0 then -- todo make an lpeg for this for k=1,#replacements do @@ -591,31 +580,18 @@ function splitters.utf(str,checked) -- we could append m and u but this is clean -- p_mapping = { p_mappings[fs][1] } -- end -- end + local t = { + ch = char, + uc = byte, + mc = m_case, + zc = z_case, + pc = p_case, + mm = m_mapping, + zm = z_mapping, + pm = p_mapping, + } - if checked then - return { - ch = trace_tests and char or nil, -- not in sequence - uc = usedinsequence.uc and byte or nil, - mc = usedinsequence.mc and m_case or nil, - zc = usedinsequence.zc and z_case or nil, - pc = usedinsequence.pc and p_case or nil, - mm = usedinsequence.mm and m_mapping or nil, - zm = usedinsequence.zm and z_mapping or nil, - pm = usedinsequence.pm and p_mapping or nil, - } - else - return { - ch = char, - uc = byte, - mc = m_case, - zc = z_case, - pc = p_case, - mm = m_mapping, - zm = z_mapping, - pm = p_mapping, - } - end - + return t end local function packch(entry) |