summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/core-ctx.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2009-08-23 11:11:32 +0000
committerTaco Hoekwater <taco@elvenkind.com>2009-08-23 11:11:32 +0000
commit8fc3039c82d48605b5ca8b2eda3f4fdd755681e1 (patch)
tree3cd9bbdd599bc4d1ac0409e167fee2136e4c0ec9 /Master/texmf-dist/tex/context/base/core-ctx.lua
parent850fc99b7cd3ae7a20065531fe866ff7bae642ec (diff)
this is context 2009.08.19 17:10
git-svn-id: svn://tug.org/texlive/trunk@14827 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-ctx.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/core-ctx.lua94
1 files changed, 94 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-ctx.lua b/Master/texmf-dist/tex/context/base/core-ctx.lua
new file mode 100644
index 00000000000..eb9003bf1fb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/core-ctx.lua
@@ -0,0 +1,94 @@
+if not modules then modules = { } end modules ['supp-fil'] = {
+ version = 1.001,
+ comment = "companion to supp-fil.tex",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+local trace_prepfiles = false trackers.register("resolvers.prepfiles", function(v) trace_prepfiles = v end)
+
+commands = commands or { }
+
+local list, suffix, islocal, found = { }, "prep", false, false
+
+function commands.loadctxpreplist()
+ local ctlname = file.replacesuffix(tex.jobname,"ctl")
+ if lfs.isfile(ctlname) then
+ local x = xml.load(ctlname)
+ if x then
+ islocal = xml.found(x,"ctx:preplist[@local=='yes']")
+ if trace_prepfiles then
+ if islocal then
+ commands.writestatus("systems","loading ctx log file (local)") -- todo: m!systems
+ else
+ commands.writestatus("systems","loading ctx log file (specified)") -- todo: m!systems
+ end
+ end
+ for r, d, k in xml.elements(x,"ctx:prepfile") do
+ local dk = d[k]
+ local name = xml.content(dk)
+ if islocal then
+ name = file.basename(name)
+ end
+ local done = dk.at['done'] or 'no'
+ if trace_prepfiles then
+ commands.writestatus("systems","registering %s -> %s",done)
+ end
+ found = true
+ list[name] = done -- 'yes' or 'no'
+ end
+ end
+ end
+end
+
+-- -- --
+
+local function found(name) -- used in resolve
+ local prepname = name .. "." .. suffix
+ if list[name] and lfs.isfile(prepname) then
+ if trace_prepfiles then
+ commands.writestatus("systems", "preprocessing: using %s",prepname)
+ end
+ return prepname
+ end
+ return false
+end
+
+local function resolve(name) -- used a few times later on
+ local filename = file.collapse_path(name)
+ local prepname = islocal and found(file.basename(name))
+ if prepname then
+ return prepname
+ end
+ prepname = found(filename)
+ if prepname then
+ return prepname
+ end
+ return false
+end
+
+--~ support.doiffileexistelse(name)
+
+local processfile = commands.processfile
+local doifinputfileelse = commands.doifinputfileelse
+
+function commands.processfile(name,depth)
+ local prepname = found and resolve(name)
+ if prepname then
+ return processfile(prepname,0)
+ end
+ return processfile(name,depth)
+end
+
+function commands.doifinputfileelse(name,depth)
+ local prepname = found and resolve(name)
+ if prepname then
+ return doifinputfileelse(prepname,0)
+ end
+ return doifinputfileelse(name,depth)
+end
+
+function commands.preparedfile(name)
+ return (found and resolve(name)) or name
+end