From e391f0e473b9a2987bd27841f96f91f3379b767d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 10 Jun 2016 08:00:50 +0200 Subject: [init] adapt Context base path for file loader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix issue #344 The paths changed a while ago making a change necessary. We can’t just replace the path because older versions of the tree would fail, rendering bisection unusable. We compensate by testing the candidate directories beforehand. --- src/luaotfload-init.lua | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/luaotfload-init.lua b/src/luaotfload-init.lua index 48a8eba..3c0b622 100644 --- a/src/luaotfload-init.lua +++ b/src/luaotfload-init.lua @@ -9,6 +9,7 @@ local setmetatable = setmetatable local kpselookup = kpse.lookup +local lfsisdir = lfs.isdir --[[doc-- @@ -223,7 +224,7 @@ end --- below paths are relative to the texmf-context local ltx = "tex/generic/context/luatex" -local ctx = "tex/context/base" +local ctx = { "tex/context/base/mkiv", "tex/context/base" } local context_modules = { @@ -285,17 +286,37 @@ local load_context_modules = function (pth) local sub, spec = unpack (context_modules [i]) if sub == false then ignore_module (spec) - elseif type (sub) == "string" then - if pth then + else + local tsub = type (sub) + if not pth then + load_module (spec) + elseif tsub == "string" then load_module (spec, file.join (pth, sub)) + elseif tsub == "table" then + local pfx + local nsub = #sub + for j = 1, nsub do + local full = file.join (pth, sub [j]) + if lfsisdir (full) then --- pick the first real one + pfx = full + break + end + end + if pfx then + load_module (spec, pfx) + else + logreport ("both", 0, "init", + "None of the %d search paths for module %q exist; \z + falling back to default path.", + nsub, tostring (spec)) + load_module (spec) --- maybe we’ll get by after all? + end else - load_module (spec) + logreport ("both", 0, "init", + "Internal error, please report. \z + This is not your fault.") + os.exit (-1) end - else - logreport ("both", 0, "init", - "Internal error, please report. \z - This is not your fault.") - os.exit (-1) end end @@ -535,7 +556,7 @@ local init_main = function () "Loading Context modules in lookup path.") load_context_modules () - elseif lfs.isdir (fontloader) then + elseif lfsisdir (fontloader) then logreport ("log", 0, "init", "Loading Context files under prefix “%s”.", fontloader) -- cgit v1.2.3