summaryrefslogtreecommitdiff
path: root/tex/context/base/core-sys.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2012-10-15 19:10:00 +0200
committerHans Hagen <pragma@wxs.nl>2012-10-15 19:10:00 +0200
commitbb77146e10ffacde870b252d64b41bdc84f66d8b (patch)
treecebc4e906da85c0f83524bb3a7cb532a5f06592a /tex/context/base/core-sys.lua
parent18b22ccfe77b0f996e3c78c16126dc00cebf7e2d (diff)
downloadcontext-bb77146e10ffacde870b252d64b41bdc84f66d8b.tar.gz
beta 2012.10.15 19:10
Diffstat (limited to 'tex/context/base/core-sys.lua')
-rw-r--r--tex/context/base/core-sys.lua109
1 files changed, 75 insertions, 34 deletions
diff --git a/tex/context/base/core-sys.lua b/tex/context/base/core-sys.lua
index d68ef05d7..e25c9b8f1 100644
--- a/tex/context/base/core-sys.lua
+++ b/tex/context/base/core-sys.lua
@@ -7,43 +7,84 @@ if not modules then modules = { } end modules ['core-sys'] = {
}
local lower, format, gsub = string.lower, string.format, string.gsub
-local suffix, basename, removesuffix = file.suffix, file.basename, file.removesuffix
+local suffixonly, basename, removesuffix = file.suffix, file.basename, file.removesuffix
local environment = environment
-function commands.updatefilenames(jobname,fulljobname,inputfilename,outputfilename)
- --
- environment.jobname = jobname
- --
- local jobfilename = gsub(fulljobname or jobname or inputfilename or tex.jobname or "","%./","")
- --
- environment.jobfilename = jobfilename
- environment.jobfilesuffix = lower(suffix(environment.jobfilename))
- --
- local inputfilename = gsub(inputfilename or "","%./","")
- environment.inputfilename = inputfilename
- environment.inputfilebarename = removesuffix(basename(inputfilename))
- --
- local inputfilerealsuffix = suffix(inputfilename)
- environment.inputfilerealsuffix = inputfilerealsuffix
- --
- local inputfilesuffix = inputfilerealsuffix == "" and "tex" or lower(inputfilerealsuffix)
- environment.inputfilesuffix = inputfilesuffix
- --
- local outputfilename = outputfilename or environment.inputfilebarename or ""
- environment.outputfilename = outputfilename
- --
- local runpath = resolvers.cleanpath(lfs.currentdir())
- environment.runpath = runpath
- --
- statistics.register("running on path", function()
- return environment.runpath
- end)
- --
- statistics.register("job file properties", function()
- return format("jobname: %s, input: %s, suffix: %s",jobfilename,inputfilename,inputfilesuffix)
- end)
- --
+local report_files = logs.reporter("system","files")
+
+-- function commands.updatefilenames(jobname,fulljobname,inputfilename,outputfilename)
+-- --
+-- environment.jobname = jobname
+-- --
+-- local jobfilename = gsub(fulljobname or jobname or inputfilename or tex.jobname or "","%./","")
+-- --
+-- environment.jobfilename = jobfilename
+-- environment.jobfilesuffix = lower(suffixonly(environment.jobfilename))
+-- --
+-- local inputfilename = gsub(inputfilename or "","%./","")
+-- environment.inputfilename = inputfilename
+-- environment.inputfilebarename = removesuffix(basename(inputfilename))
+-- --
+-- local inputfilerealsuffix = suffixonly(inputfilename)
+-- environment.inputfilerealsuffix = inputfilerealsuffix
+-- --
+-- local inputfilesuffix = inputfilerealsuffix == "" and "tex" or lower(inputfilerealsuffix)
+-- environment.inputfilesuffix = inputfilesuffix
+-- --
+-- local outputfilename = outputfilename or environment.inputfilebarename or ""
+-- environment.outputfilename = outputfilename
+-- --
+-- local runpath = resolvers.cleanpath(lfs.currentdir())
+-- environment.runpath = runpath
+-- --
+-- statistics.register("running on path", function()
+-- return environment.runpath
+-- end)
+-- --
+-- statistics.register("job file properties", function()
+-- return format("jobname: %s, input: %s, suffix: %s",jobfilename,inputfilename,inputfilesuffix)
+-- end)
+-- --
+-- end
+
+function environment.initializefilenames() -- commands.updatefilenames(jobname,fulljobname,input,result)
+
+ local arguments = environment.arguments
+
+ local jobname = arguments.jobname or tex.jobname
+ local fulljobname = arguments.fulljobname or jobname
+ local inputfilename = arguments.input or fulljobname
+ local outputfilename = arguments.result or removesuffix(jobname)
+
+ local inputfilename = suffixonly(inputfilename) == "tex" and removesuffix(inputfilename) or inputfilename or ""
+
+ local filename = fulljobname
+ local suffix = suffixonly(filename)
+
+ local filename = ctxrunner.resolve(filename) -- in case we're prepped
+
+ local jobfilename = jobname or inputfilename or tex.jobname or ""
+ local inputfilename = inputfilename or ""
+
+ jobfilename = gsub(jobfilename, "^./","")
+ inputfilename = gsub(inputfilename,"^./","")
+
+ environment.jobfilename = jobfilename
+ environment.jobfilesuffix = lower(suffixonly(jobfilename))
+
+ environment.inputfilename = inputfilename
+ environment.inputfilebarename = removesuffix(basename(inputfilename))
+ environment.inputfilesuffix = lower(suffixonly(inputfilename))
+
+ environment.outputfilename = outputfilename or environment.inputfilebarename or ""
+
+ environment.filename = filename
+ environment.suffix = suffix
+
+ report_files("jobname: %s, input: %s, result: %s",jobfilename,inputfilename,outputfilename)
+
+ function environment.initializefilenames() end
end
statistics.register("result saved in file", function()