summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/file-mod.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/file-mod.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/file-mod.lua45
1 files changed, 28 insertions, 17 deletions
diff --git a/Master/texmf-dist/tex/context/base/file-mod.lua b/Master/texmf-dist/tex/context/base/file-mod.lua
index e6592f0f062..3659d308962 100644
--- a/Master/texmf-dist/tex/context/base/file-mod.lua
+++ b/Master/texmf-dist/tex/context/base/file-mod.lua
@@ -20,14 +20,15 @@ at the <l n='tex'/> side.</p>
local format, concat, tonumber = string.format, table.concat, tonumber
-local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end)
+local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end)
local report_modules = logs.reporter("resolvers","modules")
-commands = commands or { }
-local commands = commands
+commands = commands or { }
+local commands = commands
-local findbyscheme = resolvers.finders.byscheme -- use different one
+local findbyscheme = resolvers.finders.byscheme -- use different one
+local iterator = utilities.parsers.iterator
-- modules can have a specific suffix or can specify one
@@ -42,19 +43,19 @@ local function usemodule(name,hasscheme)
-- so we only add one if missing
local fullname = file.addsuffix(name,"tex")
if trace_modules then
- report_modules("checking url: '%s'",fullname)
+ report_modules("checking url %a",fullname)
end
foundname = resolvers.findtexfile(fullname) or ""
- elseif file.extname(name) ~= "" then
+ elseif file.suffix(name) ~= "" then
if trace_modules then
- report_modules("checking file: '%s'",name)
+ report_modules("checking file %a",name)
end
foundname = findbyscheme("any",name) or ""
else
for i=1,#suffixes do
local fullname = file.addsuffix(name,suffixes[i])
if trace_modules then
- report_modules("checking file: '%s'",fullname)
+ report_modules("checking file %a",fullname)
end
foundname = findbyscheme("any",fullname) or ""
if foundname ~= "" then
@@ -64,7 +65,7 @@ local function usemodule(name,hasscheme)
end
if foundname ~= "" then
if trace_modules then
- report_modules("loading: '%s'",foundname)
+ report_modules("loading file %a",foundname)
end
context.startreadingfile()
resolvers.jobs.usefile(foundname,true) -- once, notext
@@ -87,7 +88,7 @@ function commands.usemodules(prefix,askedname,truename)
status = status + 1
else
if trace_modules then
- report_modules("locating: prefix: '%s', askedname: '%s', truename: '%s'",prefix or "", askedname or "", truename or "")
+ report_modules("locating, prefix %a, askedname %a, truename %a",prefix,askedname,truename)
end
local hasscheme = url.hasscheme(truename)
if hasscheme then
@@ -122,11 +123,11 @@ function commands.usemodules(prefix,askedname,truename)
end
end
if status == 0 then
- report_modules("not found: '%s'",askedname)
+ report_modules("%a is not found",askedname)
elseif status == 1 then
- report_modules("loaded: '%s'",trace_modules and truename or askedname)
+ report_modules("%a is loaded",trace_modules and truename or askedname)
else
- report_modules("already loaded: '%s'",trace_modules and truename or askedname)
+ report_modules("%a is already loaded",trace_modules and truename or askedname)
end
modstatus[hashname] = status
end
@@ -144,9 +145,13 @@ statistics.register("loaded tex modules", function()
t[nt] = k
end
end
- local ts = (nt>0 and format(" (%s)",concat(t," "))) or ""
- local fs = (nf>0 and format(" (%s)",concat(f," "))) or ""
- return format("%s requested, %s found%s, %s missing%s",nt+nf,nt,ts,nf,fs)
+ if nf == 0 then
+ return format("%s requested, all found (%s)",nt,concat(t," "))
+ elseif nt == 0 then
+ return format("%s requested, all missing (%s)",nf,concat(f," "))
+ else
+ return format("%s requested, %s found (%s), %s missing (%s)",nt+nf,nt,concat(t," "),nf,concat(f," "))
+ end
else
return nil
end
@@ -166,5 +171,11 @@ function commands.doifolderversionelse(one,two) -- one >= two
two = lpeg.match(splitter,two)
one = (one[1] or 0) * 10000 + (one[2] or 0) * 100 + (one[3] or 0)
two = (two[1] or 0) * 10000 + (two[2] or 0) * 100 + (two[3] or 0)
- commands.testcase(one>=two)
+ commands.doifelse(one>=two)
+end
+
+function commands.useluamodule(list)
+ for filename in iterator(list) do
+ environment.loadluafile(filename)
+ end
end