diff options
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexbase/luatexbase.loader.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luatexbase/luatexbase.loader.lua | 44 |
1 files changed, 13 insertions, 31 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexbase/luatexbase.loader.lua b/Master/texmf-dist/tex/luatex/luatexbase/luatexbase.loader.lua index d4f30a16ed1..c10febfda88 100644 --- a/Master/texmf-dist/tex/luatex/luatexbase/luatexbase.loader.lua +++ b/Master/texmf-dist/tex/luatex/luatexbase/luatexbase.loader.lua @@ -6,51 +6,33 @@ -- -- luatexbase-loader.dtx (with options: `luamodule') -- --- Written in 2009, 2010 by Manuel Pegourie-Gonnard and Elie Roux. --- --- This work is under the CC0 license. --- See source file 'luatexbase-loader.dtx' for details. +-- See the aforementioned source file(s) for copyright and licensing information. -- module('luatexbase', package.seeall) +kpse.set_program_name("luatex") local lua_suffixes = { ".luc", ".luctex", ".texluc", ".lua", ".luatex", ".texlua", } local function ends_with(suffix, name) return name:sub(-suffix:len()) == suffix end -function find_file_lua_emul(name) - local search_list = {} +local function basename(name) for _, suffix in ipairs(lua_suffixes) do if ends_with(suffix, name) then - search_list = { name } - break - else - table.insert(search_list, name..suffix) - end - end - for _, search_name in ipairs(search_list) do - local f = kpse.find_file(search_name, 'texmfscripts') - or kpse.find_file(search_name, 'tex') - if f and ends_with(search_name, f) then - return f + return name:sub(1, -(suffix:len()+1)) end end -end -local find_file_lua -if pcall('kpse.find_file', 'dummy', 'lua') then - find_file_lua = function (name) - return kpse.find_file(name, 'lua') or find_file_lua_emul(name) - end -else - find_file_lua = function (name) - return find_file_lua_emul(name) - end + return name end local function find_module_file(mod) - return find_file_lua(mod:gsub('%.', '/'), 'lua') - or find_file_lua(mod, 'lua') + local compat = basename(mod):gsub('%.', '/') + return kpse.find_file(compat, 'lua') or kpse.find_file(mod, 'lua') +end +local package_loader_two +if not package.searchers then + package.searchers = package.loaders end -local package_loader_two = package.loaders[2] +package_loader_two = package.searchers[2] local function load_module(mod) local file = find_module_file(mod) if not file then @@ -71,6 +53,6 @@ local function load_module(mod) texio.write_nl("("..file..")") return loader end -package.loaders[2] = load_module +package.searchers[2] = load_module -- -- End of File `luatexbase.loader.lua'. |