summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/data-res.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/data-res.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/data-res.lua216
1 files changed, 120 insertions, 96 deletions
diff --git a/Master/texmf-dist/tex/context/base/data-res.lua b/Master/texmf-dist/tex/context/base/data-res.lua
index 7206c0d7824..f7e238a11a3 100644
--- a/Master/texmf-dist/tex/context/base/data-res.lua
+++ b/Master/texmf-dist/tex/context/base/data-res.lua
@@ -12,9 +12,12 @@ if not modules then modules = { } end modules ['data-res'] = {
-- instance but for practical purposes we now avoid this and use a
-- instance variable. We always have one instance active (sort of global).
+-- I will reimplement this module ... way too fuzzy now and we can work
+-- with some sensible constraints as it is only is used for context.
+
-- todo: cache:/// home:/// selfautoparent:/// (sometime end 2012)
-local format, gsub, find, lower, upper, match, gmatch = string.format, string.gsub, string.find, string.lower, string.upper, string.match, string.gmatch
+local gsub, find, lower, upper, match, gmatch = string.gsub, string.find, string.lower, string.upper, string.match, string.gmatch
local concat, insert, sortedkeys = table.concat, table.insert, table.sortedkeys
local next, type, rawget = next, type, rawget
local os = os
@@ -22,14 +25,17 @@ local os = os
local P, S, R, C, Cc, Cs, Ct, Carg = lpeg.P, lpeg.S, lpeg.R, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Ct, lpeg.Carg
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
+local formatters = string.formatters
local filedirname = file.dirname
local filebasename = file.basename
-local fileextname = file.extname
+local suffixonly = file.suffixonly
local filejoin = file.join
local collapsepath = file.collapsepath
local joinpath = file.joinpath
local allocate = utilities.storage.allocate
+local settings_to_array = utilities.parsers.settings_to_array
local setmetatableindex = table.setmetatableindex
+local luasuffixes = utilities.lua.suffixes
local trace_locating = false trackers.register("resolvers.locating", function(v) trace_locating = v end)
local trace_detail = false trackers.register("resolvers.details", function(v) trace_detail = v end)
@@ -52,7 +58,7 @@ resolvers.cacheversion = '1.0.1'
resolvers.configbanner = ''
resolvers.homedir = environment.homedir
resolvers.criticalvars = allocate { "SELFAUTOLOC", "SELFAUTODIR", "SELFAUTOPARENT", "TEXMFCNF", "TEXMF", "TEXOS" }
-resolvers.luacnfname = 'texmfcnf.lua'
+resolvers.luacnfname = "texmfcnf.lua"
resolvers.luacnfstate = "unknown"
-- The web2c tex binaries as well as kpse have built in paths for the configuration
@@ -284,11 +290,12 @@ end
local slash = P("/")
-local pathexpressionpattern = Cs (
+local pathexpressionpattern = Cs ( -- create lpeg instead (2013/2014)
Cc("^") * (
Cc("%") * S(".-")
+ slash^2 * P(-1) / "/.*"
- + slash^2 / "/.-/"
+-- + slash^2 / "/.-/"
+ + slash^2 / "/[^/]*/*"
+ (1-slash) * P(-1) * Cc("/")
+ P(1)
)^1 * Cc("$") -- yes or no $
@@ -314,15 +321,11 @@ local function reportcriticalvariables(cnfspec)
for i=1,#resolvers.criticalvars do
local k = resolvers.criticalvars[i]
local v = resolvers.getenv(k) or "unknown" -- this one will not resolve !
- report_resolving("variable '%s' set to '%s'",k,v)
+ report_resolving("variable %a set to %a",k,v)
end
report_resolving()
if cnfspec then
- if type(cnfspec) == "table" then
- report_resolving("using configuration specification '%s'",concat(cnfspec,","))
- else
- report_resolving("using configuration specification '%s'",cnfspec)
- end
+ report_resolving("using configuration specification %a",type(cnfspec) == "table" and concat(cnfspec,",") or cnfspec)
end
report_resolving()
end
@@ -332,7 +335,7 @@ end
local function identify_configuration_files()
local specification = instance.specification
if #specification == 0 then
- local cnfspec = getenv('TEXMFCNF')
+ local cnfspec = getenv("TEXMFCNF")
if cnfspec == "" then
cnfspec = resolvers.luacnfspec
resolvers.luacnfstate = "default"
@@ -348,10 +351,10 @@ local function identify_configuration_files()
if lfs.isfile(realname) then
specification[#specification+1] = filename
if trace_locating then
- report_resolving("found configuration file '%s'",realname)
+ report_resolving("found configuration file %a",realname)
end
elseif trace_locating then
- report_resolving("unknown configuration file '%s'",realname)
+ report_resolving("unknown configuration file %a",realname)
end
end
if trace_locating then
@@ -383,7 +386,7 @@ local function load_configuration_files()
if blob then
local parentdata = blob()
if parentdata then
- report_resolving("loading configuration file '%s'",filename)
+ report_resolving("loading configuration file %a",filename)
data = table.merged(parentdata,data)
end
end
@@ -391,7 +394,7 @@ local function load_configuration_files()
data = data and data.content
if data then
if trace_locating then
- report_resolving("loading configuration file '%s'",filename)
+ report_resolving("loading configuration file %a",filename)
report_resolving()
end
local variables = data.variables or { }
@@ -402,7 +405,7 @@ local function load_configuration_files()
initializesetter(filename,k,v)
elseif variables[k] == nil then
if trace_locating and not warning then
- report_resolving("variables like '%s' in configuration file '%s' should move to the 'variables' subtable",
+ report_resolving("variables like %a in configuration file %a should move to the 'variables' subtable",
k,resolvers.resolve(filename))
warning = true
end
@@ -420,7 +423,7 @@ local function load_configuration_files()
-- we push the value into the main environment (osenv) so
-- that it takes precedence over the default one and therefore
-- also over following definitions
- resolvers.setenv('TEXMFCNF',cnfspec) -- resolves prefixes
+ resolvers.setenv("TEXMFCNF",cnfspec) -- resolves prefixes
-- we now identify and load the specified configuration files
instance.specification = { }
identify_configuration_files()
@@ -434,13 +437,13 @@ local function load_configuration_files()
else
if trace_locating then
- report_resolving("skipping configuration file '%s' (no content)",filename)
+ report_resolving("skipping configuration file %a (no content)",filename)
end
setups[pathname] = { }
instance.loaderror = true
end
elseif trace_locating then
- report_resolving("skipping configuration file '%s' (no valid format)",filename)
+ report_resolving("skipping configuration file %a (no valid format)",filename)
end
instance.order[#instance.order+1] = instance.setups[pathname]
if instance.loaderror then
@@ -468,10 +471,11 @@ end
local function locate_file_databases()
-- todo: cache:// and tree:// (runtime)
- local texmfpaths = resolvers.expandedpathlist('TEXMF')
+ local texmfpaths = resolvers.expandedpathlist("TEXMF")
if #texmfpaths > 0 then
for i=1,#texmfpaths do
local path = collapsepath(texmfpaths[i])
+ path = gsub(path,"/+$","") -- in case $HOME expands to something with a trailing /
local stripped = lpegmatch(inhibitstripper,path) -- the !! thing
if stripped ~= "" then
local runtime = stripped == path
@@ -484,9 +488,9 @@ local function locate_file_databases()
end
if trace_locating then
if runtime then
- report_resolving("locating list of '%s' (runtime) (%s)",path,stripped)
+ report_resolving("locating list of %a (runtime) (%s)",path,stripped)
else
- report_resolving("locating list of '%s' (cached)",path)
+ report_resolving("locating list of %a (cached)",path)
end
end
methodhandler('locators',stripped)
@@ -519,11 +523,11 @@ local function save_file_databases() -- will become cachers
local content = instance.files[cachename]
caches.collapsecontent(content)
if trace_locating then
- report_resolving("saving tree '%s'",cachename)
+ report_resolving("saving tree %a",cachename)
end
caches.savecontent(cachename,"files",content)
elseif trace_locating then
- report_resolving("not saving runtime tree '%s'",cachename)
+ report_resolving("not saving runtime tree %a",cachename)
end
end
end
@@ -533,30 +537,30 @@ function resolvers.renew(hashname)
local expanded = resolvers.expansion(hashname) or ""
if expanded ~= "" then
if trace_locating then
- report_resolving("identifying tree '%s' from '%s'",expanded,hashname)
+ report_resolving("identifying tree %a from %a",expanded,hashname)
end
hashname = expanded
else
if trace_locating then
- report_resolving("identifying tree '%s'",hashname)
+ report_resolving("identifying tree %a",hashname)
end
end
local realpath = resolvers.resolve(hashname)
if lfs.isdir(realpath) then
if trace_locating then
- report_resolving("using path '%s'",realpath)
+ report_resolving("using path %a",realpath)
end
methodhandler('generators',hashname)
-- could be shared
local content = instance.files[hashname]
caches.collapsecontent(content)
if trace_locating then
- report_resolving("saving tree '%s'",hashname)
+ report_resolving("saving tree %a",hashname)
end
caches.savecontent(hashname,"files",content)
-- till here
else
- report_resolving("invalid path '%s'",realpath)
+ report_resolving("invalid path %a",realpath)
end
end
end
@@ -581,7 +585,7 @@ function resolvers.appendhash(type,name,cache)
-- safeguard ... tricky as it's actually a bug when seen twice
if not instance.hashed[name] then
if trace_locating then
- report_resolving("hash '%s' appended",name)
+ report_resolving("hash %a appended",name)
end
insert(instance.hashes, { type = type, name = name, cache = cache } )
instance.hashed[name] = cache
@@ -592,7 +596,7 @@ function resolvers.prependhash(type,name,cache)
-- safeguard ... tricky as it's actually a bug when seen twice
if not instance.hashed[name] then
if trace_locating then
- report_resolving("hash '%s' prepended",name)
+ report_resolving("hash %a prepended",name)
end
insert(instance.hashes, 1, { type = type, name = name, cache = cache } )
instance.hashed[name] = cache
@@ -600,9 +604,9 @@ function resolvers.prependhash(type,name,cache)
end
function resolvers.extendtexmfvariable(specification) -- crap, we could better prepend the hash
- local t = resolvers.splitpath(getenv('TEXMF'))
+ local t = resolvers.splitpath(getenv("TEXMF")) -- okay?
insert(t,1,specification)
- local newspec = concat(t,";")
+ local newspec = concat(t,",") -- not ;
if instance.environment["TEXMF"] then
instance.environment["TEXMF"] = newspec
elseif instance.variables["TEXMF"] then
@@ -677,14 +681,19 @@ function resolvers.resetextrapath()
end
function resolvers.registerextrapath(paths,subpaths)
+ paths = settings_to_array(paths)
+ subpaths = settings_to_array(subpaths)
local ep = instance.extra_paths or { }
local oldn = #ep
local newn = oldn
- if paths and paths ~= "" then
- if subpaths and subpaths ~= "" then
- for p in gmatch(paths,"[^,]+") do
- -- we gmatch each step again, not that fast, but used seldom
- for s in gmatch(subpaths,"[^,]+") do
+ local nofpaths = #paths
+ local nofsubpaths = #subpaths
+ if nofpaths > 0 then
+ if nofsubpaths > 0 then
+ for i=1,nofpaths do
+ local p = paths[i]
+ for j=1,nofsubpaths do
+ local s = subpaths[j]
local ps = p .. "/" .. s
if not done[ps] then
newn = newn + 1
@@ -694,7 +703,8 @@ function resolvers.registerextrapath(paths,subpaths)
end
end
else
- for p in gmatch(paths,"[^,]+") do
+ for i=1,nofpaths do
+ local p = paths[i]
if not done[p] then
newn = newn + 1
ep[newn] = resolvers.cleanpath(p)
@@ -702,10 +712,10 @@ function resolvers.registerextrapath(paths,subpaths)
end
end
end
- elseif subpaths and subpaths ~= "" then
+ elseif nofsubpaths > 0 then
for i=1,oldn do
- -- we gmatch each step again, not that fast, but used seldom
- for s in gmatch(subpaths,"[^,]+") do
+ for j=1,nofsubpaths do
+ local s = subpaths[j]
local ps = ep[i] .. "/" .. s
if not done[ps] then
newn = newn + 1
@@ -783,18 +793,21 @@ function resolvers.expandedpathlist(str)
return { }
elseif instance.savelists then
str = lpegmatch(dollarstripper,str)
- if not instance.lists[str] then -- cached
- local lst = made_list(instance,resolvers.splitpath(resolvers.expansion(str)))
- instance.lists[str] = expandedpathfromlist(lst)
- end
- return instance.lists[str]
+ local lists = instance.lists
+ local lst = lists[str]
+ if not lst then
+ local l = made_list(instance,resolvers.splitpath(resolvers.expansion(str)))
+ lst = expandedpathfromlist(l)
+ lists[str] = lst
+ end
+ return lst
else
local lst = resolvers.splitpath(resolvers.expansion(str))
return made_list(instance,expandedpathfromlist(lst))
end
end
-function resolvers.expandedpathlistfromvariable(str) -- brrr
+function resolvers.expandedpathlistfromvariable(str) -- brrr / could also have cleaner ^!! /$ //
str = lpegmatch(dollarstripper,str)
local tmp = resolvers.variableofformatorsuffix(str)
return resolvers.expandedpathlist(tmp ~= "" and tmp or str)
@@ -828,9 +841,9 @@ local function isreadable(name)
local readable = lfs.isfile(name) -- not file.is_readable(name) asit can be a dir
if trace_detail then
if readable then
- report_resolving("file '%s' is readable",name)
+ report_resolving("file %a is readable",name)
else
- report_resolving("file '%s' is not readable", name)
+ report_resolving("file %a is not readable", name)
end
end
return readable
@@ -844,14 +857,14 @@ local function collect_files(names)
for k=1,#names do
local fname = names[k]
if trace_detail then
- report_resolving("checking name '%s'",fname)
+ report_resolving("checking name %a",fname)
end
local bname = filebasename(fname)
local dname = filedirname(fname)
if dname == "" or find(dname,"^%.") then
dname = false
else
-dname = gsub(dname,"*","%.*")
+ dname = gsub(dname,"%*",".*")
dname = "/" .. dname .. "$"
end
local hashes = instance.hashes
@@ -861,7 +874,7 @@ dname = gsub(dname,"*","%.*")
local files = blobpath and instance.files[blobpath]
if files then
if trace_detail then
- report_resolving("deep checking '%s' (%s)",blobpath,bname)
+ report_resolving("deep checking %a, base %a, pattern %a",blobpath,bname,dname)
end
local blobfile = files[bname]
if not blobfile then
@@ -881,7 +894,7 @@ dname = gsub(dname,"*","%.*")
local search = filejoin(blobroot,blobfile,bname)
local result = methodhandler('concatinators',hash.type,blobroot,blobfile,bname)
if trace_detail then
- report_resolving("match: variant '%s', search '%s', result '%s'",variant,search,result)
+ report_resolving("match: variant %a, search %a, result %a",variant,search,result)
end
noffiles = noffiles + 1
filelist[noffiles] = { variant, search, result }
@@ -895,7 +908,7 @@ dname = gsub(dname,"*","%.*")
local search = filejoin(blobroot,vv,bname)
local result = methodhandler('concatinators',hash.type,blobroot,vv,bname)
if trace_detail then
- report_resolving("match: variant '%s', search '%s', result '%s'",variant,search,result)
+ report_resolving("match: variant %a, search %a, result %a",variant,search,result)
end
noffiles = noffiles + 1
filelist[noffiles] = { variant, search, result }
@@ -904,7 +917,7 @@ dname = gsub(dname,"*","%.*")
end
end
elseif trace_locating then
- report_resolving("no match in '%s' (%s)",blobpath,bname)
+ report_resolving("no match in %a (%s)",blobpath,bname)
end
end
end
@@ -951,7 +964,7 @@ local preparetreepattern = Cs((P(".")/"%%." + P("-")/"%%-" + P(1))^0 * Cc("$"))
local collect_instance_files
local function find_analyze(filename,askedformat,allresults)
- local filetype, wantedfiles, ext = '', { }, fileextname(filename)
+ local filetype, wantedfiles, ext = '', { }, suffixonly(filename)
-- too tricky as filename can be bla.1.2.3:
--
-- if not suffixmap[ext] then
@@ -966,13 +979,13 @@ local function find_analyze(filename,askedformat,allresults)
wantedfiles[#wantedfiles+1] = forcedname
filetype = resolvers.formatofsuffix(forcedname)
if trace_locating then
- report_resolving("forcing filetype '%s'",filetype)
+ report_resolving("forcing filetype %a",filetype)
end
end
else
filetype = resolvers.formatofsuffix(filename)
if trace_locating then
- report_resolving("using suffix based filetype '%s'",filetype)
+ report_resolving("using suffix based filetype %a",filetype)
end
end
else
@@ -986,7 +999,7 @@ local function find_analyze(filename,askedformat,allresults)
end
filetype = askedformat
if trace_locating then
- report_resolving("using given filetype '%s'",filetype)
+ report_resolving("using given filetype %a",filetype)
end
end
return filetype, wantedfiles
@@ -995,7 +1008,7 @@ end
local function find_direct(filename,allresults)
if not dangerous[askedformat] and isreadable(filename) then
if trace_detail then
- report_resolving("file '%s' found directly",filename)
+ report_resolving("file %a found directly",filename)
end
return "direct", { filename }
end
@@ -1004,7 +1017,7 @@ end
local function find_wildcard(filename,allresults)
if find(filename,'%*') then
if trace_locating then
- report_resolving("checking wildcard '%s'", filename)
+ report_resolving("checking wildcard %a", filename)
end
local method, result = resolvers.findwildcardfiles(filename)
if result then
@@ -1013,23 +1026,23 @@ local function find_wildcard(filename,allresults)
end
end
-local function find_qualified(filename,allresults) -- this one will be split too
+local function find_qualified(filename,allresults,askedformat,alsostripped) -- this one will be split too
if not file.is_qualified_path(filename) then
return
end
if trace_locating then
- report_resolving("checking qualified name '%s'", filename)
+ report_resolving("checking qualified name %a", filename)
end
if isreadable(filename) then
if trace_detail then
- report_resolving("qualified file '%s' found", filename)
+ report_resolving("qualified file %a found", filename)
end
return "qualified", { filename }
end
if trace_detail then
- report_resolving("locating qualified file '%s'", filename)
+ report_resolving("locating qualified file %a", filename)
end
- local forcedname, suffix = "", fileextname(filename)
+ local forcedname, suffix = "", suffixonly(filename)
if suffix == "" then -- why
local format_suffixes = askedformat == "" and resolvers.defaultsuffixes or suffixes[askedformat]
if format_suffixes then
@@ -1038,14 +1051,14 @@ local function find_qualified(filename,allresults) -- this one will be split too
forcedname = filename .. "." .. s
if isreadable(forcedname) then
if trace_locating then
- report_resolving("no suffix, forcing format filetype '%s'", s)
+ report_resolving("no suffix, forcing format filetype %a", s)
end
return "qualified", { forcedname }
end
end
end
end
- if suffix and suffix ~= "" then
+ if alsostripped and suffix and suffix ~= "" then
-- try to find in tree (no suffix manipulation), here we search for the
-- matching last part of the name
local basename = filebasename(filename)
@@ -1060,6 +1073,8 @@ local function find_qualified(filename,allresults) -- this one will be split too
askedformat = "othertextfiles" -- kind of everything, maybe all
end
--
+ -- is this really what we want? basename if we have an explicit path?
+ --
if basename ~= filename then
local resolved = collect_instance_files(basename,askedformat,allresults)
if #resolved == 0 then
@@ -1102,7 +1117,7 @@ end
local function check_subpath(fname)
if isreadable(fname) then
if trace_detail then
- report_resolving("found '%s' by deep scanning",fname)
+ report_resolving("found %a by deep scanning",fname)
end
return fname
end
@@ -1122,9 +1137,13 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
end
end
if trace_detail then
- report_resolving("checking filename '%s'",filename)
+ report_resolving("checking filename %a",filename)
end
+ local resolve = resolvers.resolve
local result = { }
+ -- pathlist : resolved
+ -- dirlist : unresolved or resolved
+ -- filelist : unresolved
for k=1,#pathlist do
local path = pathlist[k]
local pathname = lpegmatch(inhibitstripper,path)
@@ -1138,28 +1157,29 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
-- compare list entries with permitted pattern -- /xx /xx//
local expression = makepathexpression(pathname)
if trace_detail then
- report_resolving("using pattern '%s' for path '%s'",expression,pathname)
+ report_resolving("using pattern %a for path %a",expression,pathname)
end
for k=1,#filelist do
local fl = filelist[k]
local f = fl[2]
local d = dirlist[k]
- if find(d,expression) then
+ -- resolve is new:
+ if find(d,expression) or find(resolve(d),expression) then
-- todo, test for readable
- result[#result+1] = resolvers.resolve(fl[3]) -- no shortcut
+ result[#result+1] = resolve(fl[3]) -- no shortcut
done = true
if allresults then
if trace_detail then
- report_resolving("match to '%s' in hash for file '%s' and path '%s', continue scanning",expression,f,d)
+ report_resolving("match to %a in hash for file %a and path %a, continue scanning",expression,f,d)
end
else
if trace_detail then
- report_resolving("match to '%s' in hash for file '%s' and path '%s', quit scanning",expression,f,d)
+ report_resolving("match to %a in hash for file %a and path %a, quit scanning",expression,f,d)
end
break
end
elseif trace_detail then
- report_resolving("no match to '%s' in hash for file '%s' and path '%s'",expression,f,d)
+ report_resolving("no match to %a in hash for file %a and path %a",expression,f,d)
end
end
end
@@ -1168,7 +1188,7 @@ local function find_intree(filename,filetype,wantedfiles,allresults)
else
method = "filesystem" -- bonus, even when !! is specified
pathname = gsub(pathname,"/+$","")
- pathname = resolvers.resolve(pathname)
+ pathname = resolve(pathname)
local scheme = url.hasscheme(pathname)
if not scheme or scheme == "file" then
local pname = gsub(pathname,"%.%*$",'')
@@ -1244,7 +1264,7 @@ end
local function find_onpath(filename,filetype,wantedfiles,allresults)
if trace_detail then
- report_resolving("checking filename '%s', filetype '%s', wanted files '%s'",filename, filetype or '?',concat(wantedfiles," | "))
+ report_resolving("checking filename %a, filetype %a, wanted files %a",filename,filetype,concat(wantedfiles," | "))
end
local result = { }
for k=1,#wantedfiles do
@@ -1282,7 +1302,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
local results = {
{ find_direct (filename,true) },
{ find_wildcard (filename,true) },
- { find_qualified(filename,true) },
+ { find_qualified(filename,true,askedformat) }, -- we can add ,true if we want to find dups
{ find_intree (filename,filetype,wantedfiles,true) },
{ find_onpath (filename,filetype,wantedfiles,true) },
{ find_otherwise(filename,filetype,wantedfiles,true) },
@@ -1297,7 +1317,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
result[#result+1] = c
done[c] = true
end
- status[#status+1] = format("%-10s: %s",method,c)
+ status[#status+1] = formatters["%-10s: %s"](method,c)
end
end
end
@@ -1308,11 +1328,11 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
else
local method, result, stamp, filetype, wantedfiles
if instance.remember then
- stamp = format("%s--%s", filename, askedformat)
+ stamp = formatters["%s--%s"](filename,askedformat)
result = stamp and instance.found[stamp]
if result then
if trace_locating then
- report_resolving("remembered file '%s'",filename)
+ report_resolving("remembered file %a",filename)
end
return result
end
@@ -1321,7 +1341,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
if not result then
method, result = find_wildcard(filename)
if not result then
- method, result = find_qualified(filename)
+ method, result = find_qualified(filename,false,askedformat)
if not result then
filetype, wantedfiles = find_analyze(filename,askedformat)
method, result = find_intree(filename,filetype,wantedfiles)
@@ -1343,7 +1363,7 @@ collect_instance_files = function(filename,askedformat,allresults) -- uses neste
end
if stamp then
if trace_locating then
- report_resolving("remembering file '%s'",filename)
+ report_resolving("remembering file %a",filename)
end
instance.found[stamp] = result
end
@@ -1399,7 +1419,9 @@ local function findgivenfiles(filename,allresults)
if found ~= "" then
noffound = noffound + 1
result[noffound] = resolvers.resolve(found)
- if not allresults then break end
+ if not allresults then
+ break
+ end
end
else
for kk=1,#blist do
@@ -1596,15 +1618,19 @@ function resolvers.dowithvariable(name,func)
end
function resolvers.locateformat(name)
- local barename = file.removesuffix(name) -- gsub(name,"%.%a+$","")
- local fmtname = caches.getfirstreadablefile(barename..".fmt","formats") or ""
+ local engine = environment.ownmain or "luatex"
+ local barename = file.removesuffix(name)
+ local fullname = file.addsuffix(barename,"fmt")
+ local fmtname = caches.getfirstreadablefile(fullname,"formats",engine) or ""
if fmtname == "" then
- fmtname = resolvers.findfile(barename..".fmt")
+ fmtname = resolvers.findfile(fullname)
fmtname = resolvers.cleanpath(fmtname)
end
if fmtname ~= "" then
local barename = file.removesuffix(fmtname)
- local luaname, lucname, luiname = barename .. ".lua", barename .. ".luc", barename .. ".lui"
+ local luaname = file.addsuffix(barename,luasuffixes.lua)
+ local lucname = file.addsuffix(barename,luasuffixes.luc)
+ local luiname = file.addsuffix(barename,luasuffixes.lui)
if lfs.isfile(luiname) then
return barename, luiname
elseif lfs.isfile(lucname) then
@@ -1640,13 +1666,11 @@ function resolvers.dowithfilesintree(pattern,handle,before,after) -- will move,
local files = instance.files[blobpath]
local total, checked, done = 0, 0, 0
if files then
- for k,v in next, files do
+ for k, v in table.sortedhash(files) do -- next, files do, beware: this is not the resolve order
total = total + 1
if find(k,"^remap:") then
- k = files[k]
- v = k -- files[k] -- chained
- end
- if find(k,pattern) then
+ -- forget about these
+ elseif find(k,pattern) then
if type(v) == "string" then
checked = checked + 1
if handle(blobtype,blobpath,v,k) then