summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2009-11-23 11:49:00 +0100
committerHans Hagen <pragma@wxs.nl>2009-11-23 11:49:00 +0100
commit79817aae214b6a02b8a23c90e7d5e8fb4da6b80f (patch)
tree5e1cc879663e30f40873407e7e6fa6feb9a724ea /scripts
parentc38290bd0d10e40de8f19cecf2baac0d8e9912e7 (diff)
downloadcontext-79817aae214b6a02b8a23c90e7d5e8fb4da6b80f.tar.gz
beta 2009.11.23 11:49
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/luatools.lua366
-rw-r--r--scripts/context/lua/mtxrun.lua436
-rw-r--r--scripts/context/stubs/mswin/luatools.lua366
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua436
-rwxr-xr-xscripts/context/stubs/unix/luatools366
-rwxr-xr-xscripts/context/stubs/unix/mtxrun436
6 files changed, 1026 insertions, 1380 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua
index 70c391421..692213b09 100644
--- a/scripts/context/lua/luatools.lua
+++ b/scripts/context/lua/luatools.lua
@@ -3612,92 +3612,6 @@ function directives.disable(...)
d(...)
end
---~ -- old code:
---
---~ trackers = trackers or { }
---~ local data, done = { }, { }
---~ local function set(what,value)
---~ if type(what) == "string" then
---~ what = aux.settings_to_array(what) -- inefficient but ok
---~ end
---~ for i=1,#what do
---~ local w = what[i]
---~ for d, f in next, data do
---~ if done[d] then
---~ -- prevent recursion due to wildcards
---~ elseif find(d,w) then
---~ done[d] = true
---~ for i=1,#f do
---~ f[i](value)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ local function reset()
---~ for d, f in next, data do
---~ for i=1,#f do
---~ f[i](false)
---~ end
---~ end
---~ end
---~ local function enable(what)
---~ set(what,true)
---~ end
---~ local function disable(what)
---~ if not what or what == "" then
---~ done = { }
---~ reset()
---~ else
---~ set(what,false)
---~ end
---~ end
---~ function trackers.register(what,...)
---~ what = lower(what)
---~ local w = data[what]
---~ if not w then
---~ w = { }
---~ data[what] = w
---~ end
---~ for _, fnc in next, { ... } do
---~ local typ = type(fnc)
---~ if typ == "function" then
---~ w[#w+1] = fnc
---~ elseif typ == "string" then
---~ w[#w+1] = function(value) set(fnc,value,nesting) end
---~ end
---~ end
---~ end
---~ function trackers.enable(what)
---~ local e = trackers.enable
---~ trackers.enable, done = enable, { }
---~ enable(string.simpleesc(what))
---~ trackers.enable, done = e, { }
---~ end
---~ function trackers.disable(what)
---~ local e = trackers.disable
---~ trackers.disable, done = disable, { }
---~ disable(string.simpleesc(what))
---~ trackers.disable, done = e, { }
---~ end
---~ function trackers.reset()
---~ done = { }
---~ reset()
---~ end
---~ function trackers.list() -- pattern
---~ local list = table.sortedkeys(data)
---~ local user, system = { }, { }
---~ for l=1,#list do
---~ local what = list[l]
---~ if find(what,"^%*") then
---~ system[#system+1] = what
---~ else
---~ user[#user+1] = what
---~ end
---~ end
---~ return user, system
---~ end
-
end -- of closure
@@ -3717,8 +3631,7 @@ if not modules then modules = { } end modules ['luat-env'] = {
-- evolved before bytecode arrays were available and so a lot of
-- code has disappeared already.
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local format = string.format
@@ -3909,12 +3822,12 @@ function environment.luafilechunk(filename) -- used for loading lua bytecode in
filename = file.replacesuffix(filename, "lua")
local fullname = environment.luafile(filename)
if fullname and fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading file %s", fullname)
end
return environment.loadedluacode(fullname)
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
return nil
@@ -3934,7 +3847,7 @@ function environment.loadluafile(filename, version)
-- when not overloaded by explicit suffix we look for a luc file first
local fullname = (lucname and environment.luafile(lucname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
@@ -3952,7 +3865,7 @@ function environment.loadluafile(filename, version)
if v == version then
return true
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","version mismatch for %s: lua=%s, luc=%s", filename, v, version)
end
environment.loadluafile(filename)
@@ -3963,12 +3876,12 @@ function environment.loadluafile(filename, version)
end
fullname = (luaname and environment.luafile(luaname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
if not chunk then
- if verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
else
@@ -4363,7 +4276,7 @@ end
function logs.setprogram(_name_,_banner_,_verbose_)
name, banner = _name_, _banner_
if _verbose_ then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
end
logs.set_method("tex")
logs.report = report -- also used in libraries
@@ -4376,9 +4289,9 @@ end
function logs.setverbose(what)
if what then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
else
- trackers.disable("resolvers.verbose")
+ trackers.disable("resolvers.locating")
end
logs.verbose = what or false
end
@@ -4483,11 +4396,11 @@ local format, gsub, find, lower, upper, match, gmatch = string.format, string.gs
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type = next, type
-local trace_locating, trace_detail, trace_verbose = false, false, false
+local trace_locating, trace_detail, trace_expansions = false, false, false
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
-trackers.register("resolvers.detail", function(v) trace_detail = v trackers.enable("resolvers.verbose,resolvers.detail") end)
+trackers.register("resolvers.locating", function(v) trace_locating = v end)
+trackers.register("resolvers.details", function(v) trace_detail = v end)
+trackers.register("resolvers.expansions", function(v) trace_expansions = v end) -- todo
if not resolvers then
resolvers = {
@@ -4796,37 +4709,43 @@ end
-- work that well; the parsing is ok, but dealing with the resulting
-- table is a pain because we need to work inside-out recursively
+local function do_first(a,b)
+ local t = { }
+ for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_second(a,b)
+ local t = { }
+ for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_both(a,b)
+ local t = { }
+ for sa in gmatch(a,"[^,]+") do
+ for sb in gmatch(b,"[^,]+") do
+ t[#t+1] = sa .. sb
+ end
+ end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_three(a,b,c)
+ return a .. b.. c
+end
+
local function splitpathexpr(str, t, validate)
-- no need for further optimization as it is only called a
- -- few times, we can use lpeg for the sub; we could move
- -- the local functions outside the body
+ -- few times, we can use lpeg for the sub
+ if trace_expansion then
+ logs.report("fileio","expanding variable '%s'",str)
+ end
t = t or { }
str = gsub(str,",}",",@}")
str = gsub(str,"{,","{@,")
-- str = "@" .. str .. "@"
local ok, done
- local function do_first(a,b)
- local t = { }
- for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_second(a,b)
- local t = { }
- for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_both(a,b)
- local t = { }
- for sa in gmatch(a,"[^,]+") do
- for sb in gmatch(b,"[^,]+") do
- t[#t+1] = sa .. sb
- end
- end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_three(a,b,c)
- return a .. b.. c
- end
while true do
done = false
while true do
@@ -4857,6 +4776,11 @@ local function splitpathexpr(str, t, validate)
t[#t+1] = s
end
end
+ if trace_expansions then
+ for k,v in ipairs(t) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
return t
end
@@ -4919,14 +4843,14 @@ function resolvers.getownpath()
local olddir = lfs.currentdir()
if lfs.chdir(p) then
local pp = lfs.currentdir()
- if trace_verbose and p ~= pp then
- logs.report("fileio","following symlink %s to %s",p,pp)
+ if trace_locating and p ~= pp then
+ logs.report("fileio","following symlink '%s' to '%s'",p,pp)
end
resolvers.ownpath = pp
lfs.chdir(olddir)
else
- if trace_verbose then
- logs.report("fileio","unable to check path %s",p)
+ if trace_locating then
+ logs.report("fileio","unable to check path '%s'",p)
end
resolvers.ownpath = p
end
@@ -4955,10 +4879,10 @@ local function identify_own()
if resolvers.env('TEXMFCNF') == "" then os.env['TEXMFCNF'] = resolvers.cnfdefault end
if resolvers.env('TEXOS') == "" then os.env['TEXOS'] = resolvers.env('SELFAUTODIR') end
if resolvers.env('TEXROOT') == "" then os.env['TEXROOT'] = resolvers.env('SELFAUTOPARENT') end
- if trace_verbose then
+ if trace_locating then
for i=1,#own_places do
local v = own_places[i]
- logs.report("fileio","variable %s set to %s",v,resolvers.env(v) or "unknown")
+ logs.report("fileio","variable '%s' set to '%s'",v,resolvers.env(v) or "unknown")
end
end
identify_own = function() end
@@ -4990,10 +4914,8 @@ end
local function load_cnf_file(fname)
fname = resolvers.clean_path(fname)
local lname = file.replacesuffix(fname,'lua')
- local f = io.open(lname)
- if f then -- this will go
- f:close()
- local dname = file.dirname(fname)
+ if lfs.isfile(lname) then
+ local dname = file.dirname(fname) -- fname ?
if not instance.configuration[dname] then
resolvers.load_data(dname,'configuration',lname and file.basename(lname))
instance.order[#instance.order+1] = instance.configuration[dname]
@@ -5001,8 +4923,8 @@ local function load_cnf_file(fname)
else
f = io.open(fname)
if f then
- if trace_verbose then
- logs.report("fileio","loading %s", fname)
+ if trace_locating then
+ logs.report("fileio","loading configuration file %s", fname)
end
local line, data, n, k, v
local dname = file.dirname(fname)
@@ -5036,8 +4958,8 @@ local function load_cnf_file(fname)
end
end
f:close()
- elseif trace_verbose then
- logs.report("fileio","skipping %s", fname)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'", fname)
end
end
end
@@ -5064,8 +4986,11 @@ function resolvers.load_cnf()
end
end
-- instance.cnffiles contain complete names now !
+ -- we still use a funny mix of cnf and new but soon
+ -- we will switch to lua exclusively as we only use
+ -- the file to collect the tree roots
if #instance.cnffiles == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","no cnf files found (TEXMFCNF may not be set/known)")
end
else
@@ -5132,14 +5057,14 @@ end
function resolvers.append_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash append: %s",tag)
+ logs.report("fileio","hash '%s' appended",tag)
end
insert(instance.hashes, { ['type']=type, ['tag']=tag, ['name']=name } )
end
function resolvers.prepend_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash prepend: %s",tag)
+ logs.report("fileio","hash '%s' prepended",tag)
end
insert(instance.hashes, 1, { ['type']=type, ['tag']=tag, ['name']=name } )
end
@@ -5164,8 +5089,8 @@ end
function resolvers.locatelists()
for _, path in ipairs(resolvers.clean_path_list('TEXMF')) do
- if trace_verbose then
- logs.report("fileio","locating list of %s",path)
+ if trace_locating then
+ logs.report("fileio","locating list of '%s'",path)
end
resolvers.locatedatabase(file.collapse_path(path))
end
@@ -5178,11 +5103,11 @@ end
function resolvers.locators.tex(specification)
if specification and specification ~= '' and lfs.isdir(specification) then
if trace_locating then
- logs.report("fileio",'! tex locator found: %s',specification)
+ logs.report("fileio","tex locator '%s' found",specification)
end
resolvers.append_hash('file',specification,filename)
elseif trace_locating then
- logs.report("fileio",'? tex locator not found: %s',specification)
+ logs.report("fileio","tex locator '%s' not found",specification)
end
end
@@ -5225,8 +5150,8 @@ local weird = lpeg.P(".")^1 + lpeg.anywhere(lpeg.S("~`!#$%^&*()={}[]:;\"\'||<>,?
function resolvers.generators.tex(specification)
local tag = specification
- if trace_verbose then
- logs.report("fileio","scanning path %s",specification)
+ if trace_locating then
+ logs.report("fileio","scanning path '%s'",specification)
end
instance.files[tag] = { }
local files = instance.files[tag]
@@ -5275,7 +5200,7 @@ function resolvers.generators.tex(specification)
end
end
action()
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","%s files found on %s directories with %s uppercase remappings",n,m,r)
end
end
@@ -5305,7 +5230,12 @@ local function split_kpse_path(str) -- beware, this can be either a path or a {s
else
found = checkedsplit(str,io.pathseparator)
end
- -- print(table.serialize(found))
+ if trace_expansions then
+ logs.report("fileio","splitting path specification '%s'",str)
+ for k,v in ipairs(found) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
cache[str] = found
end
return found
@@ -5335,6 +5265,7 @@ function resolvers.joinconfig()
end
end
end
+
function resolvers.split_path(str)
if type(str) == 'table' then
return str
@@ -5342,6 +5273,7 @@ function resolvers.split_path(str)
return split_kpse_path(str)
end
end
+
function resolvers.join_path(str)
if type(str) == 'table' then
return file.join_path(str)
@@ -5430,12 +5362,18 @@ function resolvers.serialize(files)
return concat(t,"\n")
end
+local data_state = { }
+
+function resolvers.data_state()
+ return data_state or { }
+end
+
function resolvers.save_data(dataname, makename) -- untested without cache overload
for cachename, files in next, instance[dataname] do
local name = (makename or file.join)(cachename,dataname)
local luaname, lucname = name .. ".lua", name .. ".luc"
- if trace_verbose then
- logs.report("fileio","preparing %s for %s",dataname,cachename)
+ if trace_locating then
+ logs.report("fileio","preparing '%s' for '%s'",dataname,cachename)
end
for k, v in next, files do
if type(v) == "table" and #v == 1 then
@@ -5449,24 +5387,25 @@ function resolvers.save_data(dataname, makename) -- untested without cache overl
date = os.date("%Y-%m-%d"),
time = os.date("%H:%M:%S"),
content = files,
+ uuid = os.uuid(),
}
local ok = io.savedata(luaname,resolvers.serialize(data))
if ok then
- if trace_verbose then
- logs.report("fileio","%s saved in %s",dataname,luaname)
+ if trace_locating then
+ logs.report("fileio","'%s' saved in '%s'",dataname,luaname)
end
if utils.lua.compile(luaname,lucname,false,true) then -- no cleanup but strip
- if trace_verbose then
- logs.report("fileio","%s compiled to %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","'%s' compiled to '%s'",dataname,lucname)
end
else
- if trace_verbose then
- logs.report("fileio","compiling failed for %s, deleting file %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","compiling failed for '%s', deleting file '%s'",dataname,lucname)
end
os.remove(lucname)
end
- elseif trace_verbose then
- logs.report("fileio","unable to save %s in %s (access error)",dataname,luaname)
+ elseif trace_locating then
+ logs.report("fileio","unable to save '%s' in '%s' (access error)",dataname,luaname)
end
end
end
@@ -5478,19 +5417,20 @@ function resolvers.load_data(pathname,dataname,filename,makename) -- untested wi
if blob then
local data = blob()
if data and data.content and data.type == dataname and data.version == resolvers.cacheversion then
- if trace_verbose then
- logs.report("fileio","loading %s for %s from %s",dataname,pathname,filename)
+ data_state[#data_state+1] = data.uuid
+ if trace_locating then
+ logs.report("fileio","loading '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = data.content
else
- if trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ if trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
end
@@ -5516,8 +5456,8 @@ function resolvers.loadnewconfig()
if blob then
local data = blob()
if data then
- if trace_verbose then
- logs.report("fileio","loading configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","loading configuration file '%s'",filename)
end
if true then
-- flatten to variable.progname
@@ -5538,14 +5478,14 @@ function resolvers.loadnewconfig()
instance['setup'][pathname] = data
end
else
- if trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance['setup'][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance.order[#instance.order+1] = instance.setup[pathname]
if instance.loaderror then break end
@@ -5811,9 +5751,9 @@ function resolvers.isreadable.file(name)
local readable = lfs.isfile(name) -- brrr
if trace_detail then
if readable then
- logs.report("fileio","+ readable: %s",name)
+ logs.report("fileio","file '%s' is readable",name)
else
- logs.report("fileio","- readable: %s", name)
+ logs.report("fileio","file '%s' is not readable", name)
end
end
return readable
@@ -5829,7 +5769,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","? blobpath asked: %s",fname)
+ logs.report("fileio","using blobpath '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -5845,7 +5785,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio",'? blobpath do: %s (%s)',blobpath,bname)
+ logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -5879,7 +5819,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio",'! blobpath no: %s (%s)',blobpath,bname)
+ logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
end
end
end
@@ -5936,7 +5876,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
if instance.found[stamp] then
if trace_locating then
- logs.report("fileio",'! remembered: %s',filename)
+ logs.report("fileio","remembering file '%s'",filename)
end
return instance.found[stamp]
end
@@ -5944,7 +5884,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not dangerous[instance.format or "?"] then
if resolvers.isreadable.file(filename) then
if trace_detail then
- logs.report("fileio",'= found directly: %s',filename)
+ logs.report("fileio","file '%s' found directly",filename)
end
instance.found[stamp] = { filename }
return { filename }
@@ -5952,13 +5892,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
if find(filename,'%*') then
if trace_locating then
- logs.report("fileio",'! wildcard: %s', filename)
+ logs.report("fileio","checking wildcard '%s'", filename)
end
result = resolvers.find_wildcard_files(filename)
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
- logs.report("fileio",'! qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
result = { filename }
else
@@ -5968,7 +5908,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. ".tex"
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing standard filetype: tex')
+ logs.report("fileio","no suffix, forcing standard filetype 'tex'")
end
result, ok = { forcedname }, true
end
@@ -5978,7 +5918,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. "." .. s
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing format filetype: %s', s)
+ logs.report("fileio","no suffix, forcing format filetype '%s'", s)
end
result, ok = { forcedname }, true
break
@@ -6028,7 +5968,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- end
end
if not ok and trace_locating then
- logs.report("fileio",'? qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
end
else
@@ -6047,12 +5987,12 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.format_of_suffix(forcedname)
if trace_locating then
- logs.report("fileio",'! forcing filetype: %s',filetype)
+ logs.report("fileio","forcing filetype '%s'",filetype)
end
else
filetype = resolvers.format_of_suffix(filename)
if trace_locating then
- logs.report("fileio",'! using suffix based filetype: %s',filetype)
+ logs.report("fileio","using suffix based filetype '%s'",filetype)
end
end
else
@@ -6064,7 +6004,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
filetype = instance.format
if trace_locating then
- logs.report("fileio",'! using given filetype: %s',filetype)
+ logs.report("fileio","using given filetype '%s'",filetype)
end
end
local typespec = resolvers.variable_of_format(filetype)
@@ -6072,9 +6012,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not pathlist or #pathlist == 0 then
-- no pathlist, access check only / todo == wildcard
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
- logs.report("fileio",'? filetype: %s',filetype or '?')
- logs.report("fileio",'? wanted files: %s',concat(wantedfiles," | "))
+ logs.report("fileio","checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
end
for k=1,#wantedfiles do
local fname = wantedfiles[k]
@@ -6097,7 +6035,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local filelist = collect_files(wantedfiles)
local doscan, recurse
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
+ logs.report("fileio","checking filename '%s'",filename)
end
-- a bit messy ... esp the doscan setting here
for k=1,#pathlist do
@@ -6118,7 +6056,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local f = fl[2]
if find(f,expr) then
if trace_detail then
- logs.report("fileio",'= found in hash: %s',f)
+ logs.report("fileio","file '%s' found in hash",f)
end
--- todo, test for readable
result[#result+1] = fl[3]
@@ -6140,7 +6078,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local fname = file.join(ppname,w)
if resolvers.isreadable.file(fname) then
if trace_detail then
- logs.report("fileio",'= found by scanning: %s',fname)
+ logs.report("fileio","found '%s' by scanning",fname)
end
result[#result+1] = fname
done = true
@@ -6313,9 +6251,9 @@ function resolvers.load(option)
statistics.starttiming(instance)
resolvers.resetconfig()
resolvers.identify_cnf()
- resolvers.load_lua()
+ resolvers.load_lua() -- will become the new method
resolvers.expand_variables()
- resolvers.load_cnf()
+ resolvers.load_cnf() -- will be skipped when we have a lua file
resolvers.expand_variables()
if option ~= "nofiles" then
resolvers.load_hash()
@@ -6327,14 +6265,14 @@ end
function resolvers.for_files(command, files, filetype, mustexist)
if files and #files > 0 then
local function report(str)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio",str) -- has already verbose
else
print(str)
end
end
- if trace_verbose then
- report('')
+ if trace_locating then
+ report('') -- ?
end
for _, file in ipairs(files) do
local result = command(file,filetype,mustexist)
@@ -6400,7 +6338,7 @@ function resolvers.methodhandler(what, filename, filetype) -- ...
local scheme = specification.scheme
if resolvers[what][scheme] then
if trace_locating then
- logs.report("fileio",'= handler: %s -> %s -> %s',specification.original,what,table.sequenced(specification))
+ logs.report("fileio","handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolvers[what][scheme](filename,filetype) -- todo: specification
else
@@ -6736,8 +6674,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub
local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end)
local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end)
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
--[[ldx--
<p>Once we found ourselves defining similar cache constructs
@@ -6861,8 +6797,7 @@ if not modules then modules = { } end modules ['data-use'] = {
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-- since we want to use the cache instead of the tree, we will now
-- reimplement the saver.
@@ -7101,47 +7036,47 @@ if not modules then modules = { } end modules ['data-aux'] = {
local find = string.find
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
function resolvers.update_script(oldname,newname) -- oldname -> own.name, not per se a suffix
local scriptpath = "scripts/context/lua"
newname = file.addsuffix(newname,"lua")
local oldscript = resolvers.clean_path(oldname)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","to be replaced old script %s", oldscript)
end
local newscripts = resolvers.find_files(newname) or { }
if #newscripts == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unable to locate new script")
end
else
for i=1,#newscripts do
local newscript = resolvers.clean_path(newscripts[i])
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","checking new script %s", newscript)
end
if oldscript == newscript then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old and new script are the same")
end
elseif not find(newscript,scriptpath) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","new script should come from %s",scriptpath)
end
elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","invalid new script name")
end
else
local newdata = io.loaddata(newscript)
if newdata then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old script content replaced by new content")
end
io.savedata(oldscript,newdata)
break
- elseif trace_verbose then
+ elseif trace_locating then
logs.report("fileio","unable to load new script")
end
end
@@ -7399,6 +7334,7 @@ messages.help = [[
--engine=str target engine
--progname=str format or backend
--pattern=str filter variables
+--trackers=list enable given trackers
]]
function runners.make_format(texname)
@@ -7543,6 +7479,12 @@ local ok = true
-- private option --noluc for testing errors in the stub
+local trackspec = environment.argument("trackers") or environment.argument("track")
+
+if trackspec then
+ trackers.enable(trackspec)
+end
+
if environment.arguments["find-file"] then
resolvers.load()
instance.format = environment.arguments["format"] or instance.format
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 580e1a46f..26f5c4c2a 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -3332,92 +3332,6 @@ function directives.disable(...)
d(...)
end
---~ -- old code:
---
---~ trackers = trackers or { }
---~ local data, done = { }, { }
---~ local function set(what,value)
---~ if type(what) == "string" then
---~ what = aux.settings_to_array(what) -- inefficient but ok
---~ end
---~ for i=1,#what do
---~ local w = what[i]
---~ for d, f in next, data do
---~ if done[d] then
---~ -- prevent recursion due to wildcards
---~ elseif find(d,w) then
---~ done[d] = true
---~ for i=1,#f do
---~ f[i](value)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ local function reset()
---~ for d, f in next, data do
---~ for i=1,#f do
---~ f[i](false)
---~ end
---~ end
---~ end
---~ local function enable(what)
---~ set(what,true)
---~ end
---~ local function disable(what)
---~ if not what or what == "" then
---~ done = { }
---~ reset()
---~ else
---~ set(what,false)
---~ end
---~ end
---~ function trackers.register(what,...)
---~ what = lower(what)
---~ local w = data[what]
---~ if not w then
---~ w = { }
---~ data[what] = w
---~ end
---~ for _, fnc in next, { ... } do
---~ local typ = type(fnc)
---~ if typ == "function" then
---~ w[#w+1] = fnc
---~ elseif typ == "string" then
---~ w[#w+1] = function(value) set(fnc,value,nesting) end
---~ end
---~ end
---~ end
---~ function trackers.enable(what)
---~ local e = trackers.enable
---~ trackers.enable, done = enable, { }
---~ enable(string.simpleesc(what))
---~ trackers.enable, done = e, { }
---~ end
---~ function trackers.disable(what)
---~ local e = trackers.disable
---~ trackers.disable, done = disable, { }
---~ disable(string.simpleesc(what))
---~ trackers.disable, done = e, { }
---~ end
---~ function trackers.reset()
---~ done = { }
---~ reset()
---~ end
---~ function trackers.list() -- pattern
---~ local list = table.sortedkeys(data)
---~ local user, system = { }, { }
---~ for l=1,#list do
---~ local what = list[l]
---~ if find(what,"^%*") then
---~ system[#system+1] = what
---~ else
---~ user[#user+1] = what
---~ end
---~ end
---~ return user, system
---~ end
-
end -- of closure
@@ -6449,8 +6363,7 @@ if not modules then modules = { } end modules ['luat-env'] = {
-- evolved before bytecode arrays were available and so a lot of
-- code has disappeared already.
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local format = string.format
@@ -6641,12 +6554,12 @@ function environment.luafilechunk(filename) -- used for loading lua bytecode in
filename = file.replacesuffix(filename, "lua")
local fullname = environment.luafile(filename)
if fullname and fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading file %s", fullname)
end
return environment.loadedluacode(fullname)
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
return nil
@@ -6666,7 +6579,7 @@ function environment.loadluafile(filename, version)
-- when not overloaded by explicit suffix we look for a luc file first
local fullname = (lucname and environment.luafile(lucname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
@@ -6684,7 +6597,7 @@ function environment.loadluafile(filename, version)
if v == version then
return true
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","version mismatch for %s: lua=%s, luc=%s", filename, v, version)
end
environment.loadluafile(filename)
@@ -6695,12 +6608,12 @@ function environment.loadluafile(filename, version)
end
fullname = (luaname and environment.luafile(luaname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
if not chunk then
- if verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
else
@@ -7095,7 +7008,7 @@ end
function logs.setprogram(_name_,_banner_,_verbose_)
name, banner = _name_, _banner_
if _verbose_ then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
end
logs.set_method("tex")
logs.report = report -- also used in libraries
@@ -7108,9 +7021,9 @@ end
function logs.setverbose(what)
if what then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
else
- trackers.disable("resolvers.verbose")
+ trackers.disable("resolvers.locating")
end
logs.verbose = what or false
end
@@ -7215,11 +7128,11 @@ local format, gsub, find, lower, upper, match, gmatch = string.format, string.gs
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type = next, type
-local trace_locating, trace_detail, trace_verbose = false, false, false
+local trace_locating, trace_detail, trace_expansions = false, false, false
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
-trackers.register("resolvers.detail", function(v) trace_detail = v trackers.enable("resolvers.verbose,resolvers.detail") end)
+trackers.register("resolvers.locating", function(v) trace_locating = v end)
+trackers.register("resolvers.details", function(v) trace_detail = v end)
+trackers.register("resolvers.expansions", function(v) trace_expansions = v end) -- todo
if not resolvers then
resolvers = {
@@ -7528,37 +7441,43 @@ end
-- work that well; the parsing is ok, but dealing with the resulting
-- table is a pain because we need to work inside-out recursively
+local function do_first(a,b)
+ local t = { }
+ for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_second(a,b)
+ local t = { }
+ for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_both(a,b)
+ local t = { }
+ for sa in gmatch(a,"[^,]+") do
+ for sb in gmatch(b,"[^,]+") do
+ t[#t+1] = sa .. sb
+ end
+ end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_three(a,b,c)
+ return a .. b.. c
+end
+
local function splitpathexpr(str, t, validate)
-- no need for further optimization as it is only called a
- -- few times, we can use lpeg for the sub; we could move
- -- the local functions outside the body
+ -- few times, we can use lpeg for the sub
+ if trace_expansion then
+ logs.report("fileio","expanding variable '%s'",str)
+ end
t = t or { }
str = gsub(str,",}",",@}")
str = gsub(str,"{,","{@,")
-- str = "@" .. str .. "@"
local ok, done
- local function do_first(a,b)
- local t = { }
- for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_second(a,b)
- local t = { }
- for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_both(a,b)
- local t = { }
- for sa in gmatch(a,"[^,]+") do
- for sb in gmatch(b,"[^,]+") do
- t[#t+1] = sa .. sb
- end
- end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_three(a,b,c)
- return a .. b.. c
- end
while true do
done = false
while true do
@@ -7589,6 +7508,11 @@ local function splitpathexpr(str, t, validate)
t[#t+1] = s
end
end
+ if trace_expansions then
+ for k,v in ipairs(t) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
return t
end
@@ -7651,14 +7575,14 @@ function resolvers.getownpath()
local olddir = lfs.currentdir()
if lfs.chdir(p) then
local pp = lfs.currentdir()
- if trace_verbose and p ~= pp then
- logs.report("fileio","following symlink %s to %s",p,pp)
+ if trace_locating and p ~= pp then
+ logs.report("fileio","following symlink '%s' to '%s'",p,pp)
end
resolvers.ownpath = pp
lfs.chdir(olddir)
else
- if trace_verbose then
- logs.report("fileio","unable to check path %s",p)
+ if trace_locating then
+ logs.report("fileio","unable to check path '%s'",p)
end
resolvers.ownpath = p
end
@@ -7687,10 +7611,10 @@ local function identify_own()
if resolvers.env('TEXMFCNF') == "" then os.env['TEXMFCNF'] = resolvers.cnfdefault end
if resolvers.env('TEXOS') == "" then os.env['TEXOS'] = resolvers.env('SELFAUTODIR') end
if resolvers.env('TEXROOT') == "" then os.env['TEXROOT'] = resolvers.env('SELFAUTOPARENT') end
- if trace_verbose then
+ if trace_locating then
for i=1,#own_places do
local v = own_places[i]
- logs.report("fileio","variable %s set to %s",v,resolvers.env(v) or "unknown")
+ logs.report("fileio","variable '%s' set to '%s'",v,resolvers.env(v) or "unknown")
end
end
identify_own = function() end
@@ -7722,10 +7646,8 @@ end
local function load_cnf_file(fname)
fname = resolvers.clean_path(fname)
local lname = file.replacesuffix(fname,'lua')
- local f = io.open(lname)
- if f then -- this will go
- f:close()
- local dname = file.dirname(fname)
+ if lfs.isfile(lname) then
+ local dname = file.dirname(fname) -- fname ?
if not instance.configuration[dname] then
resolvers.load_data(dname,'configuration',lname and file.basename(lname))
instance.order[#instance.order+1] = instance.configuration[dname]
@@ -7733,8 +7655,8 @@ local function load_cnf_file(fname)
else
f = io.open(fname)
if f then
- if trace_verbose then
- logs.report("fileio","loading %s", fname)
+ if trace_locating then
+ logs.report("fileio","loading configuration file %s", fname)
end
local line, data, n, k, v
local dname = file.dirname(fname)
@@ -7768,8 +7690,8 @@ local function load_cnf_file(fname)
end
end
f:close()
- elseif trace_verbose then
- logs.report("fileio","skipping %s", fname)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'", fname)
end
end
end
@@ -7796,8 +7718,11 @@ function resolvers.load_cnf()
end
end
-- instance.cnffiles contain complete names now !
+ -- we still use a funny mix of cnf and new but soon
+ -- we will switch to lua exclusively as we only use
+ -- the file to collect the tree roots
if #instance.cnffiles == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","no cnf files found (TEXMFCNF may not be set/known)")
end
else
@@ -7864,14 +7789,14 @@ end
function resolvers.append_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash append: %s",tag)
+ logs.report("fileio","hash '%s' appended",tag)
end
insert(instance.hashes, { ['type']=type, ['tag']=tag, ['name']=name } )
end
function resolvers.prepend_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash prepend: %s",tag)
+ logs.report("fileio","hash '%s' prepended",tag)
end
insert(instance.hashes, 1, { ['type']=type, ['tag']=tag, ['name']=name } )
end
@@ -7896,8 +7821,8 @@ end
function resolvers.locatelists()
for _, path in ipairs(resolvers.clean_path_list('TEXMF')) do
- if trace_verbose then
- logs.report("fileio","locating list of %s",path)
+ if trace_locating then
+ logs.report("fileio","locating list of '%s'",path)
end
resolvers.locatedatabase(file.collapse_path(path))
end
@@ -7910,11 +7835,11 @@ end
function resolvers.locators.tex(specification)
if specification and specification ~= '' and lfs.isdir(specification) then
if trace_locating then
- logs.report("fileio",'! tex locator found: %s',specification)
+ logs.report("fileio","tex locator '%s' found",specification)
end
resolvers.append_hash('file',specification,filename)
elseif trace_locating then
- logs.report("fileio",'? tex locator not found: %s',specification)
+ logs.report("fileio","tex locator '%s' not found",specification)
end
end
@@ -7957,8 +7882,8 @@ local weird = lpeg.P(".")^1 + lpeg.anywhere(lpeg.S("~`!#$%^&*()={}[]:;\"\'||<>,?
function resolvers.generators.tex(specification)
local tag = specification
- if trace_verbose then
- logs.report("fileio","scanning path %s",specification)
+ if trace_locating then
+ logs.report("fileio","scanning path '%s'",specification)
end
instance.files[tag] = { }
local files = instance.files[tag]
@@ -8007,7 +7932,7 @@ function resolvers.generators.tex(specification)
end
end
action()
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","%s files found on %s directories with %s uppercase remappings",n,m,r)
end
end
@@ -8037,7 +7962,12 @@ local function split_kpse_path(str) -- beware, this can be either a path or a {s
else
found = checkedsplit(str,io.pathseparator)
end
- -- print(table.serialize(found))
+ if trace_expansions then
+ logs.report("fileio","splitting path specification '%s'",str)
+ for k,v in ipairs(found) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
cache[str] = found
end
return found
@@ -8067,6 +7997,7 @@ function resolvers.joinconfig()
end
end
end
+
function resolvers.split_path(str)
if type(str) == 'table' then
return str
@@ -8074,6 +8005,7 @@ function resolvers.split_path(str)
return split_kpse_path(str)
end
end
+
function resolvers.join_path(str)
if type(str) == 'table' then
return file.join_path(str)
@@ -8162,12 +8094,18 @@ function resolvers.serialize(files)
return concat(t,"\n")
end
+local data_state = { }
+
+function resolvers.data_state()
+ return data_state or { }
+end
+
function resolvers.save_data(dataname, makename) -- untested without cache overload
for cachename, files in next, instance[dataname] do
local name = (makename or file.join)(cachename,dataname)
local luaname, lucname = name .. ".lua", name .. ".luc"
- if trace_verbose then
- logs.report("fileio","preparing %s for %s",dataname,cachename)
+ if trace_locating then
+ logs.report("fileio","preparing '%s' for '%s'",dataname,cachename)
end
for k, v in next, files do
if type(v) == "table" and #v == 1 then
@@ -8181,24 +8119,25 @@ function resolvers.save_data(dataname, makename) -- untested without cache overl
date = os.date("%Y-%m-%d"),
time = os.date("%H:%M:%S"),
content = files,
+ uuid = os.uuid(),
}
local ok = io.savedata(luaname,resolvers.serialize(data))
if ok then
- if trace_verbose then
- logs.report("fileio","%s saved in %s",dataname,luaname)
+ if trace_locating then
+ logs.report("fileio","'%s' saved in '%s'",dataname,luaname)
end
if utils.lua.compile(luaname,lucname,false,true) then -- no cleanup but strip
- if trace_verbose then
- logs.report("fileio","%s compiled to %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","'%s' compiled to '%s'",dataname,lucname)
end
else
- if trace_verbose then
- logs.report("fileio","compiling failed for %s, deleting file %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","compiling failed for '%s', deleting file '%s'",dataname,lucname)
end
os.remove(lucname)
end
- elseif trace_verbose then
- logs.report("fileio","unable to save %s in %s (access error)",dataname,luaname)
+ elseif trace_locating then
+ logs.report("fileio","unable to save '%s' in '%s' (access error)",dataname,luaname)
end
end
end
@@ -8210,19 +8149,20 @@ function resolvers.load_data(pathname,dataname,filename,makename) -- untested wi
if blob then
local data = blob()
if data and data.content and data.type == dataname and data.version == resolvers.cacheversion then
- if trace_verbose then
- logs.report("fileio","loading %s for %s from %s",dataname,pathname,filename)
+ data_state[#data_state+1] = data.uuid
+ if trace_locating then
+ logs.report("fileio","loading '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = data.content
else
- if trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ if trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
end
@@ -8248,8 +8188,8 @@ function resolvers.loadnewconfig()
if blob then
local data = blob()
if data then
- if trace_verbose then
- logs.report("fileio","loading configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","loading configuration file '%s'",filename)
end
if true then
-- flatten to variable.progname
@@ -8270,14 +8210,14 @@ function resolvers.loadnewconfig()
instance['setup'][pathname] = data
end
else
- if trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance['setup'][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance.order[#instance.order+1] = instance.setup[pathname]
if instance.loaderror then break end
@@ -8543,9 +8483,9 @@ function resolvers.isreadable.file(name)
local readable = lfs.isfile(name) -- brrr
if trace_detail then
if readable then
- logs.report("fileio","+ readable: %s",name)
+ logs.report("fileio","file '%s' is readable",name)
else
- logs.report("fileio","- readable: %s", name)
+ logs.report("fileio","file '%s' is not readable", name)
end
end
return readable
@@ -8561,7 +8501,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","? blobpath asked: %s",fname)
+ logs.report("fileio","using blobpath '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -8577,7 +8517,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio",'? blobpath do: %s (%s)',blobpath,bname)
+ logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -8611,7 +8551,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio",'! blobpath no: %s (%s)',blobpath,bname)
+ logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
end
end
end
@@ -8668,7 +8608,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
if instance.found[stamp] then
if trace_locating then
- logs.report("fileio",'! remembered: %s',filename)
+ logs.report("fileio","remembering file '%s'",filename)
end
return instance.found[stamp]
end
@@ -8676,7 +8616,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not dangerous[instance.format or "?"] then
if resolvers.isreadable.file(filename) then
if trace_detail then
- logs.report("fileio",'= found directly: %s',filename)
+ logs.report("fileio","file '%s' found directly",filename)
end
instance.found[stamp] = { filename }
return { filename }
@@ -8684,13 +8624,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
if find(filename,'%*') then
if trace_locating then
- logs.report("fileio",'! wildcard: %s', filename)
+ logs.report("fileio","checking wildcard '%s'", filename)
end
result = resolvers.find_wildcard_files(filename)
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
- logs.report("fileio",'! qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
result = { filename }
else
@@ -8700,7 +8640,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. ".tex"
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing standard filetype: tex')
+ logs.report("fileio","no suffix, forcing standard filetype 'tex'")
end
result, ok = { forcedname }, true
end
@@ -8710,7 +8650,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. "." .. s
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing format filetype: %s', s)
+ logs.report("fileio","no suffix, forcing format filetype '%s'", s)
end
result, ok = { forcedname }, true
break
@@ -8760,7 +8700,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- end
end
if not ok and trace_locating then
- logs.report("fileio",'? qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
end
else
@@ -8779,12 +8719,12 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.format_of_suffix(forcedname)
if trace_locating then
- logs.report("fileio",'! forcing filetype: %s',filetype)
+ logs.report("fileio","forcing filetype '%s'",filetype)
end
else
filetype = resolvers.format_of_suffix(filename)
if trace_locating then
- logs.report("fileio",'! using suffix based filetype: %s',filetype)
+ logs.report("fileio","using suffix based filetype '%s'",filetype)
end
end
else
@@ -8796,7 +8736,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
filetype = instance.format
if trace_locating then
- logs.report("fileio",'! using given filetype: %s',filetype)
+ logs.report("fileio","using given filetype '%s'",filetype)
end
end
local typespec = resolvers.variable_of_format(filetype)
@@ -8804,9 +8744,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not pathlist or #pathlist == 0 then
-- no pathlist, access check only / todo == wildcard
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
- logs.report("fileio",'? filetype: %s',filetype or '?')
- logs.report("fileio",'? wanted files: %s',concat(wantedfiles," | "))
+ logs.report("fileio","checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
end
for k=1,#wantedfiles do
local fname = wantedfiles[k]
@@ -8829,7 +8767,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local filelist = collect_files(wantedfiles)
local doscan, recurse
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
+ logs.report("fileio","checking filename '%s'",filename)
end
-- a bit messy ... esp the doscan setting here
for k=1,#pathlist do
@@ -8850,7 +8788,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local f = fl[2]
if find(f,expr) then
if trace_detail then
- logs.report("fileio",'= found in hash: %s',f)
+ logs.report("fileio","file '%s' found in hash",f)
end
--- todo, test for readable
result[#result+1] = fl[3]
@@ -8872,7 +8810,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local fname = file.join(ppname,w)
if resolvers.isreadable.file(fname) then
if trace_detail then
- logs.report("fileio",'= found by scanning: %s',fname)
+ logs.report("fileio","found '%s' by scanning",fname)
end
result[#result+1] = fname
done = true
@@ -9045,9 +8983,9 @@ function resolvers.load(option)
statistics.starttiming(instance)
resolvers.resetconfig()
resolvers.identify_cnf()
- resolvers.load_lua()
+ resolvers.load_lua() -- will become the new method
resolvers.expand_variables()
- resolvers.load_cnf()
+ resolvers.load_cnf() -- will be skipped when we have a lua file
resolvers.expand_variables()
if option ~= "nofiles" then
resolvers.load_hash()
@@ -9059,14 +8997,14 @@ end
function resolvers.for_files(command, files, filetype, mustexist)
if files and #files > 0 then
local function report(str)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio",str) -- has already verbose
else
print(str)
end
end
- if trace_verbose then
- report('')
+ if trace_locating then
+ report('') -- ?
end
for _, file in ipairs(files) do
local result = command(file,filetype,mustexist)
@@ -9132,7 +9070,7 @@ function resolvers.methodhandler(what, filename, filetype) -- ...
local scheme = specification.scheme
if resolvers[what][scheme] then
if trace_locating then
- logs.report("fileio",'= handler: %s -> %s -> %s',specification.original,what,table.sequenced(specification))
+ logs.report("fileio","handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolvers[what][scheme](filename,filetype) -- todo: specification
else
@@ -9564,8 +9502,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub
local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end)
local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end)
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
--[[ldx--
<p>Once we found ourselves defining similar cache constructs
@@ -9689,8 +9625,7 @@ if not modules then modules = { } end modules ['data-use'] = {
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-- since we want to use the cache instead of the tree, we will now
-- reimplement the saver.
@@ -9822,10 +9757,13 @@ if not modules then modules = { } end modules ['data-zip'] = {
local format, find = string.format, string.find
-local trace_locating, trace_verbose = false, false
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trace_verbose = v end)
+-- zip:///oeps.zip?name=bla/bla.tex
+-- zip:///oeps.zip?tree=tex/texmf-local
+-- zip:///texmf.zip?tree=/tex/texmf
+-- zip:///texmf.zip?tree=/tex/texmf-local
+-- zip:///texmf-mine.zip?tree=/tex/texmf-projects
zip = zip or { }
zip.archives = zip.archives or { }
@@ -9836,9 +9774,6 @@ local locators, hashers, concatinators = resolvers.locators, resolvers.hashers,
local archives = zip.archives
--- zip:///oeps.zip?name=bla/bla.tex
--- zip:///oeps.zip?tree=tex/texmf-local
-
local function validzip(str) -- todo: use url splitter
if not find(str,"^zip://") then
return "zip:///" .. str
@@ -9868,26 +9803,22 @@ function zip.closearchive(name)
end
end
--- zip:///texmf.zip?tree=/tex/texmf
--- zip:///texmf.zip?tree=/tex/texmf-local
--- zip:///texmf-mine.zip?tree=/tex/texmf-projects
-
function locators.zip(specification) -- where is this used? startup zips (untested)
specification = resolvers.splitmethod(specification)
local zipfile = specification.path
local zfile = zip.openarchive(name) -- tricky, could be in to be initialized tree
if trace_locating then
if zfile then
- logs.report("fileio",'! zip locator, found: %s',specification.original)
+ logs.report("fileio","zip locator, archive '%s' found",specification.original)
else
- logs.report("fileio",'? zip locator, not found: %s',specification.original)
+ logs.report("fileio","zip locator, archive '%s' not found",specification.original)
end
end
end
function hashers.zip(tag,name)
- if trace_verbose then
- logs.report("fileio","loading zip file %s as %s",name,tag)
+ if trace_locating then
+ logs.report("fileio","loading zip file '%s' as '%s'",name,tag)
end
resolvers.usezipfile(format("%s?tree=%s",tag,name))
end
@@ -9912,23 +9843,25 @@ function finders.zip(specification,filetype)
local zfile = zip.openarchive(specification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'! zip finder, path: %s',specification.path)
+ logs.report("fileio","zip finder, archive '%s' found",specification.path)
end
local dfile = zfile:open(q.name)
if dfile then
dfile = zfile:close()
if trace_locating then
- logs.report("fileio",'+ zip finder, name: %s',q.name)
+ logs.report("fileio","zip finder, file '%s' found",q.name)
end
return specification.original
+ elseif trace_locating then
+ logs.report("fileio","zip finder, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'? zip finder, path %s',specification.path)
+ logs.report("fileio","zip finder, unknown archive '%s'",specification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip finder, name: %s',filename)
+ logs.report("fileio","zip finder, '%s' not found",filename)
end
return unpack(finders.notfound)
end
@@ -9941,20 +9874,25 @@ function openers.zip(specification)
local zfile = zip.openarchive(zipspecification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'+ zip starter, path: %s',zipspecification.path)
+ logs.report("fileio","zip opener, archive '%s' opened",zipspecification.path)
end
local dfile = zfile:open(q.name)
if dfile then
logs.show_open(specification)
+ if trace_locating then
+ logs.report("fileio","zip opener, file '%s' found",q.name)
+ end
return openers.text_opener(specification,dfile,'zip')
+ elseif trace_locating then
+ logs.report("fileio","zip opener, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'- zip starter, path %s',zipspecification.path)
+ logs.report("fileio","zip opener, unknown archive '%s'",zipspecification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip opener, name: %s',filename)
+ logs.report("fileio","zip opener, '%s' not found",filename)
end
return unpack(openers.notfound)
end
@@ -9967,25 +9905,27 @@ function loaders.zip(specification)
local zfile = zip.openarchive(specification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'+ zip starter, path: %s',specification.path)
+ logs.report("fileio","zip loader, archive '%s' opened",specification.path)
end
local dfile = zfile:open(q.name)
if dfile then
logs.show_load(filename)
if trace_locating then
- logs.report("fileio",'+ zip loader, name: %s',filename)
+ logs.report("fileio","zip loader, file '%s' loaded",filename)
end
local s = dfile:read("*all")
dfile:close()
return true, s, #s
+ elseif trace_locating then
+ logs.report("fileio","zip loader, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'- zip starter, path: %s',specification.path)
+ logs.report("fileio","zip loader, unknown archive '%s'",specification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip loader, name: %s',filename)
+ logs.report("fileio","zip loader, '%s' not found",filename)
end
return unpack(openers.notfound)
end
@@ -9995,21 +9935,15 @@ end
function resolvers.usezipfile(zipname)
zipname = validzip(zipname)
- if trace_locating then
- logs.report("fileio",'! zip use, file: %s',zipname)
- end
local specification = resolvers.splitmethod(zipname)
local zipfile = specification.path
if zipfile and not zip.registeredfiles[zipname] then
local tree = url.query(specification.query).tree or ""
- if trace_locating then
- logs.report("fileio",'! zip register, file: %s',zipname)
- end
local z = zip.openarchive(zipfile)
if z then
local instance = resolvers.instance
if trace_locating then
- logs.report("fileio","= zipfile, registering: %s",zipname)
+ logs.report("fileio","zip registering, registering archive '%s'",zipname)
end
statistics.starttiming(instance)
resolvers.prepend_hash('zip',zipname,zipfile)
@@ -10018,10 +9952,10 @@ function resolvers.usezipfile(zipname)
instance.files[zipname] = resolvers.register_zip_file(z,tree or "")
statistics.stoptiming(instance)
elseif trace_locating then
- logs.report("fileio","? zipfile, unknown: %s",zipname)
+ logs.report("fileio","zip registering, unknown archive '%s'",zipname)
end
elseif trace_locating then
- logs.report("fileio",'! zip register, no file: %s',zipname)
+ logs.report("fileio","zip registering, '%s' not found",zipname)
end
end
@@ -10033,7 +9967,7 @@ function resolvers.register_zip_file(z,tree)
filter = format("^%s/(.+)/(.-)$",tree)
end
if trace_locating then
- logs.report("fileio",'= zip filter: %s',filter)
+ logs.report("fileio","zip registering, using filter '%s'",filter)
end
local register, n = resolvers.register_file, 0
for i in z:files() do
@@ -10050,7 +9984,7 @@ function resolvers.register_zip_file(z,tree)
n = n + 1
end
end
- logs.report("fileio",'= zip entries: %s',n)
+ logs.report("fileio","zip registering, %s files registered",n)
return files
end
@@ -10240,47 +10174,47 @@ if not modules then modules = { } end modules ['data-aux'] = {
local find = string.find
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
function resolvers.update_script(oldname,newname) -- oldname -> own.name, not per se a suffix
local scriptpath = "scripts/context/lua"
newname = file.addsuffix(newname,"lua")
local oldscript = resolvers.clean_path(oldname)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","to be replaced old script %s", oldscript)
end
local newscripts = resolvers.find_files(newname) or { }
if #newscripts == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unable to locate new script")
end
else
for i=1,#newscripts do
local newscript = resolvers.clean_path(newscripts[i])
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","checking new script %s", newscript)
end
if oldscript == newscript then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old and new script are the same")
end
elseif not find(newscript,scriptpath) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","new script should come from %s",scriptpath)
end
elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","invalid new script name")
end
else
local newdata = io.loaddata(newscript)
if newdata then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old script content replaced by new content")
end
io.savedata(oldscript,newdata)
break
- elseif trace_verbose then
+ elseif trace_locating then
logs.report("fileio","unable to load new script")
end
end
@@ -10690,6 +10624,7 @@ messages.help = [[
--unix create unix (linux) stubs
--verbose give a bit more info
+--trackers=list enable given trackers
--engine=str target engine
--progname=str format or backend
@@ -11246,6 +11181,11 @@ else
end
+local trackspec = environment.argument("trackers") or environment.argument("track")
+
+if trackspec then
+ trackers.enable(trackspec)
+end
if environment.argument("selfmerge") then
-- embed used libraries
diff --git a/scripts/context/stubs/mswin/luatools.lua b/scripts/context/stubs/mswin/luatools.lua
index 70c391421..692213b09 100644
--- a/scripts/context/stubs/mswin/luatools.lua
+++ b/scripts/context/stubs/mswin/luatools.lua
@@ -3612,92 +3612,6 @@ function directives.disable(...)
d(...)
end
---~ -- old code:
---
---~ trackers = trackers or { }
---~ local data, done = { }, { }
---~ local function set(what,value)
---~ if type(what) == "string" then
---~ what = aux.settings_to_array(what) -- inefficient but ok
---~ end
---~ for i=1,#what do
---~ local w = what[i]
---~ for d, f in next, data do
---~ if done[d] then
---~ -- prevent recursion due to wildcards
---~ elseif find(d,w) then
---~ done[d] = true
---~ for i=1,#f do
---~ f[i](value)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ local function reset()
---~ for d, f in next, data do
---~ for i=1,#f do
---~ f[i](false)
---~ end
---~ end
---~ end
---~ local function enable(what)
---~ set(what,true)
---~ end
---~ local function disable(what)
---~ if not what or what == "" then
---~ done = { }
---~ reset()
---~ else
---~ set(what,false)
---~ end
---~ end
---~ function trackers.register(what,...)
---~ what = lower(what)
---~ local w = data[what]
---~ if not w then
---~ w = { }
---~ data[what] = w
---~ end
---~ for _, fnc in next, { ... } do
---~ local typ = type(fnc)
---~ if typ == "function" then
---~ w[#w+1] = fnc
---~ elseif typ == "string" then
---~ w[#w+1] = function(value) set(fnc,value,nesting) end
---~ end
---~ end
---~ end
---~ function trackers.enable(what)
---~ local e = trackers.enable
---~ trackers.enable, done = enable, { }
---~ enable(string.simpleesc(what))
---~ trackers.enable, done = e, { }
---~ end
---~ function trackers.disable(what)
---~ local e = trackers.disable
---~ trackers.disable, done = disable, { }
---~ disable(string.simpleesc(what))
---~ trackers.disable, done = e, { }
---~ end
---~ function trackers.reset()
---~ done = { }
---~ reset()
---~ end
---~ function trackers.list() -- pattern
---~ local list = table.sortedkeys(data)
---~ local user, system = { }, { }
---~ for l=1,#list do
---~ local what = list[l]
---~ if find(what,"^%*") then
---~ system[#system+1] = what
---~ else
---~ user[#user+1] = what
---~ end
---~ end
---~ return user, system
---~ end
-
end -- of closure
@@ -3717,8 +3631,7 @@ if not modules then modules = { } end modules ['luat-env'] = {
-- evolved before bytecode arrays were available and so a lot of
-- code has disappeared already.
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local format = string.format
@@ -3909,12 +3822,12 @@ function environment.luafilechunk(filename) -- used for loading lua bytecode in
filename = file.replacesuffix(filename, "lua")
local fullname = environment.luafile(filename)
if fullname and fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading file %s", fullname)
end
return environment.loadedluacode(fullname)
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
return nil
@@ -3934,7 +3847,7 @@ function environment.loadluafile(filename, version)
-- when not overloaded by explicit suffix we look for a luc file first
local fullname = (lucname and environment.luafile(lucname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
@@ -3952,7 +3865,7 @@ function environment.loadluafile(filename, version)
if v == version then
return true
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","version mismatch for %s: lua=%s, luc=%s", filename, v, version)
end
environment.loadluafile(filename)
@@ -3963,12 +3876,12 @@ function environment.loadluafile(filename, version)
end
fullname = (luaname and environment.luafile(luaname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
if not chunk then
- if verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
else
@@ -4363,7 +4276,7 @@ end
function logs.setprogram(_name_,_banner_,_verbose_)
name, banner = _name_, _banner_
if _verbose_ then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
end
logs.set_method("tex")
logs.report = report -- also used in libraries
@@ -4376,9 +4289,9 @@ end
function logs.setverbose(what)
if what then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
else
- trackers.disable("resolvers.verbose")
+ trackers.disable("resolvers.locating")
end
logs.verbose = what or false
end
@@ -4483,11 +4396,11 @@ local format, gsub, find, lower, upper, match, gmatch = string.format, string.gs
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type = next, type
-local trace_locating, trace_detail, trace_verbose = false, false, false
+local trace_locating, trace_detail, trace_expansions = false, false, false
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
-trackers.register("resolvers.detail", function(v) trace_detail = v trackers.enable("resolvers.verbose,resolvers.detail") end)
+trackers.register("resolvers.locating", function(v) trace_locating = v end)
+trackers.register("resolvers.details", function(v) trace_detail = v end)
+trackers.register("resolvers.expansions", function(v) trace_expansions = v end) -- todo
if not resolvers then
resolvers = {
@@ -4796,37 +4709,43 @@ end
-- work that well; the parsing is ok, but dealing with the resulting
-- table is a pain because we need to work inside-out recursively
+local function do_first(a,b)
+ local t = { }
+ for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_second(a,b)
+ local t = { }
+ for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_both(a,b)
+ local t = { }
+ for sa in gmatch(a,"[^,]+") do
+ for sb in gmatch(b,"[^,]+") do
+ t[#t+1] = sa .. sb
+ end
+ end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_three(a,b,c)
+ return a .. b.. c
+end
+
local function splitpathexpr(str, t, validate)
-- no need for further optimization as it is only called a
- -- few times, we can use lpeg for the sub; we could move
- -- the local functions outside the body
+ -- few times, we can use lpeg for the sub
+ if trace_expansion then
+ logs.report("fileio","expanding variable '%s'",str)
+ end
t = t or { }
str = gsub(str,",}",",@}")
str = gsub(str,"{,","{@,")
-- str = "@" .. str .. "@"
local ok, done
- local function do_first(a,b)
- local t = { }
- for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_second(a,b)
- local t = { }
- for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_both(a,b)
- local t = { }
- for sa in gmatch(a,"[^,]+") do
- for sb in gmatch(b,"[^,]+") do
- t[#t+1] = sa .. sb
- end
- end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_three(a,b,c)
- return a .. b.. c
- end
while true do
done = false
while true do
@@ -4857,6 +4776,11 @@ local function splitpathexpr(str, t, validate)
t[#t+1] = s
end
end
+ if trace_expansions then
+ for k,v in ipairs(t) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
return t
end
@@ -4919,14 +4843,14 @@ function resolvers.getownpath()
local olddir = lfs.currentdir()
if lfs.chdir(p) then
local pp = lfs.currentdir()
- if trace_verbose and p ~= pp then
- logs.report("fileio","following symlink %s to %s",p,pp)
+ if trace_locating and p ~= pp then
+ logs.report("fileio","following symlink '%s' to '%s'",p,pp)
end
resolvers.ownpath = pp
lfs.chdir(olddir)
else
- if trace_verbose then
- logs.report("fileio","unable to check path %s",p)
+ if trace_locating then
+ logs.report("fileio","unable to check path '%s'",p)
end
resolvers.ownpath = p
end
@@ -4955,10 +4879,10 @@ local function identify_own()
if resolvers.env('TEXMFCNF') == "" then os.env['TEXMFCNF'] = resolvers.cnfdefault end
if resolvers.env('TEXOS') == "" then os.env['TEXOS'] = resolvers.env('SELFAUTODIR') end
if resolvers.env('TEXROOT') == "" then os.env['TEXROOT'] = resolvers.env('SELFAUTOPARENT') end
- if trace_verbose then
+ if trace_locating then
for i=1,#own_places do
local v = own_places[i]
- logs.report("fileio","variable %s set to %s",v,resolvers.env(v) or "unknown")
+ logs.report("fileio","variable '%s' set to '%s'",v,resolvers.env(v) or "unknown")
end
end
identify_own = function() end
@@ -4990,10 +4914,8 @@ end
local function load_cnf_file(fname)
fname = resolvers.clean_path(fname)
local lname = file.replacesuffix(fname,'lua')
- local f = io.open(lname)
- if f then -- this will go
- f:close()
- local dname = file.dirname(fname)
+ if lfs.isfile(lname) then
+ local dname = file.dirname(fname) -- fname ?
if not instance.configuration[dname] then
resolvers.load_data(dname,'configuration',lname and file.basename(lname))
instance.order[#instance.order+1] = instance.configuration[dname]
@@ -5001,8 +4923,8 @@ local function load_cnf_file(fname)
else
f = io.open(fname)
if f then
- if trace_verbose then
- logs.report("fileio","loading %s", fname)
+ if trace_locating then
+ logs.report("fileio","loading configuration file %s", fname)
end
local line, data, n, k, v
local dname = file.dirname(fname)
@@ -5036,8 +4958,8 @@ local function load_cnf_file(fname)
end
end
f:close()
- elseif trace_verbose then
- logs.report("fileio","skipping %s", fname)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'", fname)
end
end
end
@@ -5064,8 +4986,11 @@ function resolvers.load_cnf()
end
end
-- instance.cnffiles contain complete names now !
+ -- we still use a funny mix of cnf and new but soon
+ -- we will switch to lua exclusively as we only use
+ -- the file to collect the tree roots
if #instance.cnffiles == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","no cnf files found (TEXMFCNF may not be set/known)")
end
else
@@ -5132,14 +5057,14 @@ end
function resolvers.append_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash append: %s",tag)
+ logs.report("fileio","hash '%s' appended",tag)
end
insert(instance.hashes, { ['type']=type, ['tag']=tag, ['name']=name } )
end
function resolvers.prepend_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash prepend: %s",tag)
+ logs.report("fileio","hash '%s' prepended",tag)
end
insert(instance.hashes, 1, { ['type']=type, ['tag']=tag, ['name']=name } )
end
@@ -5164,8 +5089,8 @@ end
function resolvers.locatelists()
for _, path in ipairs(resolvers.clean_path_list('TEXMF')) do
- if trace_verbose then
- logs.report("fileio","locating list of %s",path)
+ if trace_locating then
+ logs.report("fileio","locating list of '%s'",path)
end
resolvers.locatedatabase(file.collapse_path(path))
end
@@ -5178,11 +5103,11 @@ end
function resolvers.locators.tex(specification)
if specification and specification ~= '' and lfs.isdir(specification) then
if trace_locating then
- logs.report("fileio",'! tex locator found: %s',specification)
+ logs.report("fileio","tex locator '%s' found",specification)
end
resolvers.append_hash('file',specification,filename)
elseif trace_locating then
- logs.report("fileio",'? tex locator not found: %s',specification)
+ logs.report("fileio","tex locator '%s' not found",specification)
end
end
@@ -5225,8 +5150,8 @@ local weird = lpeg.P(".")^1 + lpeg.anywhere(lpeg.S("~`!#$%^&*()={}[]:;\"\'||<>,?
function resolvers.generators.tex(specification)
local tag = specification
- if trace_verbose then
- logs.report("fileio","scanning path %s",specification)
+ if trace_locating then
+ logs.report("fileio","scanning path '%s'",specification)
end
instance.files[tag] = { }
local files = instance.files[tag]
@@ -5275,7 +5200,7 @@ function resolvers.generators.tex(specification)
end
end
action()
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","%s files found on %s directories with %s uppercase remappings",n,m,r)
end
end
@@ -5305,7 +5230,12 @@ local function split_kpse_path(str) -- beware, this can be either a path or a {s
else
found = checkedsplit(str,io.pathseparator)
end
- -- print(table.serialize(found))
+ if trace_expansions then
+ logs.report("fileio","splitting path specification '%s'",str)
+ for k,v in ipairs(found) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
cache[str] = found
end
return found
@@ -5335,6 +5265,7 @@ function resolvers.joinconfig()
end
end
end
+
function resolvers.split_path(str)
if type(str) == 'table' then
return str
@@ -5342,6 +5273,7 @@ function resolvers.split_path(str)
return split_kpse_path(str)
end
end
+
function resolvers.join_path(str)
if type(str) == 'table' then
return file.join_path(str)
@@ -5430,12 +5362,18 @@ function resolvers.serialize(files)
return concat(t,"\n")
end
+local data_state = { }
+
+function resolvers.data_state()
+ return data_state or { }
+end
+
function resolvers.save_data(dataname, makename) -- untested without cache overload
for cachename, files in next, instance[dataname] do
local name = (makename or file.join)(cachename,dataname)
local luaname, lucname = name .. ".lua", name .. ".luc"
- if trace_verbose then
- logs.report("fileio","preparing %s for %s",dataname,cachename)
+ if trace_locating then
+ logs.report("fileio","preparing '%s' for '%s'",dataname,cachename)
end
for k, v in next, files do
if type(v) == "table" and #v == 1 then
@@ -5449,24 +5387,25 @@ function resolvers.save_data(dataname, makename) -- untested without cache overl
date = os.date("%Y-%m-%d"),
time = os.date("%H:%M:%S"),
content = files,
+ uuid = os.uuid(),
}
local ok = io.savedata(luaname,resolvers.serialize(data))
if ok then
- if trace_verbose then
- logs.report("fileio","%s saved in %s",dataname,luaname)
+ if trace_locating then
+ logs.report("fileio","'%s' saved in '%s'",dataname,luaname)
end
if utils.lua.compile(luaname,lucname,false,true) then -- no cleanup but strip
- if trace_verbose then
- logs.report("fileio","%s compiled to %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","'%s' compiled to '%s'",dataname,lucname)
end
else
- if trace_verbose then
- logs.report("fileio","compiling failed for %s, deleting file %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","compiling failed for '%s', deleting file '%s'",dataname,lucname)
end
os.remove(lucname)
end
- elseif trace_verbose then
- logs.report("fileio","unable to save %s in %s (access error)",dataname,luaname)
+ elseif trace_locating then
+ logs.report("fileio","unable to save '%s' in '%s' (access error)",dataname,luaname)
end
end
end
@@ -5478,19 +5417,20 @@ function resolvers.load_data(pathname,dataname,filename,makename) -- untested wi
if blob then
local data = blob()
if data and data.content and data.type == dataname and data.version == resolvers.cacheversion then
- if trace_verbose then
- logs.report("fileio","loading %s for %s from %s",dataname,pathname,filename)
+ data_state[#data_state+1] = data.uuid
+ if trace_locating then
+ logs.report("fileio","loading '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = data.content
else
- if trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ if trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
end
@@ -5516,8 +5456,8 @@ function resolvers.loadnewconfig()
if blob then
local data = blob()
if data then
- if trace_verbose then
- logs.report("fileio","loading configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","loading configuration file '%s'",filename)
end
if true then
-- flatten to variable.progname
@@ -5538,14 +5478,14 @@ function resolvers.loadnewconfig()
instance['setup'][pathname] = data
end
else
- if trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance['setup'][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance.order[#instance.order+1] = instance.setup[pathname]
if instance.loaderror then break end
@@ -5811,9 +5751,9 @@ function resolvers.isreadable.file(name)
local readable = lfs.isfile(name) -- brrr
if trace_detail then
if readable then
- logs.report("fileio","+ readable: %s",name)
+ logs.report("fileio","file '%s' is readable",name)
else
- logs.report("fileio","- readable: %s", name)
+ logs.report("fileio","file '%s' is not readable", name)
end
end
return readable
@@ -5829,7 +5769,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","? blobpath asked: %s",fname)
+ logs.report("fileio","using blobpath '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -5845,7 +5785,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio",'? blobpath do: %s (%s)',blobpath,bname)
+ logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -5879,7 +5819,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio",'! blobpath no: %s (%s)',blobpath,bname)
+ logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
end
end
end
@@ -5936,7 +5876,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
if instance.found[stamp] then
if trace_locating then
- logs.report("fileio",'! remembered: %s',filename)
+ logs.report("fileio","remembering file '%s'",filename)
end
return instance.found[stamp]
end
@@ -5944,7 +5884,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not dangerous[instance.format or "?"] then
if resolvers.isreadable.file(filename) then
if trace_detail then
- logs.report("fileio",'= found directly: %s',filename)
+ logs.report("fileio","file '%s' found directly",filename)
end
instance.found[stamp] = { filename }
return { filename }
@@ -5952,13 +5892,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
if find(filename,'%*') then
if trace_locating then
- logs.report("fileio",'! wildcard: %s', filename)
+ logs.report("fileio","checking wildcard '%s'", filename)
end
result = resolvers.find_wildcard_files(filename)
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
- logs.report("fileio",'! qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
result = { filename }
else
@@ -5968,7 +5908,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. ".tex"
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing standard filetype: tex')
+ logs.report("fileio","no suffix, forcing standard filetype 'tex'")
end
result, ok = { forcedname }, true
end
@@ -5978,7 +5918,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. "." .. s
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing format filetype: %s', s)
+ logs.report("fileio","no suffix, forcing format filetype '%s'", s)
end
result, ok = { forcedname }, true
break
@@ -6028,7 +5968,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- end
end
if not ok and trace_locating then
- logs.report("fileio",'? qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
end
else
@@ -6047,12 +5987,12 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.format_of_suffix(forcedname)
if trace_locating then
- logs.report("fileio",'! forcing filetype: %s',filetype)
+ logs.report("fileio","forcing filetype '%s'",filetype)
end
else
filetype = resolvers.format_of_suffix(filename)
if trace_locating then
- logs.report("fileio",'! using suffix based filetype: %s',filetype)
+ logs.report("fileio","using suffix based filetype '%s'",filetype)
end
end
else
@@ -6064,7 +6004,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
filetype = instance.format
if trace_locating then
- logs.report("fileio",'! using given filetype: %s',filetype)
+ logs.report("fileio","using given filetype '%s'",filetype)
end
end
local typespec = resolvers.variable_of_format(filetype)
@@ -6072,9 +6012,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not pathlist or #pathlist == 0 then
-- no pathlist, access check only / todo == wildcard
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
- logs.report("fileio",'? filetype: %s',filetype or '?')
- logs.report("fileio",'? wanted files: %s',concat(wantedfiles," | "))
+ logs.report("fileio","checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
end
for k=1,#wantedfiles do
local fname = wantedfiles[k]
@@ -6097,7 +6035,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local filelist = collect_files(wantedfiles)
local doscan, recurse
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
+ logs.report("fileio","checking filename '%s'",filename)
end
-- a bit messy ... esp the doscan setting here
for k=1,#pathlist do
@@ -6118,7 +6056,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local f = fl[2]
if find(f,expr) then
if trace_detail then
- logs.report("fileio",'= found in hash: %s',f)
+ logs.report("fileio","file '%s' found in hash",f)
end
--- todo, test for readable
result[#result+1] = fl[3]
@@ -6140,7 +6078,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local fname = file.join(ppname,w)
if resolvers.isreadable.file(fname) then
if trace_detail then
- logs.report("fileio",'= found by scanning: %s',fname)
+ logs.report("fileio","found '%s' by scanning",fname)
end
result[#result+1] = fname
done = true
@@ -6313,9 +6251,9 @@ function resolvers.load(option)
statistics.starttiming(instance)
resolvers.resetconfig()
resolvers.identify_cnf()
- resolvers.load_lua()
+ resolvers.load_lua() -- will become the new method
resolvers.expand_variables()
- resolvers.load_cnf()
+ resolvers.load_cnf() -- will be skipped when we have a lua file
resolvers.expand_variables()
if option ~= "nofiles" then
resolvers.load_hash()
@@ -6327,14 +6265,14 @@ end
function resolvers.for_files(command, files, filetype, mustexist)
if files and #files > 0 then
local function report(str)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio",str) -- has already verbose
else
print(str)
end
end
- if trace_verbose then
- report('')
+ if trace_locating then
+ report('') -- ?
end
for _, file in ipairs(files) do
local result = command(file,filetype,mustexist)
@@ -6400,7 +6338,7 @@ function resolvers.methodhandler(what, filename, filetype) -- ...
local scheme = specification.scheme
if resolvers[what][scheme] then
if trace_locating then
- logs.report("fileio",'= handler: %s -> %s -> %s',specification.original,what,table.sequenced(specification))
+ logs.report("fileio","handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolvers[what][scheme](filename,filetype) -- todo: specification
else
@@ -6736,8 +6674,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub
local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end)
local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end)
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
--[[ldx--
<p>Once we found ourselves defining similar cache constructs
@@ -6861,8 +6797,7 @@ if not modules then modules = { } end modules ['data-use'] = {
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-- since we want to use the cache instead of the tree, we will now
-- reimplement the saver.
@@ -7101,47 +7036,47 @@ if not modules then modules = { } end modules ['data-aux'] = {
local find = string.find
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
function resolvers.update_script(oldname,newname) -- oldname -> own.name, not per se a suffix
local scriptpath = "scripts/context/lua"
newname = file.addsuffix(newname,"lua")
local oldscript = resolvers.clean_path(oldname)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","to be replaced old script %s", oldscript)
end
local newscripts = resolvers.find_files(newname) or { }
if #newscripts == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unable to locate new script")
end
else
for i=1,#newscripts do
local newscript = resolvers.clean_path(newscripts[i])
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","checking new script %s", newscript)
end
if oldscript == newscript then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old and new script are the same")
end
elseif not find(newscript,scriptpath) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","new script should come from %s",scriptpath)
end
elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","invalid new script name")
end
else
local newdata = io.loaddata(newscript)
if newdata then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old script content replaced by new content")
end
io.savedata(oldscript,newdata)
break
- elseif trace_verbose then
+ elseif trace_locating then
logs.report("fileio","unable to load new script")
end
end
@@ -7399,6 +7334,7 @@ messages.help = [[
--engine=str target engine
--progname=str format or backend
--pattern=str filter variables
+--trackers=list enable given trackers
]]
function runners.make_format(texname)
@@ -7543,6 +7479,12 @@ local ok = true
-- private option --noluc for testing errors in the stub
+local trackspec = environment.argument("trackers") or environment.argument("track")
+
+if trackspec then
+ trackers.enable(trackspec)
+end
+
if environment.arguments["find-file"] then
resolvers.load()
instance.format = environment.arguments["format"] or instance.format
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 580e1a46f..26f5c4c2a 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -3332,92 +3332,6 @@ function directives.disable(...)
d(...)
end
---~ -- old code:
---
---~ trackers = trackers or { }
---~ local data, done = { }, { }
---~ local function set(what,value)
---~ if type(what) == "string" then
---~ what = aux.settings_to_array(what) -- inefficient but ok
---~ end
---~ for i=1,#what do
---~ local w = what[i]
---~ for d, f in next, data do
---~ if done[d] then
---~ -- prevent recursion due to wildcards
---~ elseif find(d,w) then
---~ done[d] = true
---~ for i=1,#f do
---~ f[i](value)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ local function reset()
---~ for d, f in next, data do
---~ for i=1,#f do
---~ f[i](false)
---~ end
---~ end
---~ end
---~ local function enable(what)
---~ set(what,true)
---~ end
---~ local function disable(what)
---~ if not what or what == "" then
---~ done = { }
---~ reset()
---~ else
---~ set(what,false)
---~ end
---~ end
---~ function trackers.register(what,...)
---~ what = lower(what)
---~ local w = data[what]
---~ if not w then
---~ w = { }
---~ data[what] = w
---~ end
---~ for _, fnc in next, { ... } do
---~ local typ = type(fnc)
---~ if typ == "function" then
---~ w[#w+1] = fnc
---~ elseif typ == "string" then
---~ w[#w+1] = function(value) set(fnc,value,nesting) end
---~ end
---~ end
---~ end
---~ function trackers.enable(what)
---~ local e = trackers.enable
---~ trackers.enable, done = enable, { }
---~ enable(string.simpleesc(what))
---~ trackers.enable, done = e, { }
---~ end
---~ function trackers.disable(what)
---~ local e = trackers.disable
---~ trackers.disable, done = disable, { }
---~ disable(string.simpleesc(what))
---~ trackers.disable, done = e, { }
---~ end
---~ function trackers.reset()
---~ done = { }
---~ reset()
---~ end
---~ function trackers.list() -- pattern
---~ local list = table.sortedkeys(data)
---~ local user, system = { }, { }
---~ for l=1,#list do
---~ local what = list[l]
---~ if find(what,"^%*") then
---~ system[#system+1] = what
---~ else
---~ user[#user+1] = what
---~ end
---~ end
---~ return user, system
---~ end
-
end -- of closure
@@ -6449,8 +6363,7 @@ if not modules then modules = { } end modules ['luat-env'] = {
-- evolved before bytecode arrays were available and so a lot of
-- code has disappeared already.
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local format = string.format
@@ -6641,12 +6554,12 @@ function environment.luafilechunk(filename) -- used for loading lua bytecode in
filename = file.replacesuffix(filename, "lua")
local fullname = environment.luafile(filename)
if fullname and fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading file %s", fullname)
end
return environment.loadedluacode(fullname)
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
return nil
@@ -6666,7 +6579,7 @@ function environment.loadluafile(filename, version)
-- when not overloaded by explicit suffix we look for a luc file first
local fullname = (lucname and environment.luafile(lucname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
@@ -6684,7 +6597,7 @@ function environment.loadluafile(filename, version)
if v == version then
return true
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","version mismatch for %s: lua=%s, luc=%s", filename, v, version)
end
environment.loadluafile(filename)
@@ -6695,12 +6608,12 @@ function environment.loadluafile(filename, version)
end
fullname = (luaname and environment.luafile(luaname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
if not chunk then
- if verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
else
@@ -7095,7 +7008,7 @@ end
function logs.setprogram(_name_,_banner_,_verbose_)
name, banner = _name_, _banner_
if _verbose_ then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
end
logs.set_method("tex")
logs.report = report -- also used in libraries
@@ -7108,9 +7021,9 @@ end
function logs.setverbose(what)
if what then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
else
- trackers.disable("resolvers.verbose")
+ trackers.disable("resolvers.locating")
end
logs.verbose = what or false
end
@@ -7215,11 +7128,11 @@ local format, gsub, find, lower, upper, match, gmatch = string.format, string.gs
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type = next, type
-local trace_locating, trace_detail, trace_verbose = false, false, false
+local trace_locating, trace_detail, trace_expansions = false, false, false
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
-trackers.register("resolvers.detail", function(v) trace_detail = v trackers.enable("resolvers.verbose,resolvers.detail") end)
+trackers.register("resolvers.locating", function(v) trace_locating = v end)
+trackers.register("resolvers.details", function(v) trace_detail = v end)
+trackers.register("resolvers.expansions", function(v) trace_expansions = v end) -- todo
if not resolvers then
resolvers = {
@@ -7528,37 +7441,43 @@ end
-- work that well; the parsing is ok, but dealing with the resulting
-- table is a pain because we need to work inside-out recursively
+local function do_first(a,b)
+ local t = { }
+ for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_second(a,b)
+ local t = { }
+ for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_both(a,b)
+ local t = { }
+ for sa in gmatch(a,"[^,]+") do
+ for sb in gmatch(b,"[^,]+") do
+ t[#t+1] = sa .. sb
+ end
+ end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_three(a,b,c)
+ return a .. b.. c
+end
+
local function splitpathexpr(str, t, validate)
-- no need for further optimization as it is only called a
- -- few times, we can use lpeg for the sub; we could move
- -- the local functions outside the body
+ -- few times, we can use lpeg for the sub
+ if trace_expansion then
+ logs.report("fileio","expanding variable '%s'",str)
+ end
t = t or { }
str = gsub(str,",}",",@}")
str = gsub(str,"{,","{@,")
-- str = "@" .. str .. "@"
local ok, done
- local function do_first(a,b)
- local t = { }
- for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_second(a,b)
- local t = { }
- for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_both(a,b)
- local t = { }
- for sa in gmatch(a,"[^,]+") do
- for sb in gmatch(b,"[^,]+") do
- t[#t+1] = sa .. sb
- end
- end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_three(a,b,c)
- return a .. b.. c
- end
while true do
done = false
while true do
@@ -7589,6 +7508,11 @@ local function splitpathexpr(str, t, validate)
t[#t+1] = s
end
end
+ if trace_expansions then
+ for k,v in ipairs(t) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
return t
end
@@ -7651,14 +7575,14 @@ function resolvers.getownpath()
local olddir = lfs.currentdir()
if lfs.chdir(p) then
local pp = lfs.currentdir()
- if trace_verbose and p ~= pp then
- logs.report("fileio","following symlink %s to %s",p,pp)
+ if trace_locating and p ~= pp then
+ logs.report("fileio","following symlink '%s' to '%s'",p,pp)
end
resolvers.ownpath = pp
lfs.chdir(olddir)
else
- if trace_verbose then
- logs.report("fileio","unable to check path %s",p)
+ if trace_locating then
+ logs.report("fileio","unable to check path '%s'",p)
end
resolvers.ownpath = p
end
@@ -7687,10 +7611,10 @@ local function identify_own()
if resolvers.env('TEXMFCNF') == "" then os.env['TEXMFCNF'] = resolvers.cnfdefault end
if resolvers.env('TEXOS') == "" then os.env['TEXOS'] = resolvers.env('SELFAUTODIR') end
if resolvers.env('TEXROOT') == "" then os.env['TEXROOT'] = resolvers.env('SELFAUTOPARENT') end
- if trace_verbose then
+ if trace_locating then
for i=1,#own_places do
local v = own_places[i]
- logs.report("fileio","variable %s set to %s",v,resolvers.env(v) or "unknown")
+ logs.report("fileio","variable '%s' set to '%s'",v,resolvers.env(v) or "unknown")
end
end
identify_own = function() end
@@ -7722,10 +7646,8 @@ end
local function load_cnf_file(fname)
fname = resolvers.clean_path(fname)
local lname = file.replacesuffix(fname,'lua')
- local f = io.open(lname)
- if f then -- this will go
- f:close()
- local dname = file.dirname(fname)
+ if lfs.isfile(lname) then
+ local dname = file.dirname(fname) -- fname ?
if not instance.configuration[dname] then
resolvers.load_data(dname,'configuration',lname and file.basename(lname))
instance.order[#instance.order+1] = instance.configuration[dname]
@@ -7733,8 +7655,8 @@ local function load_cnf_file(fname)
else
f = io.open(fname)
if f then
- if trace_verbose then
- logs.report("fileio","loading %s", fname)
+ if trace_locating then
+ logs.report("fileio","loading configuration file %s", fname)
end
local line, data, n, k, v
local dname = file.dirname(fname)
@@ -7768,8 +7690,8 @@ local function load_cnf_file(fname)
end
end
f:close()
- elseif trace_verbose then
- logs.report("fileio","skipping %s", fname)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'", fname)
end
end
end
@@ -7796,8 +7718,11 @@ function resolvers.load_cnf()
end
end
-- instance.cnffiles contain complete names now !
+ -- we still use a funny mix of cnf and new but soon
+ -- we will switch to lua exclusively as we only use
+ -- the file to collect the tree roots
if #instance.cnffiles == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","no cnf files found (TEXMFCNF may not be set/known)")
end
else
@@ -7864,14 +7789,14 @@ end
function resolvers.append_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash append: %s",tag)
+ logs.report("fileio","hash '%s' appended",tag)
end
insert(instance.hashes, { ['type']=type, ['tag']=tag, ['name']=name } )
end
function resolvers.prepend_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash prepend: %s",tag)
+ logs.report("fileio","hash '%s' prepended",tag)
end
insert(instance.hashes, 1, { ['type']=type, ['tag']=tag, ['name']=name } )
end
@@ -7896,8 +7821,8 @@ end
function resolvers.locatelists()
for _, path in ipairs(resolvers.clean_path_list('TEXMF')) do
- if trace_verbose then
- logs.report("fileio","locating list of %s",path)
+ if trace_locating then
+ logs.report("fileio","locating list of '%s'",path)
end
resolvers.locatedatabase(file.collapse_path(path))
end
@@ -7910,11 +7835,11 @@ end
function resolvers.locators.tex(specification)
if specification and specification ~= '' and lfs.isdir(specification) then
if trace_locating then
- logs.report("fileio",'! tex locator found: %s',specification)
+ logs.report("fileio","tex locator '%s' found",specification)
end
resolvers.append_hash('file',specification,filename)
elseif trace_locating then
- logs.report("fileio",'? tex locator not found: %s',specification)
+ logs.report("fileio","tex locator '%s' not found",specification)
end
end
@@ -7957,8 +7882,8 @@ local weird = lpeg.P(".")^1 + lpeg.anywhere(lpeg.S("~`!#$%^&*()={}[]:;\"\'||<>,?
function resolvers.generators.tex(specification)
local tag = specification
- if trace_verbose then
- logs.report("fileio","scanning path %s",specification)
+ if trace_locating then
+ logs.report("fileio","scanning path '%s'",specification)
end
instance.files[tag] = { }
local files = instance.files[tag]
@@ -8007,7 +7932,7 @@ function resolvers.generators.tex(specification)
end
end
action()
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","%s files found on %s directories with %s uppercase remappings",n,m,r)
end
end
@@ -8037,7 +7962,12 @@ local function split_kpse_path(str) -- beware, this can be either a path or a {s
else
found = checkedsplit(str,io.pathseparator)
end
- -- print(table.serialize(found))
+ if trace_expansions then
+ logs.report("fileio","splitting path specification '%s'",str)
+ for k,v in ipairs(found) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
cache[str] = found
end
return found
@@ -8067,6 +7997,7 @@ function resolvers.joinconfig()
end
end
end
+
function resolvers.split_path(str)
if type(str) == 'table' then
return str
@@ -8074,6 +8005,7 @@ function resolvers.split_path(str)
return split_kpse_path(str)
end
end
+
function resolvers.join_path(str)
if type(str) == 'table' then
return file.join_path(str)
@@ -8162,12 +8094,18 @@ function resolvers.serialize(files)
return concat(t,"\n")
end
+local data_state = { }
+
+function resolvers.data_state()
+ return data_state or { }
+end
+
function resolvers.save_data(dataname, makename) -- untested without cache overload
for cachename, files in next, instance[dataname] do
local name = (makename or file.join)(cachename,dataname)
local luaname, lucname = name .. ".lua", name .. ".luc"
- if trace_verbose then
- logs.report("fileio","preparing %s for %s",dataname,cachename)
+ if trace_locating then
+ logs.report("fileio","preparing '%s' for '%s'",dataname,cachename)
end
for k, v in next, files do
if type(v) == "table" and #v == 1 then
@@ -8181,24 +8119,25 @@ function resolvers.save_data(dataname, makename) -- untested without cache overl
date = os.date("%Y-%m-%d"),
time = os.date("%H:%M:%S"),
content = files,
+ uuid = os.uuid(),
}
local ok = io.savedata(luaname,resolvers.serialize(data))
if ok then
- if trace_verbose then
- logs.report("fileio","%s saved in %s",dataname,luaname)
+ if trace_locating then
+ logs.report("fileio","'%s' saved in '%s'",dataname,luaname)
end
if utils.lua.compile(luaname,lucname,false,true) then -- no cleanup but strip
- if trace_verbose then
- logs.report("fileio","%s compiled to %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","'%s' compiled to '%s'",dataname,lucname)
end
else
- if trace_verbose then
- logs.report("fileio","compiling failed for %s, deleting file %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","compiling failed for '%s', deleting file '%s'",dataname,lucname)
end
os.remove(lucname)
end
- elseif trace_verbose then
- logs.report("fileio","unable to save %s in %s (access error)",dataname,luaname)
+ elseif trace_locating then
+ logs.report("fileio","unable to save '%s' in '%s' (access error)",dataname,luaname)
end
end
end
@@ -8210,19 +8149,20 @@ function resolvers.load_data(pathname,dataname,filename,makename) -- untested wi
if blob then
local data = blob()
if data and data.content and data.type == dataname and data.version == resolvers.cacheversion then
- if trace_verbose then
- logs.report("fileio","loading %s for %s from %s",dataname,pathname,filename)
+ data_state[#data_state+1] = data.uuid
+ if trace_locating then
+ logs.report("fileio","loading '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = data.content
else
- if trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ if trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
end
@@ -8248,8 +8188,8 @@ function resolvers.loadnewconfig()
if blob then
local data = blob()
if data then
- if trace_verbose then
- logs.report("fileio","loading configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","loading configuration file '%s'",filename)
end
if true then
-- flatten to variable.progname
@@ -8270,14 +8210,14 @@ function resolvers.loadnewconfig()
instance['setup'][pathname] = data
end
else
- if trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance['setup'][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance.order[#instance.order+1] = instance.setup[pathname]
if instance.loaderror then break end
@@ -8543,9 +8483,9 @@ function resolvers.isreadable.file(name)
local readable = lfs.isfile(name) -- brrr
if trace_detail then
if readable then
- logs.report("fileio","+ readable: %s",name)
+ logs.report("fileio","file '%s' is readable",name)
else
- logs.report("fileio","- readable: %s", name)
+ logs.report("fileio","file '%s' is not readable", name)
end
end
return readable
@@ -8561,7 +8501,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","? blobpath asked: %s",fname)
+ logs.report("fileio","using blobpath '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -8577,7 +8517,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio",'? blobpath do: %s (%s)',blobpath,bname)
+ logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -8611,7 +8551,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio",'! blobpath no: %s (%s)',blobpath,bname)
+ logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
end
end
end
@@ -8668,7 +8608,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
if instance.found[stamp] then
if trace_locating then
- logs.report("fileio",'! remembered: %s',filename)
+ logs.report("fileio","remembering file '%s'",filename)
end
return instance.found[stamp]
end
@@ -8676,7 +8616,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not dangerous[instance.format or "?"] then
if resolvers.isreadable.file(filename) then
if trace_detail then
- logs.report("fileio",'= found directly: %s',filename)
+ logs.report("fileio","file '%s' found directly",filename)
end
instance.found[stamp] = { filename }
return { filename }
@@ -8684,13 +8624,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
if find(filename,'%*') then
if trace_locating then
- logs.report("fileio",'! wildcard: %s', filename)
+ logs.report("fileio","checking wildcard '%s'", filename)
end
result = resolvers.find_wildcard_files(filename)
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
- logs.report("fileio",'! qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
result = { filename }
else
@@ -8700,7 +8640,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. ".tex"
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing standard filetype: tex')
+ logs.report("fileio","no suffix, forcing standard filetype 'tex'")
end
result, ok = { forcedname }, true
end
@@ -8710,7 +8650,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. "." .. s
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing format filetype: %s', s)
+ logs.report("fileio","no suffix, forcing format filetype '%s'", s)
end
result, ok = { forcedname }, true
break
@@ -8760,7 +8700,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- end
end
if not ok and trace_locating then
- logs.report("fileio",'? qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
end
else
@@ -8779,12 +8719,12 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.format_of_suffix(forcedname)
if trace_locating then
- logs.report("fileio",'! forcing filetype: %s',filetype)
+ logs.report("fileio","forcing filetype '%s'",filetype)
end
else
filetype = resolvers.format_of_suffix(filename)
if trace_locating then
- logs.report("fileio",'! using suffix based filetype: %s',filetype)
+ logs.report("fileio","using suffix based filetype '%s'",filetype)
end
end
else
@@ -8796,7 +8736,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
filetype = instance.format
if trace_locating then
- logs.report("fileio",'! using given filetype: %s',filetype)
+ logs.report("fileio","using given filetype '%s'",filetype)
end
end
local typespec = resolvers.variable_of_format(filetype)
@@ -8804,9 +8744,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not pathlist or #pathlist == 0 then
-- no pathlist, access check only / todo == wildcard
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
- logs.report("fileio",'? filetype: %s',filetype or '?')
- logs.report("fileio",'? wanted files: %s',concat(wantedfiles," | "))
+ logs.report("fileio","checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
end
for k=1,#wantedfiles do
local fname = wantedfiles[k]
@@ -8829,7 +8767,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local filelist = collect_files(wantedfiles)
local doscan, recurse
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
+ logs.report("fileio","checking filename '%s'",filename)
end
-- a bit messy ... esp the doscan setting here
for k=1,#pathlist do
@@ -8850,7 +8788,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local f = fl[2]
if find(f,expr) then
if trace_detail then
- logs.report("fileio",'= found in hash: %s',f)
+ logs.report("fileio","file '%s' found in hash",f)
end
--- todo, test for readable
result[#result+1] = fl[3]
@@ -8872,7 +8810,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local fname = file.join(ppname,w)
if resolvers.isreadable.file(fname) then
if trace_detail then
- logs.report("fileio",'= found by scanning: %s',fname)
+ logs.report("fileio","found '%s' by scanning",fname)
end
result[#result+1] = fname
done = true
@@ -9045,9 +8983,9 @@ function resolvers.load(option)
statistics.starttiming(instance)
resolvers.resetconfig()
resolvers.identify_cnf()
- resolvers.load_lua()
+ resolvers.load_lua() -- will become the new method
resolvers.expand_variables()
- resolvers.load_cnf()
+ resolvers.load_cnf() -- will be skipped when we have a lua file
resolvers.expand_variables()
if option ~= "nofiles" then
resolvers.load_hash()
@@ -9059,14 +8997,14 @@ end
function resolvers.for_files(command, files, filetype, mustexist)
if files and #files > 0 then
local function report(str)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio",str) -- has already verbose
else
print(str)
end
end
- if trace_verbose then
- report('')
+ if trace_locating then
+ report('') -- ?
end
for _, file in ipairs(files) do
local result = command(file,filetype,mustexist)
@@ -9132,7 +9070,7 @@ function resolvers.methodhandler(what, filename, filetype) -- ...
local scheme = specification.scheme
if resolvers[what][scheme] then
if trace_locating then
- logs.report("fileio",'= handler: %s -> %s -> %s',specification.original,what,table.sequenced(specification))
+ logs.report("fileio","handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolvers[what][scheme](filename,filetype) -- todo: specification
else
@@ -9564,8 +9502,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub
local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end)
local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end)
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
--[[ldx--
<p>Once we found ourselves defining similar cache constructs
@@ -9689,8 +9625,7 @@ if not modules then modules = { } end modules ['data-use'] = {
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-- since we want to use the cache instead of the tree, we will now
-- reimplement the saver.
@@ -9822,10 +9757,13 @@ if not modules then modules = { } end modules ['data-zip'] = {
local format, find = string.format, string.find
-local trace_locating, trace_verbose = false, false
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trace_verbose = v end)
+-- zip:///oeps.zip?name=bla/bla.tex
+-- zip:///oeps.zip?tree=tex/texmf-local
+-- zip:///texmf.zip?tree=/tex/texmf
+-- zip:///texmf.zip?tree=/tex/texmf-local
+-- zip:///texmf-mine.zip?tree=/tex/texmf-projects
zip = zip or { }
zip.archives = zip.archives or { }
@@ -9836,9 +9774,6 @@ local locators, hashers, concatinators = resolvers.locators, resolvers.hashers,
local archives = zip.archives
--- zip:///oeps.zip?name=bla/bla.tex
--- zip:///oeps.zip?tree=tex/texmf-local
-
local function validzip(str) -- todo: use url splitter
if not find(str,"^zip://") then
return "zip:///" .. str
@@ -9868,26 +9803,22 @@ function zip.closearchive(name)
end
end
--- zip:///texmf.zip?tree=/tex/texmf
--- zip:///texmf.zip?tree=/tex/texmf-local
--- zip:///texmf-mine.zip?tree=/tex/texmf-projects
-
function locators.zip(specification) -- where is this used? startup zips (untested)
specification = resolvers.splitmethod(specification)
local zipfile = specification.path
local zfile = zip.openarchive(name) -- tricky, could be in to be initialized tree
if trace_locating then
if zfile then
- logs.report("fileio",'! zip locator, found: %s',specification.original)
+ logs.report("fileio","zip locator, archive '%s' found",specification.original)
else
- logs.report("fileio",'? zip locator, not found: %s',specification.original)
+ logs.report("fileio","zip locator, archive '%s' not found",specification.original)
end
end
end
function hashers.zip(tag,name)
- if trace_verbose then
- logs.report("fileio","loading zip file %s as %s",name,tag)
+ if trace_locating then
+ logs.report("fileio","loading zip file '%s' as '%s'",name,tag)
end
resolvers.usezipfile(format("%s?tree=%s",tag,name))
end
@@ -9912,23 +9843,25 @@ function finders.zip(specification,filetype)
local zfile = zip.openarchive(specification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'! zip finder, path: %s',specification.path)
+ logs.report("fileio","zip finder, archive '%s' found",specification.path)
end
local dfile = zfile:open(q.name)
if dfile then
dfile = zfile:close()
if trace_locating then
- logs.report("fileio",'+ zip finder, name: %s',q.name)
+ logs.report("fileio","zip finder, file '%s' found",q.name)
end
return specification.original
+ elseif trace_locating then
+ logs.report("fileio","zip finder, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'? zip finder, path %s',specification.path)
+ logs.report("fileio","zip finder, unknown archive '%s'",specification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip finder, name: %s',filename)
+ logs.report("fileio","zip finder, '%s' not found",filename)
end
return unpack(finders.notfound)
end
@@ -9941,20 +9874,25 @@ function openers.zip(specification)
local zfile = zip.openarchive(zipspecification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'+ zip starter, path: %s',zipspecification.path)
+ logs.report("fileio","zip opener, archive '%s' opened",zipspecification.path)
end
local dfile = zfile:open(q.name)
if dfile then
logs.show_open(specification)
+ if trace_locating then
+ logs.report("fileio","zip opener, file '%s' found",q.name)
+ end
return openers.text_opener(specification,dfile,'zip')
+ elseif trace_locating then
+ logs.report("fileio","zip opener, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'- zip starter, path %s',zipspecification.path)
+ logs.report("fileio","zip opener, unknown archive '%s'",zipspecification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip opener, name: %s',filename)
+ logs.report("fileio","zip opener, '%s' not found",filename)
end
return unpack(openers.notfound)
end
@@ -9967,25 +9905,27 @@ function loaders.zip(specification)
local zfile = zip.openarchive(specification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'+ zip starter, path: %s',specification.path)
+ logs.report("fileio","zip loader, archive '%s' opened",specification.path)
end
local dfile = zfile:open(q.name)
if dfile then
logs.show_load(filename)
if trace_locating then
- logs.report("fileio",'+ zip loader, name: %s',filename)
+ logs.report("fileio","zip loader, file '%s' loaded",filename)
end
local s = dfile:read("*all")
dfile:close()
return true, s, #s
+ elseif trace_locating then
+ logs.report("fileio","zip loader, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'- zip starter, path: %s',specification.path)
+ logs.report("fileio","zip loader, unknown archive '%s'",specification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip loader, name: %s',filename)
+ logs.report("fileio","zip loader, '%s' not found",filename)
end
return unpack(openers.notfound)
end
@@ -9995,21 +9935,15 @@ end
function resolvers.usezipfile(zipname)
zipname = validzip(zipname)
- if trace_locating then
- logs.report("fileio",'! zip use, file: %s',zipname)
- end
local specification = resolvers.splitmethod(zipname)
local zipfile = specification.path
if zipfile and not zip.registeredfiles[zipname] then
local tree = url.query(specification.query).tree or ""
- if trace_locating then
- logs.report("fileio",'! zip register, file: %s',zipname)
- end
local z = zip.openarchive(zipfile)
if z then
local instance = resolvers.instance
if trace_locating then
- logs.report("fileio","= zipfile, registering: %s",zipname)
+ logs.report("fileio","zip registering, registering archive '%s'",zipname)
end
statistics.starttiming(instance)
resolvers.prepend_hash('zip',zipname,zipfile)
@@ -10018,10 +9952,10 @@ function resolvers.usezipfile(zipname)
instance.files[zipname] = resolvers.register_zip_file(z,tree or "")
statistics.stoptiming(instance)
elseif trace_locating then
- logs.report("fileio","? zipfile, unknown: %s",zipname)
+ logs.report("fileio","zip registering, unknown archive '%s'",zipname)
end
elseif trace_locating then
- logs.report("fileio",'! zip register, no file: %s',zipname)
+ logs.report("fileio","zip registering, '%s' not found",zipname)
end
end
@@ -10033,7 +9967,7 @@ function resolvers.register_zip_file(z,tree)
filter = format("^%s/(.+)/(.-)$",tree)
end
if trace_locating then
- logs.report("fileio",'= zip filter: %s',filter)
+ logs.report("fileio","zip registering, using filter '%s'",filter)
end
local register, n = resolvers.register_file, 0
for i in z:files() do
@@ -10050,7 +9984,7 @@ function resolvers.register_zip_file(z,tree)
n = n + 1
end
end
- logs.report("fileio",'= zip entries: %s',n)
+ logs.report("fileio","zip registering, %s files registered",n)
return files
end
@@ -10240,47 +10174,47 @@ if not modules then modules = { } end modules ['data-aux'] = {
local find = string.find
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
function resolvers.update_script(oldname,newname) -- oldname -> own.name, not per se a suffix
local scriptpath = "scripts/context/lua"
newname = file.addsuffix(newname,"lua")
local oldscript = resolvers.clean_path(oldname)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","to be replaced old script %s", oldscript)
end
local newscripts = resolvers.find_files(newname) or { }
if #newscripts == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unable to locate new script")
end
else
for i=1,#newscripts do
local newscript = resolvers.clean_path(newscripts[i])
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","checking new script %s", newscript)
end
if oldscript == newscript then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old and new script are the same")
end
elseif not find(newscript,scriptpath) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","new script should come from %s",scriptpath)
end
elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","invalid new script name")
end
else
local newdata = io.loaddata(newscript)
if newdata then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old script content replaced by new content")
end
io.savedata(oldscript,newdata)
break
- elseif trace_verbose then
+ elseif trace_locating then
logs.report("fileio","unable to load new script")
end
end
@@ -10690,6 +10624,7 @@ messages.help = [[
--unix create unix (linux) stubs
--verbose give a bit more info
+--trackers=list enable given trackers
--engine=str target engine
--progname=str format or backend
@@ -11246,6 +11181,11 @@ else
end
+local trackspec = environment.argument("trackers") or environment.argument("track")
+
+if trackspec then
+ trackers.enable(trackspec)
+end
if environment.argument("selfmerge") then
-- embed used libraries
diff --git a/scripts/context/stubs/unix/luatools b/scripts/context/stubs/unix/luatools
index 70c391421..692213b09 100755
--- a/scripts/context/stubs/unix/luatools
+++ b/scripts/context/stubs/unix/luatools
@@ -3612,92 +3612,6 @@ function directives.disable(...)
d(...)
end
---~ -- old code:
---
---~ trackers = trackers or { }
---~ local data, done = { }, { }
---~ local function set(what,value)
---~ if type(what) == "string" then
---~ what = aux.settings_to_array(what) -- inefficient but ok
---~ end
---~ for i=1,#what do
---~ local w = what[i]
---~ for d, f in next, data do
---~ if done[d] then
---~ -- prevent recursion due to wildcards
---~ elseif find(d,w) then
---~ done[d] = true
---~ for i=1,#f do
---~ f[i](value)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ local function reset()
---~ for d, f in next, data do
---~ for i=1,#f do
---~ f[i](false)
---~ end
---~ end
---~ end
---~ local function enable(what)
---~ set(what,true)
---~ end
---~ local function disable(what)
---~ if not what or what == "" then
---~ done = { }
---~ reset()
---~ else
---~ set(what,false)
---~ end
---~ end
---~ function trackers.register(what,...)
---~ what = lower(what)
---~ local w = data[what]
---~ if not w then
---~ w = { }
---~ data[what] = w
---~ end
---~ for _, fnc in next, { ... } do
---~ local typ = type(fnc)
---~ if typ == "function" then
---~ w[#w+1] = fnc
---~ elseif typ == "string" then
---~ w[#w+1] = function(value) set(fnc,value,nesting) end
---~ end
---~ end
---~ end
---~ function trackers.enable(what)
---~ local e = trackers.enable
---~ trackers.enable, done = enable, { }
---~ enable(string.simpleesc(what))
---~ trackers.enable, done = e, { }
---~ end
---~ function trackers.disable(what)
---~ local e = trackers.disable
---~ trackers.disable, done = disable, { }
---~ disable(string.simpleesc(what))
---~ trackers.disable, done = e, { }
---~ end
---~ function trackers.reset()
---~ done = { }
---~ reset()
---~ end
---~ function trackers.list() -- pattern
---~ local list = table.sortedkeys(data)
---~ local user, system = { }, { }
---~ for l=1,#list do
---~ local what = list[l]
---~ if find(what,"^%*") then
---~ system[#system+1] = what
---~ else
---~ user[#user+1] = what
---~ end
---~ end
---~ return user, system
---~ end
-
end -- of closure
@@ -3717,8 +3631,7 @@ if not modules then modules = { } end modules ['luat-env'] = {
-- evolved before bytecode arrays were available and so a lot of
-- code has disappeared already.
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local format = string.format
@@ -3909,12 +3822,12 @@ function environment.luafilechunk(filename) -- used for loading lua bytecode in
filename = file.replacesuffix(filename, "lua")
local fullname = environment.luafile(filename)
if fullname and fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading file %s", fullname)
end
return environment.loadedluacode(fullname)
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
return nil
@@ -3934,7 +3847,7 @@ function environment.loadluafile(filename, version)
-- when not overloaded by explicit suffix we look for a luc file first
local fullname = (lucname and environment.luafile(lucname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
@@ -3952,7 +3865,7 @@ function environment.loadluafile(filename, version)
if v == version then
return true
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","version mismatch for %s: lua=%s, luc=%s", filename, v, version)
end
environment.loadluafile(filename)
@@ -3963,12 +3876,12 @@ function environment.loadluafile(filename, version)
end
fullname = (luaname and environment.luafile(luaname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
if not chunk then
- if verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
else
@@ -4363,7 +4276,7 @@ end
function logs.setprogram(_name_,_banner_,_verbose_)
name, banner = _name_, _banner_
if _verbose_ then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
end
logs.set_method("tex")
logs.report = report -- also used in libraries
@@ -4376,9 +4289,9 @@ end
function logs.setverbose(what)
if what then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
else
- trackers.disable("resolvers.verbose")
+ trackers.disable("resolvers.locating")
end
logs.verbose = what or false
end
@@ -4483,11 +4396,11 @@ local format, gsub, find, lower, upper, match, gmatch = string.format, string.gs
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type = next, type
-local trace_locating, trace_detail, trace_verbose = false, false, false
+local trace_locating, trace_detail, trace_expansions = false, false, false
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
-trackers.register("resolvers.detail", function(v) trace_detail = v trackers.enable("resolvers.verbose,resolvers.detail") end)
+trackers.register("resolvers.locating", function(v) trace_locating = v end)
+trackers.register("resolvers.details", function(v) trace_detail = v end)
+trackers.register("resolvers.expansions", function(v) trace_expansions = v end) -- todo
if not resolvers then
resolvers = {
@@ -4796,37 +4709,43 @@ end
-- work that well; the parsing is ok, but dealing with the resulting
-- table is a pain because we need to work inside-out recursively
+local function do_first(a,b)
+ local t = { }
+ for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_second(a,b)
+ local t = { }
+ for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_both(a,b)
+ local t = { }
+ for sa in gmatch(a,"[^,]+") do
+ for sb in gmatch(b,"[^,]+") do
+ t[#t+1] = sa .. sb
+ end
+ end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_three(a,b,c)
+ return a .. b.. c
+end
+
local function splitpathexpr(str, t, validate)
-- no need for further optimization as it is only called a
- -- few times, we can use lpeg for the sub; we could move
- -- the local functions outside the body
+ -- few times, we can use lpeg for the sub
+ if trace_expansion then
+ logs.report("fileio","expanding variable '%s'",str)
+ end
t = t or { }
str = gsub(str,",}",",@}")
str = gsub(str,"{,","{@,")
-- str = "@" .. str .. "@"
local ok, done
- local function do_first(a,b)
- local t = { }
- for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_second(a,b)
- local t = { }
- for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_both(a,b)
- local t = { }
- for sa in gmatch(a,"[^,]+") do
- for sb in gmatch(b,"[^,]+") do
- t[#t+1] = sa .. sb
- end
- end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_three(a,b,c)
- return a .. b.. c
- end
while true do
done = false
while true do
@@ -4857,6 +4776,11 @@ local function splitpathexpr(str, t, validate)
t[#t+1] = s
end
end
+ if trace_expansions then
+ for k,v in ipairs(t) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
return t
end
@@ -4919,14 +4843,14 @@ function resolvers.getownpath()
local olddir = lfs.currentdir()
if lfs.chdir(p) then
local pp = lfs.currentdir()
- if trace_verbose and p ~= pp then
- logs.report("fileio","following symlink %s to %s",p,pp)
+ if trace_locating and p ~= pp then
+ logs.report("fileio","following symlink '%s' to '%s'",p,pp)
end
resolvers.ownpath = pp
lfs.chdir(olddir)
else
- if trace_verbose then
- logs.report("fileio","unable to check path %s",p)
+ if trace_locating then
+ logs.report("fileio","unable to check path '%s'",p)
end
resolvers.ownpath = p
end
@@ -4955,10 +4879,10 @@ local function identify_own()
if resolvers.env('TEXMFCNF') == "" then os.env['TEXMFCNF'] = resolvers.cnfdefault end
if resolvers.env('TEXOS') == "" then os.env['TEXOS'] = resolvers.env('SELFAUTODIR') end
if resolvers.env('TEXROOT') == "" then os.env['TEXROOT'] = resolvers.env('SELFAUTOPARENT') end
- if trace_verbose then
+ if trace_locating then
for i=1,#own_places do
local v = own_places[i]
- logs.report("fileio","variable %s set to %s",v,resolvers.env(v) or "unknown")
+ logs.report("fileio","variable '%s' set to '%s'",v,resolvers.env(v) or "unknown")
end
end
identify_own = function() end
@@ -4990,10 +4914,8 @@ end
local function load_cnf_file(fname)
fname = resolvers.clean_path(fname)
local lname = file.replacesuffix(fname,'lua')
- local f = io.open(lname)
- if f then -- this will go
- f:close()
- local dname = file.dirname(fname)
+ if lfs.isfile(lname) then
+ local dname = file.dirname(fname) -- fname ?
if not instance.configuration[dname] then
resolvers.load_data(dname,'configuration',lname and file.basename(lname))
instance.order[#instance.order+1] = instance.configuration[dname]
@@ -5001,8 +4923,8 @@ local function load_cnf_file(fname)
else
f = io.open(fname)
if f then
- if trace_verbose then
- logs.report("fileio","loading %s", fname)
+ if trace_locating then
+ logs.report("fileio","loading configuration file %s", fname)
end
local line, data, n, k, v
local dname = file.dirname(fname)
@@ -5036,8 +4958,8 @@ local function load_cnf_file(fname)
end
end
f:close()
- elseif trace_verbose then
- logs.report("fileio","skipping %s", fname)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'", fname)
end
end
end
@@ -5064,8 +4986,11 @@ function resolvers.load_cnf()
end
end
-- instance.cnffiles contain complete names now !
+ -- we still use a funny mix of cnf and new but soon
+ -- we will switch to lua exclusively as we only use
+ -- the file to collect the tree roots
if #instance.cnffiles == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","no cnf files found (TEXMFCNF may not be set/known)")
end
else
@@ -5132,14 +5057,14 @@ end
function resolvers.append_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash append: %s",tag)
+ logs.report("fileio","hash '%s' appended",tag)
end
insert(instance.hashes, { ['type']=type, ['tag']=tag, ['name']=name } )
end
function resolvers.prepend_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash prepend: %s",tag)
+ logs.report("fileio","hash '%s' prepended",tag)
end
insert(instance.hashes, 1, { ['type']=type, ['tag']=tag, ['name']=name } )
end
@@ -5164,8 +5089,8 @@ end
function resolvers.locatelists()
for _, path in ipairs(resolvers.clean_path_list('TEXMF')) do
- if trace_verbose then
- logs.report("fileio","locating list of %s",path)
+ if trace_locating then
+ logs.report("fileio","locating list of '%s'",path)
end
resolvers.locatedatabase(file.collapse_path(path))
end
@@ -5178,11 +5103,11 @@ end
function resolvers.locators.tex(specification)
if specification and specification ~= '' and lfs.isdir(specification) then
if trace_locating then
- logs.report("fileio",'! tex locator found: %s',specification)
+ logs.report("fileio","tex locator '%s' found",specification)
end
resolvers.append_hash('file',specification,filename)
elseif trace_locating then
- logs.report("fileio",'? tex locator not found: %s',specification)
+ logs.report("fileio","tex locator '%s' not found",specification)
end
end
@@ -5225,8 +5150,8 @@ local weird = lpeg.P(".")^1 + lpeg.anywhere(lpeg.S("~`!#$%^&*()={}[]:;\"\'||<>,?
function resolvers.generators.tex(specification)
local tag = specification
- if trace_verbose then
- logs.report("fileio","scanning path %s",specification)
+ if trace_locating then
+ logs.report("fileio","scanning path '%s'",specification)
end
instance.files[tag] = { }
local files = instance.files[tag]
@@ -5275,7 +5200,7 @@ function resolvers.generators.tex(specification)
end
end
action()
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","%s files found on %s directories with %s uppercase remappings",n,m,r)
end
end
@@ -5305,7 +5230,12 @@ local function split_kpse_path(str) -- beware, this can be either a path or a {s
else
found = checkedsplit(str,io.pathseparator)
end
- -- print(table.serialize(found))
+ if trace_expansions then
+ logs.report("fileio","splitting path specification '%s'",str)
+ for k,v in ipairs(found) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
cache[str] = found
end
return found
@@ -5335,6 +5265,7 @@ function resolvers.joinconfig()
end
end
end
+
function resolvers.split_path(str)
if type(str) == 'table' then
return str
@@ -5342,6 +5273,7 @@ function resolvers.split_path(str)
return split_kpse_path(str)
end
end
+
function resolvers.join_path(str)
if type(str) == 'table' then
return file.join_path(str)
@@ -5430,12 +5362,18 @@ function resolvers.serialize(files)
return concat(t,"\n")
end
+local data_state = { }
+
+function resolvers.data_state()
+ return data_state or { }
+end
+
function resolvers.save_data(dataname, makename) -- untested without cache overload
for cachename, files in next, instance[dataname] do
local name = (makename or file.join)(cachename,dataname)
local luaname, lucname = name .. ".lua", name .. ".luc"
- if trace_verbose then
- logs.report("fileio","preparing %s for %s",dataname,cachename)
+ if trace_locating then
+ logs.report("fileio","preparing '%s' for '%s'",dataname,cachename)
end
for k, v in next, files do
if type(v) == "table" and #v == 1 then
@@ -5449,24 +5387,25 @@ function resolvers.save_data(dataname, makename) -- untested without cache overl
date = os.date("%Y-%m-%d"),
time = os.date("%H:%M:%S"),
content = files,
+ uuid = os.uuid(),
}
local ok = io.savedata(luaname,resolvers.serialize(data))
if ok then
- if trace_verbose then
- logs.report("fileio","%s saved in %s",dataname,luaname)
+ if trace_locating then
+ logs.report("fileio","'%s' saved in '%s'",dataname,luaname)
end
if utils.lua.compile(luaname,lucname,false,true) then -- no cleanup but strip
- if trace_verbose then
- logs.report("fileio","%s compiled to %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","'%s' compiled to '%s'",dataname,lucname)
end
else
- if trace_verbose then
- logs.report("fileio","compiling failed for %s, deleting file %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","compiling failed for '%s', deleting file '%s'",dataname,lucname)
end
os.remove(lucname)
end
- elseif trace_verbose then
- logs.report("fileio","unable to save %s in %s (access error)",dataname,luaname)
+ elseif trace_locating then
+ logs.report("fileio","unable to save '%s' in '%s' (access error)",dataname,luaname)
end
end
end
@@ -5478,19 +5417,20 @@ function resolvers.load_data(pathname,dataname,filename,makename) -- untested wi
if blob then
local data = blob()
if data and data.content and data.type == dataname and data.version == resolvers.cacheversion then
- if trace_verbose then
- logs.report("fileio","loading %s for %s from %s",dataname,pathname,filename)
+ data_state[#data_state+1] = data.uuid
+ if trace_locating then
+ logs.report("fileio","loading '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = data.content
else
- if trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ if trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
end
@@ -5516,8 +5456,8 @@ function resolvers.loadnewconfig()
if blob then
local data = blob()
if data then
- if trace_verbose then
- logs.report("fileio","loading configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","loading configuration file '%s'",filename)
end
if true then
-- flatten to variable.progname
@@ -5538,14 +5478,14 @@ function resolvers.loadnewconfig()
instance['setup'][pathname] = data
end
else
- if trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance['setup'][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance.order[#instance.order+1] = instance.setup[pathname]
if instance.loaderror then break end
@@ -5811,9 +5751,9 @@ function resolvers.isreadable.file(name)
local readable = lfs.isfile(name) -- brrr
if trace_detail then
if readable then
- logs.report("fileio","+ readable: %s",name)
+ logs.report("fileio","file '%s' is readable",name)
else
- logs.report("fileio","- readable: %s", name)
+ logs.report("fileio","file '%s' is not readable", name)
end
end
return readable
@@ -5829,7 +5769,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","? blobpath asked: %s",fname)
+ logs.report("fileio","using blobpath '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -5845,7 +5785,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio",'? blobpath do: %s (%s)',blobpath,bname)
+ logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -5879,7 +5819,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio",'! blobpath no: %s (%s)',blobpath,bname)
+ logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
end
end
end
@@ -5936,7 +5876,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
if instance.found[stamp] then
if trace_locating then
- logs.report("fileio",'! remembered: %s',filename)
+ logs.report("fileio","remembering file '%s'",filename)
end
return instance.found[stamp]
end
@@ -5944,7 +5884,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not dangerous[instance.format or "?"] then
if resolvers.isreadable.file(filename) then
if trace_detail then
- logs.report("fileio",'= found directly: %s',filename)
+ logs.report("fileio","file '%s' found directly",filename)
end
instance.found[stamp] = { filename }
return { filename }
@@ -5952,13 +5892,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
if find(filename,'%*') then
if trace_locating then
- logs.report("fileio",'! wildcard: %s', filename)
+ logs.report("fileio","checking wildcard '%s'", filename)
end
result = resolvers.find_wildcard_files(filename)
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
- logs.report("fileio",'! qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
result = { filename }
else
@@ -5968,7 +5908,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. ".tex"
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing standard filetype: tex')
+ logs.report("fileio","no suffix, forcing standard filetype 'tex'")
end
result, ok = { forcedname }, true
end
@@ -5978,7 +5918,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. "." .. s
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing format filetype: %s', s)
+ logs.report("fileio","no suffix, forcing format filetype '%s'", s)
end
result, ok = { forcedname }, true
break
@@ -6028,7 +5968,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- end
end
if not ok and trace_locating then
- logs.report("fileio",'? qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
end
else
@@ -6047,12 +5987,12 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.format_of_suffix(forcedname)
if trace_locating then
- logs.report("fileio",'! forcing filetype: %s',filetype)
+ logs.report("fileio","forcing filetype '%s'",filetype)
end
else
filetype = resolvers.format_of_suffix(filename)
if trace_locating then
- logs.report("fileio",'! using suffix based filetype: %s',filetype)
+ logs.report("fileio","using suffix based filetype '%s'",filetype)
end
end
else
@@ -6064,7 +6004,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
filetype = instance.format
if trace_locating then
- logs.report("fileio",'! using given filetype: %s',filetype)
+ logs.report("fileio","using given filetype '%s'",filetype)
end
end
local typespec = resolvers.variable_of_format(filetype)
@@ -6072,9 +6012,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not pathlist or #pathlist == 0 then
-- no pathlist, access check only / todo == wildcard
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
- logs.report("fileio",'? filetype: %s',filetype or '?')
- logs.report("fileio",'? wanted files: %s',concat(wantedfiles," | "))
+ logs.report("fileio","checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
end
for k=1,#wantedfiles do
local fname = wantedfiles[k]
@@ -6097,7 +6035,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local filelist = collect_files(wantedfiles)
local doscan, recurse
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
+ logs.report("fileio","checking filename '%s'",filename)
end
-- a bit messy ... esp the doscan setting here
for k=1,#pathlist do
@@ -6118,7 +6056,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local f = fl[2]
if find(f,expr) then
if trace_detail then
- logs.report("fileio",'= found in hash: %s',f)
+ logs.report("fileio","file '%s' found in hash",f)
end
--- todo, test for readable
result[#result+1] = fl[3]
@@ -6140,7 +6078,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local fname = file.join(ppname,w)
if resolvers.isreadable.file(fname) then
if trace_detail then
- logs.report("fileio",'= found by scanning: %s',fname)
+ logs.report("fileio","found '%s' by scanning",fname)
end
result[#result+1] = fname
done = true
@@ -6313,9 +6251,9 @@ function resolvers.load(option)
statistics.starttiming(instance)
resolvers.resetconfig()
resolvers.identify_cnf()
- resolvers.load_lua()
+ resolvers.load_lua() -- will become the new method
resolvers.expand_variables()
- resolvers.load_cnf()
+ resolvers.load_cnf() -- will be skipped when we have a lua file
resolvers.expand_variables()
if option ~= "nofiles" then
resolvers.load_hash()
@@ -6327,14 +6265,14 @@ end
function resolvers.for_files(command, files, filetype, mustexist)
if files and #files > 0 then
local function report(str)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio",str) -- has already verbose
else
print(str)
end
end
- if trace_verbose then
- report('')
+ if trace_locating then
+ report('') -- ?
end
for _, file in ipairs(files) do
local result = command(file,filetype,mustexist)
@@ -6400,7 +6338,7 @@ function resolvers.methodhandler(what, filename, filetype) -- ...
local scheme = specification.scheme
if resolvers[what][scheme] then
if trace_locating then
- logs.report("fileio",'= handler: %s -> %s -> %s',specification.original,what,table.sequenced(specification))
+ logs.report("fileio","handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolvers[what][scheme](filename,filetype) -- todo: specification
else
@@ -6736,8 +6674,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub
local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end)
local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end)
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
--[[ldx--
<p>Once we found ourselves defining similar cache constructs
@@ -6861,8 +6797,7 @@ if not modules then modules = { } end modules ['data-use'] = {
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-- since we want to use the cache instead of the tree, we will now
-- reimplement the saver.
@@ -7101,47 +7036,47 @@ if not modules then modules = { } end modules ['data-aux'] = {
local find = string.find
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
function resolvers.update_script(oldname,newname) -- oldname -> own.name, not per se a suffix
local scriptpath = "scripts/context/lua"
newname = file.addsuffix(newname,"lua")
local oldscript = resolvers.clean_path(oldname)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","to be replaced old script %s", oldscript)
end
local newscripts = resolvers.find_files(newname) or { }
if #newscripts == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unable to locate new script")
end
else
for i=1,#newscripts do
local newscript = resolvers.clean_path(newscripts[i])
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","checking new script %s", newscript)
end
if oldscript == newscript then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old and new script are the same")
end
elseif not find(newscript,scriptpath) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","new script should come from %s",scriptpath)
end
elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","invalid new script name")
end
else
local newdata = io.loaddata(newscript)
if newdata then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old script content replaced by new content")
end
io.savedata(oldscript,newdata)
break
- elseif trace_verbose then
+ elseif trace_locating then
logs.report("fileio","unable to load new script")
end
end
@@ -7399,6 +7334,7 @@ messages.help = [[
--engine=str target engine
--progname=str format or backend
--pattern=str filter variables
+--trackers=list enable given trackers
]]
function runners.make_format(texname)
@@ -7543,6 +7479,12 @@ local ok = true
-- private option --noluc for testing errors in the stub
+local trackspec = environment.argument("trackers") or environment.argument("track")
+
+if trackspec then
+ trackers.enable(trackspec)
+end
+
if environment.arguments["find-file"] then
resolvers.load()
instance.format = environment.arguments["format"] or instance.format
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 580e1a46f..26f5c4c2a 100755
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -3332,92 +3332,6 @@ function directives.disable(...)
d(...)
end
---~ -- old code:
---
---~ trackers = trackers or { }
---~ local data, done = { }, { }
---~ local function set(what,value)
---~ if type(what) == "string" then
---~ what = aux.settings_to_array(what) -- inefficient but ok
---~ end
---~ for i=1,#what do
---~ local w = what[i]
---~ for d, f in next, data do
---~ if done[d] then
---~ -- prevent recursion due to wildcards
---~ elseif find(d,w) then
---~ done[d] = true
---~ for i=1,#f do
---~ f[i](value)
---~ end
---~ end
---~ end
---~ end
---~ end
---~ local function reset()
---~ for d, f in next, data do
---~ for i=1,#f do
---~ f[i](false)
---~ end
---~ end
---~ end
---~ local function enable(what)
---~ set(what,true)
---~ end
---~ local function disable(what)
---~ if not what or what == "" then
---~ done = { }
---~ reset()
---~ else
---~ set(what,false)
---~ end
---~ end
---~ function trackers.register(what,...)
---~ what = lower(what)
---~ local w = data[what]
---~ if not w then
---~ w = { }
---~ data[what] = w
---~ end
---~ for _, fnc in next, { ... } do
---~ local typ = type(fnc)
---~ if typ == "function" then
---~ w[#w+1] = fnc
---~ elseif typ == "string" then
---~ w[#w+1] = function(value) set(fnc,value,nesting) end
---~ end
---~ end
---~ end
---~ function trackers.enable(what)
---~ local e = trackers.enable
---~ trackers.enable, done = enable, { }
---~ enable(string.simpleesc(what))
---~ trackers.enable, done = e, { }
---~ end
---~ function trackers.disable(what)
---~ local e = trackers.disable
---~ trackers.disable, done = disable, { }
---~ disable(string.simpleesc(what))
---~ trackers.disable, done = e, { }
---~ end
---~ function trackers.reset()
---~ done = { }
---~ reset()
---~ end
---~ function trackers.list() -- pattern
---~ local list = table.sortedkeys(data)
---~ local user, system = { }, { }
---~ for l=1,#list do
---~ local what = list[l]
---~ if find(what,"^%*") then
---~ system[#system+1] = what
---~ else
---~ user[#user+1] = what
---~ end
---~ end
---~ return user, system
---~ end
-
end -- of closure
@@ -6449,8 +6363,7 @@ if not modules then modules = { } end modules ['luat-env'] = {
-- evolved before bytecode arrays were available and so a lot of
-- code has disappeared already.
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local format = string.format
@@ -6641,12 +6554,12 @@ function environment.luafilechunk(filename) -- used for loading lua bytecode in
filename = file.replacesuffix(filename, "lua")
local fullname = environment.luafile(filename)
if fullname and fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading file %s", fullname)
end
return environment.loadedluacode(fullname)
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
return nil
@@ -6666,7 +6579,7 @@ function environment.loadluafile(filename, version)
-- when not overloaded by explicit suffix we look for a luc file first
local fullname = (lucname and environment.luafile(lucname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
@@ -6684,7 +6597,7 @@ function environment.loadluafile(filename, version)
if v == version then
return true
else
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","version mismatch for %s: lua=%s, luc=%s", filename, v, version)
end
environment.loadluafile(filename)
@@ -6695,12 +6608,12 @@ function environment.loadluafile(filename, version)
end
fullname = (luaname and environment.luafile(luaname)) or ""
if fullname ~= "" then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","loading %s", fullname)
end
chunk = loadfile(fullname) -- this way we don't need a file exists check
if not chunk then
- if verbose then
+ if trace_locating then
logs.report("fileio","unknown file %s", filename)
end
else
@@ -7095,7 +7008,7 @@ end
function logs.setprogram(_name_,_banner_,_verbose_)
name, banner = _name_, _banner_
if _verbose_ then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
end
logs.set_method("tex")
logs.report = report -- also used in libraries
@@ -7108,9 +7021,9 @@ end
function logs.setverbose(what)
if what then
- trackers.enable("resolvers.verbose")
+ trackers.enable("resolvers.locating")
else
- trackers.disable("resolvers.verbose")
+ trackers.disable("resolvers.locating")
end
logs.verbose = what or false
end
@@ -7215,11 +7128,11 @@ local format, gsub, find, lower, upper, match, gmatch = string.format, string.gs
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type = next, type
-local trace_locating, trace_detail, trace_verbose = false, false, false
+local trace_locating, trace_detail, trace_expansions = false, false, false
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
-trackers.register("resolvers.detail", function(v) trace_detail = v trackers.enable("resolvers.verbose,resolvers.detail") end)
+trackers.register("resolvers.locating", function(v) trace_locating = v end)
+trackers.register("resolvers.details", function(v) trace_detail = v end)
+trackers.register("resolvers.expansions", function(v) trace_expansions = v end) -- todo
if not resolvers then
resolvers = {
@@ -7528,37 +7441,43 @@ end
-- work that well; the parsing is ok, but dealing with the resulting
-- table is a pain because we need to work inside-out recursively
+local function do_first(a,b)
+ local t = { }
+ for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_second(a,b)
+ local t = { }
+ for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_both(a,b)
+ local t = { }
+ for sa in gmatch(a,"[^,]+") do
+ for sb in gmatch(b,"[^,]+") do
+ t[#t+1] = sa .. sb
+ end
+ end
+ return "{" .. concat(t,",") .. "}"
+end
+
+local function do_three(a,b,c)
+ return a .. b.. c
+end
+
local function splitpathexpr(str, t, validate)
-- no need for further optimization as it is only called a
- -- few times, we can use lpeg for the sub; we could move
- -- the local functions outside the body
+ -- few times, we can use lpeg for the sub
+ if trace_expansion then
+ logs.report("fileio","expanding variable '%s'",str)
+ end
t = t or { }
str = gsub(str,",}",",@}")
str = gsub(str,"{,","{@,")
-- str = "@" .. str .. "@"
local ok, done
- local function do_first(a,b)
- local t = { }
- for s in gmatch(b,"[^,]+") do t[#t+1] = a .. s end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_second(a,b)
- local t = { }
- for s in gmatch(a,"[^,]+") do t[#t+1] = s .. b end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_both(a,b)
- local t = { }
- for sa in gmatch(a,"[^,]+") do
- for sb in gmatch(b,"[^,]+") do
- t[#t+1] = sa .. sb
- end
- end
- return "{" .. concat(t,",") .. "}"
- end
- local function do_three(a,b,c)
- return a .. b.. c
- end
while true do
done = false
while true do
@@ -7589,6 +7508,11 @@ local function splitpathexpr(str, t, validate)
t[#t+1] = s
end
end
+ if trace_expansions then
+ for k,v in ipairs(t) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
return t
end
@@ -7651,14 +7575,14 @@ function resolvers.getownpath()
local olddir = lfs.currentdir()
if lfs.chdir(p) then
local pp = lfs.currentdir()
- if trace_verbose and p ~= pp then
- logs.report("fileio","following symlink %s to %s",p,pp)
+ if trace_locating and p ~= pp then
+ logs.report("fileio","following symlink '%s' to '%s'",p,pp)
end
resolvers.ownpath = pp
lfs.chdir(olddir)
else
- if trace_verbose then
- logs.report("fileio","unable to check path %s",p)
+ if trace_locating then
+ logs.report("fileio","unable to check path '%s'",p)
end
resolvers.ownpath = p
end
@@ -7687,10 +7611,10 @@ local function identify_own()
if resolvers.env('TEXMFCNF') == "" then os.env['TEXMFCNF'] = resolvers.cnfdefault end
if resolvers.env('TEXOS') == "" then os.env['TEXOS'] = resolvers.env('SELFAUTODIR') end
if resolvers.env('TEXROOT') == "" then os.env['TEXROOT'] = resolvers.env('SELFAUTOPARENT') end
- if trace_verbose then
+ if trace_locating then
for i=1,#own_places do
local v = own_places[i]
- logs.report("fileio","variable %s set to %s",v,resolvers.env(v) or "unknown")
+ logs.report("fileio","variable '%s' set to '%s'",v,resolvers.env(v) or "unknown")
end
end
identify_own = function() end
@@ -7722,10 +7646,8 @@ end
local function load_cnf_file(fname)
fname = resolvers.clean_path(fname)
local lname = file.replacesuffix(fname,'lua')
- local f = io.open(lname)
- if f then -- this will go
- f:close()
- local dname = file.dirname(fname)
+ if lfs.isfile(lname) then
+ local dname = file.dirname(fname) -- fname ?
if not instance.configuration[dname] then
resolvers.load_data(dname,'configuration',lname and file.basename(lname))
instance.order[#instance.order+1] = instance.configuration[dname]
@@ -7733,8 +7655,8 @@ local function load_cnf_file(fname)
else
f = io.open(fname)
if f then
- if trace_verbose then
- logs.report("fileio","loading %s", fname)
+ if trace_locating then
+ logs.report("fileio","loading configuration file %s", fname)
end
local line, data, n, k, v
local dname = file.dirname(fname)
@@ -7768,8 +7690,8 @@ local function load_cnf_file(fname)
end
end
f:close()
- elseif trace_verbose then
- logs.report("fileio","skipping %s", fname)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'", fname)
end
end
end
@@ -7796,8 +7718,11 @@ function resolvers.load_cnf()
end
end
-- instance.cnffiles contain complete names now !
+ -- we still use a funny mix of cnf and new but soon
+ -- we will switch to lua exclusively as we only use
+ -- the file to collect the tree roots
if #instance.cnffiles == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","no cnf files found (TEXMFCNF may not be set/known)")
end
else
@@ -7864,14 +7789,14 @@ end
function resolvers.append_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash append: %s",tag)
+ logs.report("fileio","hash '%s' appended",tag)
end
insert(instance.hashes, { ['type']=type, ['tag']=tag, ['name']=name } )
end
function resolvers.prepend_hash(type,tag,name)
if trace_locating then
- logs.report("fileio","= hash prepend: %s",tag)
+ logs.report("fileio","hash '%s' prepended",tag)
end
insert(instance.hashes, 1, { ['type']=type, ['tag']=tag, ['name']=name } )
end
@@ -7896,8 +7821,8 @@ end
function resolvers.locatelists()
for _, path in ipairs(resolvers.clean_path_list('TEXMF')) do
- if trace_verbose then
- logs.report("fileio","locating list of %s",path)
+ if trace_locating then
+ logs.report("fileio","locating list of '%s'",path)
end
resolvers.locatedatabase(file.collapse_path(path))
end
@@ -7910,11 +7835,11 @@ end
function resolvers.locators.tex(specification)
if specification and specification ~= '' and lfs.isdir(specification) then
if trace_locating then
- logs.report("fileio",'! tex locator found: %s',specification)
+ logs.report("fileio","tex locator '%s' found",specification)
end
resolvers.append_hash('file',specification,filename)
elseif trace_locating then
- logs.report("fileio",'? tex locator not found: %s',specification)
+ logs.report("fileio","tex locator '%s' not found",specification)
end
end
@@ -7957,8 +7882,8 @@ local weird = lpeg.P(".")^1 + lpeg.anywhere(lpeg.S("~`!#$%^&*()={}[]:;\"\'||<>,?
function resolvers.generators.tex(specification)
local tag = specification
- if trace_verbose then
- logs.report("fileio","scanning path %s",specification)
+ if trace_locating then
+ logs.report("fileio","scanning path '%s'",specification)
end
instance.files[tag] = { }
local files = instance.files[tag]
@@ -8007,7 +7932,7 @@ function resolvers.generators.tex(specification)
end
end
action()
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","%s files found on %s directories with %s uppercase remappings",n,m,r)
end
end
@@ -8037,7 +7962,12 @@ local function split_kpse_path(str) -- beware, this can be either a path or a {s
else
found = checkedsplit(str,io.pathseparator)
end
- -- print(table.serialize(found))
+ if trace_expansions then
+ logs.report("fileio","splitting path specification '%s'",str)
+ for k,v in ipairs(found) do
+ logs.report("fileio","% 4i: %s",k,v)
+ end
+ end
cache[str] = found
end
return found
@@ -8067,6 +7997,7 @@ function resolvers.joinconfig()
end
end
end
+
function resolvers.split_path(str)
if type(str) == 'table' then
return str
@@ -8074,6 +8005,7 @@ function resolvers.split_path(str)
return split_kpse_path(str)
end
end
+
function resolvers.join_path(str)
if type(str) == 'table' then
return file.join_path(str)
@@ -8162,12 +8094,18 @@ function resolvers.serialize(files)
return concat(t,"\n")
end
+local data_state = { }
+
+function resolvers.data_state()
+ return data_state or { }
+end
+
function resolvers.save_data(dataname, makename) -- untested without cache overload
for cachename, files in next, instance[dataname] do
local name = (makename or file.join)(cachename,dataname)
local luaname, lucname = name .. ".lua", name .. ".luc"
- if trace_verbose then
- logs.report("fileio","preparing %s for %s",dataname,cachename)
+ if trace_locating then
+ logs.report("fileio","preparing '%s' for '%s'",dataname,cachename)
end
for k, v in next, files do
if type(v) == "table" and #v == 1 then
@@ -8181,24 +8119,25 @@ function resolvers.save_data(dataname, makename) -- untested without cache overl
date = os.date("%Y-%m-%d"),
time = os.date("%H:%M:%S"),
content = files,
+ uuid = os.uuid(),
}
local ok = io.savedata(luaname,resolvers.serialize(data))
if ok then
- if trace_verbose then
- logs.report("fileio","%s saved in %s",dataname,luaname)
+ if trace_locating then
+ logs.report("fileio","'%s' saved in '%s'",dataname,luaname)
end
if utils.lua.compile(luaname,lucname,false,true) then -- no cleanup but strip
- if trace_verbose then
- logs.report("fileio","%s compiled to %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","'%s' compiled to '%s'",dataname,lucname)
end
else
- if trace_verbose then
- logs.report("fileio","compiling failed for %s, deleting file %s",dataname,lucname)
+ if trace_locating then
+ logs.report("fileio","compiling failed for '%s', deleting file '%s'",dataname,lucname)
end
os.remove(lucname)
end
- elseif trace_verbose then
- logs.report("fileio","unable to save %s in %s (access error)",dataname,luaname)
+ elseif trace_locating then
+ logs.report("fileio","unable to save '%s' in '%s' (access error)",dataname,luaname)
end
end
end
@@ -8210,19 +8149,20 @@ function resolvers.load_data(pathname,dataname,filename,makename) -- untested wi
if blob then
local data = blob()
if data and data.content and data.type == dataname and data.version == resolvers.cacheversion then
- if trace_verbose then
- logs.report("fileio","loading %s for %s from %s",dataname,pathname,filename)
+ data_state[#data_state+1] = data.uuid
+ if trace_locating then
+ logs.report("fileio","loading '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = data.content
else
- if trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ if trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
instance[dataname][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping %s for %s from %s",dataname,pathname,filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping '%s' for '%s' from '%s'",dataname,pathname,filename)
end
end
@@ -8248,8 +8188,8 @@ function resolvers.loadnewconfig()
if blob then
local data = blob()
if data then
- if trace_verbose then
- logs.report("fileio","loading configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","loading configuration file '%s'",filename)
end
if true then
-- flatten to variable.progname
@@ -8270,14 +8210,14 @@ function resolvers.loadnewconfig()
instance['setup'][pathname] = data
end
else
- if trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ if trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance['setup'][pathname] = { }
instance.loaderror = true
end
- elseif trace_verbose then
- logs.report("fileio","skipping configuration file %s",filename)
+ elseif trace_locating then
+ logs.report("fileio","skipping configuration file '%s'",filename)
end
instance.order[#instance.order+1] = instance.setup[pathname]
if instance.loaderror then break end
@@ -8543,9 +8483,9 @@ function resolvers.isreadable.file(name)
local readable = lfs.isfile(name) -- brrr
if trace_detail then
if readable then
- logs.report("fileio","+ readable: %s",name)
+ logs.report("fileio","file '%s' is readable",name)
else
- logs.report("fileio","- readable: %s", name)
+ logs.report("fileio","file '%s' is not readable", name)
end
end
return readable
@@ -8561,7 +8501,7 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- logs.report("fileio","? blobpath asked: %s",fname)
+ logs.report("fileio","using blobpath '%s'",fname)
end
local bname = file.basename(fname)
local dname = file.dirname(fname)
@@ -8577,7 +8517,7 @@ local function collect_files(names)
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- logs.report("fileio",'? blobpath do: %s (%s)',blobpath,bname)
+ logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname)
end
local blobfile = files[bname]
if not blobfile then
@@ -8611,7 +8551,7 @@ local function collect_files(names)
end
end
elseif trace_locating then
- logs.report("fileio",'! blobpath no: %s (%s)',blobpath,bname)
+ logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname)
end
end
end
@@ -8668,7 +8608,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
stamp = filename .. "--" .. instance.engine .. "--" .. instance.progname .. "--" .. instance.format
if instance.found[stamp] then
if trace_locating then
- logs.report("fileio",'! remembered: %s',filename)
+ logs.report("fileio","remembering file '%s'",filename)
end
return instance.found[stamp]
end
@@ -8676,7 +8616,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not dangerous[instance.format or "?"] then
if resolvers.isreadable.file(filename) then
if trace_detail then
- logs.report("fileio",'= found directly: %s',filename)
+ logs.report("fileio","file '%s' found directly",filename)
end
instance.found[stamp] = { filename }
return { filename }
@@ -8684,13 +8624,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
if find(filename,'%*') then
if trace_locating then
- logs.report("fileio",'! wildcard: %s', filename)
+ logs.report("fileio","checking wildcard '%s'", filename)
end
result = resolvers.find_wildcard_files(filename)
elseif file.is_qualified_path(filename) then
if resolvers.isreadable.file(filename) then
if trace_locating then
- logs.report("fileio",'! qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
result = { filename }
else
@@ -8700,7 +8640,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. ".tex"
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing standard filetype: tex')
+ logs.report("fileio","no suffix, forcing standard filetype 'tex'")
end
result, ok = { forcedname }, true
end
@@ -8710,7 +8650,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
forcedname = filename .. "." .. s
if resolvers.isreadable.file(forcedname) then
if trace_locating then
- logs.report("fileio",'! no suffix, forcing format filetype: %s', s)
+ logs.report("fileio","no suffix, forcing format filetype '%s'", s)
end
result, ok = { forcedname }, true
break
@@ -8760,7 +8700,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
-- end
end
if not ok and trace_locating then
- logs.report("fileio",'? qualified: %s', filename)
+ logs.report("fileio","qualified name '%s'", filename)
end
end
else
@@ -8779,12 +8719,12 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.format_of_suffix(forcedname)
if trace_locating then
- logs.report("fileio",'! forcing filetype: %s',filetype)
+ logs.report("fileio","forcing filetype '%s'",filetype)
end
else
filetype = resolvers.format_of_suffix(filename)
if trace_locating then
- logs.report("fileio",'! using suffix based filetype: %s',filetype)
+ logs.report("fileio","using suffix based filetype '%s'",filetype)
end
end
else
@@ -8796,7 +8736,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
end
filetype = instance.format
if trace_locating then
- logs.report("fileio",'! using given filetype: %s',filetype)
+ logs.report("fileio","using given filetype '%s'",filetype)
end
end
local typespec = resolvers.variable_of_format(filetype)
@@ -8804,9 +8744,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
if not pathlist or #pathlist == 0 then
-- no pathlist, access check only / todo == wildcard
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
- logs.report("fileio",'? filetype: %s',filetype or '?')
- logs.report("fileio",'? wanted files: %s',concat(wantedfiles," | "))
+ logs.report("fileio","checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
end
for k=1,#wantedfiles do
local fname = wantedfiles[k]
@@ -8829,7 +8767,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local filelist = collect_files(wantedfiles)
local doscan, recurse
if trace_detail then
- logs.report("fileio",'? filename: %s',filename)
+ logs.report("fileio","checking filename '%s'",filename)
end
-- a bit messy ... esp the doscan setting here
for k=1,#pathlist do
@@ -8850,7 +8788,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local f = fl[2]
if find(f,expr) then
if trace_detail then
- logs.report("fileio",'= found in hash: %s',f)
+ logs.report("fileio","file '%s' found in hash",f)
end
--- todo, test for readable
result[#result+1] = fl[3]
@@ -8872,7 +8810,7 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan
local fname = file.join(ppname,w)
if resolvers.isreadable.file(fname) then
if trace_detail then
- logs.report("fileio",'= found by scanning: %s',fname)
+ logs.report("fileio","found '%s' by scanning",fname)
end
result[#result+1] = fname
done = true
@@ -9045,9 +8983,9 @@ function resolvers.load(option)
statistics.starttiming(instance)
resolvers.resetconfig()
resolvers.identify_cnf()
- resolvers.load_lua()
+ resolvers.load_lua() -- will become the new method
resolvers.expand_variables()
- resolvers.load_cnf()
+ resolvers.load_cnf() -- will be skipped when we have a lua file
resolvers.expand_variables()
if option ~= "nofiles" then
resolvers.load_hash()
@@ -9059,14 +8997,14 @@ end
function resolvers.for_files(command, files, filetype, mustexist)
if files and #files > 0 then
local function report(str)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio",str) -- has already verbose
else
print(str)
end
end
- if trace_verbose then
- report('')
+ if trace_locating then
+ report('') -- ?
end
for _, file in ipairs(files) do
local result = command(file,filetype,mustexist)
@@ -9132,7 +9070,7 @@ function resolvers.methodhandler(what, filename, filetype) -- ...
local scheme = specification.scheme
if resolvers[what][scheme] then
if trace_locating then
- logs.report("fileio",'= handler: %s -> %s -> %s',specification.original,what,table.sequenced(specification))
+ logs.report("fileio","handler '%s' -> '%s' -> '%s'",specification.original,what,table.sequenced(specification))
end
return resolvers[what][scheme](filename,filetype) -- todo: specification
else
@@ -9564,8 +9502,6 @@ local format, lower, gsub = string.format, string.lower, string.gsub
local trace_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end)
local trace_containers = false trackers.register("resolvers.containers", function(v) trace_containers = v end)
local trace_storage = false trackers.register("resolvers.storage", function(v) trace_storage = v end)
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
--[[ldx--
<p>Once we found ourselves defining similar cache constructs
@@ -9689,8 +9625,7 @@ if not modules then modules = { } end modules ['data-use'] = {
local format, lower, gsub = string.format, string.lower, string.gsub
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v trackers.enable("resolvers.verbose") end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-- since we want to use the cache instead of the tree, we will now
-- reimplement the saver.
@@ -9822,10 +9757,13 @@ if not modules then modules = { } end modules ['data-zip'] = {
local format, find = string.format, string.find
-local trace_locating, trace_verbose = false, false
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
-trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
-trackers.register("resolvers.locating", function(v) trace_locating = v trace_verbose = v end)
+-- zip:///oeps.zip?name=bla/bla.tex
+-- zip:///oeps.zip?tree=tex/texmf-local
+-- zip:///texmf.zip?tree=/tex/texmf
+-- zip:///texmf.zip?tree=/tex/texmf-local
+-- zip:///texmf-mine.zip?tree=/tex/texmf-projects
zip = zip or { }
zip.archives = zip.archives or { }
@@ -9836,9 +9774,6 @@ local locators, hashers, concatinators = resolvers.locators, resolvers.hashers,
local archives = zip.archives
--- zip:///oeps.zip?name=bla/bla.tex
--- zip:///oeps.zip?tree=tex/texmf-local
-
local function validzip(str) -- todo: use url splitter
if not find(str,"^zip://") then
return "zip:///" .. str
@@ -9868,26 +9803,22 @@ function zip.closearchive(name)
end
end
--- zip:///texmf.zip?tree=/tex/texmf
--- zip:///texmf.zip?tree=/tex/texmf-local
--- zip:///texmf-mine.zip?tree=/tex/texmf-projects
-
function locators.zip(specification) -- where is this used? startup zips (untested)
specification = resolvers.splitmethod(specification)
local zipfile = specification.path
local zfile = zip.openarchive(name) -- tricky, could be in to be initialized tree
if trace_locating then
if zfile then
- logs.report("fileio",'! zip locator, found: %s',specification.original)
+ logs.report("fileio","zip locator, archive '%s' found",specification.original)
else
- logs.report("fileio",'? zip locator, not found: %s',specification.original)
+ logs.report("fileio","zip locator, archive '%s' not found",specification.original)
end
end
end
function hashers.zip(tag,name)
- if trace_verbose then
- logs.report("fileio","loading zip file %s as %s",name,tag)
+ if trace_locating then
+ logs.report("fileio","loading zip file '%s' as '%s'",name,tag)
end
resolvers.usezipfile(format("%s?tree=%s",tag,name))
end
@@ -9912,23 +9843,25 @@ function finders.zip(specification,filetype)
local zfile = zip.openarchive(specification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'! zip finder, path: %s',specification.path)
+ logs.report("fileio","zip finder, archive '%s' found",specification.path)
end
local dfile = zfile:open(q.name)
if dfile then
dfile = zfile:close()
if trace_locating then
- logs.report("fileio",'+ zip finder, name: %s',q.name)
+ logs.report("fileio","zip finder, file '%s' found",q.name)
end
return specification.original
+ elseif trace_locating then
+ logs.report("fileio","zip finder, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'? zip finder, path %s',specification.path)
+ logs.report("fileio","zip finder, unknown archive '%s'",specification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip finder, name: %s',filename)
+ logs.report("fileio","zip finder, '%s' not found",filename)
end
return unpack(finders.notfound)
end
@@ -9941,20 +9874,25 @@ function openers.zip(specification)
local zfile = zip.openarchive(zipspecification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'+ zip starter, path: %s',zipspecification.path)
+ logs.report("fileio","zip opener, archive '%s' opened",zipspecification.path)
end
local dfile = zfile:open(q.name)
if dfile then
logs.show_open(specification)
+ if trace_locating then
+ logs.report("fileio","zip opener, file '%s' found",q.name)
+ end
return openers.text_opener(specification,dfile,'zip')
+ elseif trace_locating then
+ logs.report("fileio","zip opener, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'- zip starter, path %s',zipspecification.path)
+ logs.report("fileio","zip opener, unknown archive '%s'",zipspecification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip opener, name: %s',filename)
+ logs.report("fileio","zip opener, '%s' not found",filename)
end
return unpack(openers.notfound)
end
@@ -9967,25 +9905,27 @@ function loaders.zip(specification)
local zfile = zip.openarchive(specification.path)
if zfile then
if trace_locating then
- logs.report("fileio",'+ zip starter, path: %s',specification.path)
+ logs.report("fileio","zip loader, archive '%s' opened",specification.path)
end
local dfile = zfile:open(q.name)
if dfile then
logs.show_load(filename)
if trace_locating then
- logs.report("fileio",'+ zip loader, name: %s',filename)
+ logs.report("fileio","zip loader, file '%s' loaded",filename)
end
local s = dfile:read("*all")
dfile:close()
return true, s, #s
+ elseif trace_locating then
+ logs.report("fileio","zip loader, file '%s' not found",q.name)
end
elseif trace_locating then
- logs.report("fileio",'- zip starter, path: %s',specification.path)
+ logs.report("fileio","zip loader, unknown archive '%s'",specification.path)
end
end
end
if trace_locating then
- logs.report("fileio",'- zip loader, name: %s',filename)
+ logs.report("fileio","zip loader, '%s' not found",filename)
end
return unpack(openers.notfound)
end
@@ -9995,21 +9935,15 @@ end
function resolvers.usezipfile(zipname)
zipname = validzip(zipname)
- if trace_locating then
- logs.report("fileio",'! zip use, file: %s',zipname)
- end
local specification = resolvers.splitmethod(zipname)
local zipfile = specification.path
if zipfile and not zip.registeredfiles[zipname] then
local tree = url.query(specification.query).tree or ""
- if trace_locating then
- logs.report("fileio",'! zip register, file: %s',zipname)
- end
local z = zip.openarchive(zipfile)
if z then
local instance = resolvers.instance
if trace_locating then
- logs.report("fileio","= zipfile, registering: %s",zipname)
+ logs.report("fileio","zip registering, registering archive '%s'",zipname)
end
statistics.starttiming(instance)
resolvers.prepend_hash('zip',zipname,zipfile)
@@ -10018,10 +9952,10 @@ function resolvers.usezipfile(zipname)
instance.files[zipname] = resolvers.register_zip_file(z,tree or "")
statistics.stoptiming(instance)
elseif trace_locating then
- logs.report("fileio","? zipfile, unknown: %s",zipname)
+ logs.report("fileio","zip registering, unknown archive '%s'",zipname)
end
elseif trace_locating then
- logs.report("fileio",'! zip register, no file: %s',zipname)
+ logs.report("fileio","zip registering, '%s' not found",zipname)
end
end
@@ -10033,7 +9967,7 @@ function resolvers.register_zip_file(z,tree)
filter = format("^%s/(.+)/(.-)$",tree)
end
if trace_locating then
- logs.report("fileio",'= zip filter: %s',filter)
+ logs.report("fileio","zip registering, using filter '%s'",filter)
end
local register, n = resolvers.register_file, 0
for i in z:files() do
@@ -10050,7 +9984,7 @@ function resolvers.register_zip_file(z,tree)
n = n + 1
end
end
- logs.report("fileio",'= zip entries: %s',n)
+ logs.report("fileio","zip registering, %s files registered",n)
return files
end
@@ -10240,47 +10174,47 @@ if not modules then modules = { } end modules ['data-aux'] = {
local find = string.find
-local trace_verbose = false trackers.register("resolvers.verbose", function(v) trace_verbose = v end)
+local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
function resolvers.update_script(oldname,newname) -- oldname -> own.name, not per se a suffix
local scriptpath = "scripts/context/lua"
newname = file.addsuffix(newname,"lua")
local oldscript = resolvers.clean_path(oldname)
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","to be replaced old script %s", oldscript)
end
local newscripts = resolvers.find_files(newname) or { }
if #newscripts == 0 then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","unable to locate new script")
end
else
for i=1,#newscripts do
local newscript = resolvers.clean_path(newscripts[i])
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","checking new script %s", newscript)
end
if oldscript == newscript then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old and new script are the same")
end
elseif not find(newscript,scriptpath) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","new script should come from %s",scriptpath)
end
elseif not (find(oldscript,file.removesuffix(newname).."$") or find(oldscript,newname.."$")) then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","invalid new script name")
end
else
local newdata = io.loaddata(newscript)
if newdata then
- if trace_verbose then
+ if trace_locating then
logs.report("fileio","old script content replaced by new content")
end
io.savedata(oldscript,newdata)
break
- elseif trace_verbose then
+ elseif trace_locating then
logs.report("fileio","unable to load new script")
end
end
@@ -10690,6 +10624,7 @@ messages.help = [[
--unix create unix (linux) stubs
--verbose give a bit more info
+--trackers=list enable given trackers
--engine=str target engine
--progname=str format or backend
@@ -11246,6 +11181,11 @@ else
end
+local trackspec = environment.argument("trackers") or environment.argument("track")
+
+if trackspec then
+ trackers.enable(trackspec)
+end
if environment.argument("selfmerge") then
-- embed used libraries