summaryrefslogtreecommitdiff
path: root/tex/context/base/core-ctx.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/core-ctx.lua')
-rw-r--r--tex/context/base/core-ctx.lua76
1 files changed, 48 insertions, 28 deletions
diff --git a/tex/context/base/core-ctx.lua b/tex/context/base/core-ctx.lua
index 18978a530..c20691cd7 100644
--- a/tex/context/base/core-ctx.lua
+++ b/tex/context/base/core-ctx.lua
@@ -39,12 +39,12 @@ local xmltext = xml.text
local report_prepfiles = logs.reporter("system","prepfiles")
-commands = commands or { }
-local commands = commands
+local commands = commands
+local implement = interfaces.implement
-ctxrunner = ctxrunner or { }
+ctxrunner = ctxrunner or { }
-ctxrunner.prepfiles = utilities.storage.allocate()
+ctxrunner.prepfiles = utilities.storage.allocate()
local function dontpreparefile(t,k)
return k -- we only store when we have a prepper
@@ -254,7 +254,7 @@ function ctxrunner.load(ctxname)
for i=1,#runners do
local command = runners[i]
report_prepfiles("command: %s",command)
- local result = os.spawn(command) or 0
+ local result = os.execute(command) or 0
-- if result > 0 then
-- report_prepfiles("error, return code: %s",result)
-- end
@@ -301,35 +301,55 @@ local function resolve(name) -- used a few times later on
return ctxrunner.prepfiles[file.collapsepath(name)] or false
end
-local processfile = commands.processfile
-local doifinputfileelse = commands.doifinputfileelse
-
-function commands.processfile(name,maxreadlevel) -- overloaded
- local prepname = resolve(name)
- if prepname then
- return processfile(prepname,0)
- end
- return processfile(name,maxreadlevel)
+function ctxrunner.preparedfile(name)
+ return resolve(name) or name
end
-function commands.doifinputfileelse(name,depth)
- local prepname = resolve(name)
- if prepname then
- return doifinputfileelse(prepname,0)
+local processfile = commands.processfile
+local doifelseinputfile = commands.doifelseinputfile
+
+implement {
+ name = "processfile",
+ overload = true,
+ arguments = { "string", "integer" },
+ actions = function(name,maxreadlevel) -- overloaded
+ local prepname = resolve(name)
+ if prepname then
+ return processfile(prepname,0)
+ end
+ return processfile(name,maxreadlevel)
end
- return doifinputfileelse(name,depth)
-end
+}
-function commands.preparedfile(name)
- return resolve(name) or name
-end
+implement {
+ name = "doifelseinputfile",
+ overload = true,
+ arguments = { "string", "integer" },
+ actions = function(name,depth)
+ local prepname = resolve(name)
+ if prepname then
+ return doifelseinputfile(prepname,0)
+ end
+ return doifelseinputfile(name,depth)
+ end
+}
-function commands.getctxfile()
- local ctxfile = document.arguments.ctx or ""
- if ctxfile ~= "" then
- ctxrunner.load(ctxfile) -- do we need to locate it?
+-- implement {
+-- name = "preparedfile", -- not used
+-- arguments = "string",
+-- actions = { ctxrunner.preparedfile, context }
+-- }
+
+implement {
+ name = "setdocumentctxfile",
+ onlyonce = true,
+ actions = function()
+ local ctxfile = document.arguments.ctx or ""
+ if ctxfile ~= "" then
+ ctxrunner.load(ctxfile) -- do we need to locate it?
+ end
end
-end
+}
function ctxrunner.resolve(name) -- used a few times later on
local collapsedname = file.collapsepath(name,".")