diff options
Diffstat (limited to 'tex/context/base/data-res.lua')
-rw-r--r-- | tex/context/base/data-res.lua | 101 |
1 files changed, 49 insertions, 52 deletions
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index 02ef35f5f..0e87aeb78 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -14,7 +14,7 @@ if not modules then modules = { } end modules ['data-res'] = { -- 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,6 +22,7 @@ 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 suffixonly = file.suffixonly @@ -316,15 +317,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 @@ -350,10 +347,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 @@ -385,7 +382,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 @@ -393,7 +390,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 { } @@ -404,7 +401,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 @@ -436,13 +433,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 @@ -487,9 +484,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) @@ -522,11 +519,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 @@ -536,30 +533,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 @@ -584,7 +581,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 @@ -595,7 +592,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 @@ -840,9 +837,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 @@ -856,7 +853,7 @@ 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) @@ -873,7 +870,7 @@ local function collect_files(names) 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 (%s)",blobpath,bname) end local blobfile = files[bname] if not blobfile then @@ -893,7 +890,7 @@ local function collect_files(names) 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 } @@ -907,7 +904,7 @@ local function collect_files(names) 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 } @@ -916,7 +913,7 @@ local function collect_files(names) 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 @@ -978,13 +975,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 @@ -998,7 +995,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 @@ -1007,7 +1004,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 @@ -1016,7 +1013,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 @@ -1030,16 +1027,16 @@ local function find_qualified(filename,allresults) -- this one will be split too 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 = "", suffixonly(filename) if suffix == "" then -- why @@ -1050,7 +1047,7 @@ 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 @@ -1114,7 +1111,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 @@ -1134,7 +1131,7 @@ 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 result = { } for k=1,#pathlist do @@ -1150,7 +1147,7 @@ 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] @@ -1162,16 +1159,16 @@ local function find_intree(filename,filetype,wantedfiles,allresults) 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 @@ -1256,7 +1253,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 @@ -1309,7 +1306,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 @@ -1320,11 +1317,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 @@ -1355,7 +1352,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 |