summaryrefslogtreecommitdiff
path: root/tex/context/base/supp-fil.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-05-28 11:23:00 +0200
committerHans Hagen <pragma@wxs.nl>2009-05-28 11:23:00 +0200
commit1d3090326210c6e6f7ec5432799ded25b75bba46 (patch)
treec5921203789ec669e6bccaba4bd56f9c072dc56b /tex/context/base/supp-fil.lua
parent94d83f84758766511c5e324721e39fea6ab71dae (diff)
downloadcontext-1d3090326210c6e6f7ec5432799ded25b75bba46.tar.gz
beta 2009.05.28 11:23
Diffstat (limited to 'tex/context/base/supp-fil.lua')
-rw-r--r--tex/context/base/supp-fil.lua49
1 files changed, 29 insertions, 20 deletions
diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua
index 32c5fb865..a93b0bce9 100644
--- a/tex/context/base/supp-fil.lua
+++ b/tex/context/base/supp-fil.lua
@@ -12,26 +12,30 @@ if not modules then modules = { } end modules ['supp-fil'] = {
at the <l n='tex'/> side.</p>
--ldx]]--
+local find, gsub, match = string.find, string.gsub, string.match
+
+local ctxcatcodes = tex.ctxcatcodes
+
support = support or { }
environment = environment or { }
environment.outputfilename = environment.outputfilename or environment.jobname
function support.checkfilename(str) -- "/whatever..." "c:..." "http://..."
- cs.chardef("kindoffile",boolean.tonumber(str:find("^/") or str:find("[%a]:")))
+ commands.chardef("kindoffile",boolean.tonumber(find(str,"^/") or find(str,"[%a]:")))
end
function support.thesanitizedfilename(str)
- tex.write((str:gsub("\\","/")))
+ tex.write((gsub(str,"\\","/")))
end
function support.splitfilename(fullname)
local path, name, base, suffix, kind = '', fullname, fullname, '', 0
- local p, n = fullname:match("^(.+)/(.-)$")
+ local p, n = match(fullname,"^(.+)/(.-)$")
if p and n then
path, name, base = p, n, n
end
- local b, s = base:match("^(.+)%.(.-)$")
+ local b, s = match(base,"^(.+)%.(.-)$")
if b and s then
name, suffix = b, s
end
@@ -42,38 +46,43 @@ function support.splitfilename(fullname)
else
kind = 2
end
---~ print(fullname,path,base,name,suffix)
- cs.def("splitofffull", fullname)
- cs.def("splitoffpath", path)
- cs.def("splitoffbase", base)
- cs.def("splitoffname", name)
- cs.def("splitofftype", suffix)
- cs.chardef("splitoffkind", kind)
+ commands.def("splitofffull", fullname)
+ commands.def("splitoffpath", path)
+ commands.def("splitoffbase", base)
+ commands.def("splitoffname", name)
+ commands.def("splitofftype", suffix)
+ commands.chardef("splitoffkind", kind)
end
function support.splitfiletype(fullname)
local name, suffix = fullname, ''
- local n, s = fullname:match("^(.+)%.(.-)$")
+ local n, s = match(fullname,"^(.+)%.(.-)$")
if n and s then
name, suffix = n, s
end
- cs.def("splitofffull", fullname)
- cs.def("splitoffpath", "")
- cs.def("splitoffname", name)
- cs.def("splitofftype", suffix)
+ commands.def("splitofffull", fullname)
+ commands.def("splitoffpath", "")
+ commands.def("splitoffname", name)
+ commands.def("splitofftype", suffix)
end
function support.doifparentfileelse(n)
- cs.testcase(n==environment.jobname or n==environment.jobname..'.tex' or n==environment.outputfilename)
+ commands.testcase(n==environment.jobname or n==environment.jobname..'.tex' or n==environment.outputfilename)
end
-- saves some .15 sec on 12 sec format generation
+local lastexistingfile = ""
+
function support.doiffileexistelse(name)
if not name or name == "" then
- return cs.testcase(false)
+ lastexistingfile = ""
else
- local n = input.findtexfile(name)
- return cs.testcase(n and n ~= "")
+ lastexistingfile = resolvers.findtexfile(name) or ""
end
+ return commands.testcase(lastexistingfile ~= "")
+end
+
+function support.lastexistingfile()
+ tex.sprint(ctxcatcodes,lastexistingfile)
end