[latex3-commits] [git/LaTeX3-latex3-luaotfload] dev: Use lua-uni-algos for case folding (b6d65e6)

Marcel Fabian Krüger tex at 2krueger.de
Wed May 11 12:53:17 CEST 2022


Repository : https://github.com/latex3/luaotfload
On branch  : dev
Link       : https://github.com/latex3/luaotfload/commit/b6d65e665433a20091241cdfeb8ead971ce8f664

>---------------------------------------------------------------

commit b6d65e665433a20091241cdfeb8ead971ce8f664
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Wed May 11 12:52:35 2022 +0200

    Use lua-uni-algos for case folding


>---------------------------------------------------------------

b6d65e665433a20091241cdfeb8ead971ce8f664
 src/luaotfload-database.lua |  2 +-
 src/luaotfload-unicode.lua  | 41 -----------------------------------------
 2 files changed, 1 insertion(+), 42 deletions(-)

diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index dd42929..7b8aa38 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -201,7 +201,7 @@ local resolversfindfile        = context_environment.resolvers.findfile
 
 --- some of our own
 local unicode                  = require'luaotfload-unicode'
-local casefold                 = unicode.casefold
+local casefold                 = require'lua-uni-case'.casefold
 local alphnum_only             = unicode.alphnum_only
 
 local name_index               = nil --> upvalue for names.data
diff --git a/src/luaotfload-unicode.lua b/src/luaotfload-unicode.lua
index 65f16c8..d46f2f5 100644
--- a/src/luaotfload-unicode.lua
+++ b/src/luaotfload-unicode.lua
@@ -23,46 +23,6 @@ local codepoint = lpeg.S'0123456789ABCDEF'^4/function(c)return tonumber(c, 16)en
 local empty = {}
 local result = {}
 
-local casefold do
-  local nl = ('#' * (1-lpeg.P'\n')^0)^-1 * '\n'
-  local entry = codepoint * "; " * lpeg.C(1) * ";" * lpeg.Ct((' ' * codepoint)^1) * "; " * nl
-  local file = lpeg.Cf(
-      lpeg.Ct(
-          lpeg.Cg(lpeg.Ct"", "C")
-        * lpeg.Cg(lpeg.Ct"", "F")
-        * lpeg.Cg(lpeg.Ct"", "S")
-        * lpeg.Cg(lpeg.Ct"", "T"))
-    * nl^0 * lpeg.Cg(entry)^0 * nl^0 * -1
-  , function(t, base, class, mapping)
-    rawset(rawget(t, class), base, mapping)
-    return t
-  end)
-
-  local f = io.open(kpse.find_file"CaseFolding.txt")
-  local data = file:match(f:read'*a')
-  f:close()
-  function casefold(s, full, special)
-    local first = special and data.T or empty
-    local second = data.C
-    local third = full and data.F or data.S
-    local result = result
-    for i = #result, 1, -1 do result[i] = nil end
-    local i = 1
-    for _, c in utf8codes(s) do
-      local datum = first[c] or second[c] or third[c]
-      if datum then
-        local l = #datum
-        move(datum, 1, l, i, result)
-        i = i + l
-      else
-        result[i] = c
-        i = i + 1
-      end
-    end
-    return utf8char(unpack(result))
-  end
-end
-
 local alphnum_only do
   local niceentry = lpeg.Cg(codepoint * ';' * (1-lpeg.P';')^0 * ';' * lpeg.S'LN' * lpeg.Cc(true))
   local entry = niceentry^0 * (1-lpeg.P'\n')^0 * lpeg.P'\n'
@@ -284,7 +244,6 @@ uppercase[0x0587]['hy'] = { _ = { 0x0535, 0x054E } }
 uppercase[0x0587]['hy-x-yiwn'] = { _ = uppercase[0x0587]._ }
 
 return {
-  casefold = casefold,
   alphnum_only = alphnum_only,
   casemapping = {
     uppercase = uppercase,





More information about the latex3-commits mailing list.