diff options
author | Hans Hagen <pragma@wxs.nl> | 2021-12-24 19:46:30 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2021-12-24 19:46:30 +0100 |
commit | 1cc6c316feae649d3c8b64ef0c980dfd792c2347 (patch) | |
tree | d2153ed2d05808a40963f095fb2d29c4f5e5c4c8 /tex/context/base/mkiv/file-lib.lua | |
parent | 19750b667c23a9f276032837d6c517063376bd0c (diff) | |
download | context-1cc6c316feae649d3c8b64ef0c980dfd792c2347.tar.gz |
2021-12-24 19:09:00
Diffstat (limited to 'tex/context/base/mkiv/file-lib.lua')
-rw-r--r-- | tex/context/base/mkiv/file-lib.lua | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/tex/context/base/mkiv/file-lib.lua b/tex/context/base/mkiv/file-lib.lua index 9b0679e25..50ac5e1db 100644 --- a/tex/context/base/mkiv/file-lib.lua +++ b/tex/context/base/mkiv/file-lib.lua @@ -18,10 +18,11 @@ local report_library = logs.reporter("files","library") ----- report_files = logs.reporter("files","readfile") local removesuffix = file.removesuffix +local collapsepath = file.collapsepath local getreadfilename = resolvers.getreadfilename -local loaded = { } +local libraries = table.setmetatableindex("table") local defaultpatterns = { "%s" } local function defaultaction(name,foundname) @@ -46,6 +47,7 @@ function resolvers.uselibrary(specification) -- todo: reporter local foundname = getreadfilename("any",".",somename) -- maybe some day also an option not to backtrack .. and ../.. (or block global) return foundname ~= "" and foundname end + local loaded = libraries[patterns] for i=1,#files do local filename = files[i] if not loaded[filename] then @@ -76,17 +78,25 @@ function resolvers.uselibrary(specification) -- todo: reporter end end end - if not loaded[foundname] then - if foundname then - action(name,foundname) + if type(foundname) == "string" then + if not loaded[foundname] then + if foundname then + foundname = collapsepath(foundname) + -- this way we can run a module (nil when making a format): + local inputname = environment.inputfilename + if not inputname or collapsepath(inputname) ~= foundname then + action(name,foundname) + end + -- afterwards: + if onlyonce then + loaded[foundname] = true -- todo: base this on return value + end + elseif failure then + failure(name) + end if onlyonce then - loaded[foundname] = true -- todo: base this on return value + loaded[filename] = true -- todo: base this on return value end - elseif failure then - failure(name) - end - if onlyonce then - loaded[filename] = true -- todo: base this on return value end end end |