From ddad52fbcdd8fdcff155009cf9b0d82a32a8a5b6 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 18 May 2020 20:40:58 +0000 Subject: lua-uni-algos (18may20) git-svn-id: svn://tug.org/texlive/trunk@55206 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/luatex/lua-uni-algos/lua-uni-normalize.lua | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'Master/texmf-dist/tex/luatex') diff --git a/Master/texmf-dist/tex/luatex/lua-uni-algos/lua-uni-normalize.lua b/Master/texmf-dist/tex/luatex/lua-uni-algos/lua-uni-normalize.lua index dc1356568cb..4536a1b977b 100644 --- a/Master/texmf-dist/tex/luatex/lua-uni-algos/lua-uni-normalize.lua +++ b/Master/texmf-dist/tex/luatex/lua-uni-algos/lua-uni-normalize.lua @@ -169,8 +169,17 @@ local function ccc_reorder(codepoints, i, j, k) codepoints[new_pos] = first return ccc_reorder(codepoints, i, j, k == i and i or k-1) end +local result_table = {} +local function get_string() + local result_table = result_table + local s = char(unpack(result_table)) + for i=1,#result_table do + result_table[i] = nil + end + return s +end function to_nfd_table(s, decomposition_mapping) - local new_codepoints = newtable(#s, 0) + local new_codepoints = result_table local j = 1 for _, c in codes(s) do local decomposed = decomposition_mapping[c] @@ -197,16 +206,18 @@ function to_nfd_table(s, decomposition_mapping) end end ccc_reorder(new_codepoints, 1, #new_codepoints, 1) - return new_codepoints end local function to_nfd(s) - return char(unpack(to_nfd_table(s, decomposition_mapping))) + to_nfd_table(s, decomposition_mapping) + return get_string() end local function to_nfkd(s) - return char(unpack(to_nfd_table(s, compatibility_mapping))) + to_nfd_table(s, compatibility_mapping) + return get_string() end local function to_nfc_generic(s, decomposition_mapping) - local codepoints = to_nfd_table(s, decomposition_mapping) + to_nfd_table(s, decomposition_mapping) + local codepoints = result_table local starter, lookup, last_ccc, lvt local j = 1 for i, c in ipairs(codepoints) do @@ -222,7 +233,7 @@ local function to_nfc_generic(s, decomposition_mapping) end elseif lvt then if lvt == 1 then - if c >= 0x1161 and c <= 0x11A7 then + if c >= 0x1161 and c <= 0x1175 then lvt = 2 codepoints[starter] = ((codepoints[starter] - 0x1100) * 21 + c - 0x1161) * 28 + 0xAC00 goto CONTINUE @@ -249,7 +260,7 @@ local function to_nfc_generic(s, decomposition_mapping) ::CONTINUE:: end for i = j,#codepoints do codepoints[i] = nil end - return char(unpack(codepoints)) + return get_string() end local function to_nfc(s) return to_nfc_generic(s, decomposition_mapping) -- cgit v1.2.3