diff options
author | Hans Hagen <pragma@wxs.nl> | 2008-01-28 21:28:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2008-01-28 21:28:00 +0100 |
commit | f0302311dd47bf250c0e2b5f8be46f21437f43d8 (patch) | |
tree | ce920dd169066a8dcdf13b81490816ab58c0e4cd /tex/context/base/core-job.lua | |
parent | e3467ba8810e788b01d8e7ce2e16d3c8ffdd3e2a (diff) | |
download | context-f0302311dd47bf250c0e2b5f8be46f21437f43d8.tar.gz |
stable 2008.01.28 21:28
Diffstat (limited to 'tex/context/base/core-job.lua')
-rw-r--r-- | tex/context/base/core-job.lua | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/tex/context/base/core-job.lua b/tex/context/base/core-job.lua index ce2952ff6..aa3ff9a0e 100644 --- a/tex/context/base/core-job.lua +++ b/tex/context/base/core-job.lua @@ -29,27 +29,47 @@ cs.testcase = commands.doifelse -- main code -function commands.processfile(name) - name = input.find_file(texmf.instance,name) or "" - if name ~= "" then - tex.sprint(tex.ctxcatcodes,string.format("\\input %s\\relax",name)) +do + + local function find(name,maxreadlevel) + local n = "./" .. name + if io.exists(n) then + return n + else + n = file.addsuffix(name,'tex') + for i=1,maxreadlevel or 0 do + n = "../" .. n + if io.exists(n) then + return n + end + end + end + return input.find_file(texmf.instance,name) or "" end -end -function commands.doifinputfileelse(name) - commands.doifelse((input.find_file(texmf.instance,name) or "") ~= "") -end + function commands.processfile(name,maxreadlevel) + name = find(name,maxreadlevel) + if name ~= "" then + tex.sprint(tex.ctxcatcodes,string.format("\\input %s\\relax",name)) + end + end -function commands.locatefilepath(name) - tex.sprint(tex.texcatcodes,file.dirname(input.find_file(texmf.instance,name) or "")) -end + function commands.doifinputfileelse(name,maxreadlevel) + commands.doifelse(find(name,maxreadlevel) ~= "") + end -function commands.usepath(paths) - input.register_extra_path(texmf.instance,paths) - tex.sprint(tex.texcatcodes,table.concat(texmf.instance.extra_paths or {}, "")) -end + function commands.locatefilepath(name,maxreadlevel) + tex.sprint(tex.texcatcodes,file.dirname(find(name,maxreadlevel))) + end + + function commands.usepath(paths,maxreadlevel) + input.register_extra_path(texmf.instance,paths) + tex.sprint(tex.texcatcodes,table.concat(texmf.instance.extra_paths or {}, "")) + end + + function commands.usesubpath(subpaths,maxreadlevel) + input.register_extra_path(texmf.instance,nil,subpaths) + tex.sprint(tex.texcatcodes,table.concat(texmf.instance.extra_paths or {}, "")) + end -function commands.usesubpath(subpaths) - input.register_extra_path(texmf.instance,nil,subpaths) - tex.sprint(tex.texcatcodes,table.concat(texmf.instance.extra_paths or {}, "")) end |