diff options
Diffstat (limited to 'scripts/context/stubs/mswin/luatools.lua')
-rw-r--r-- | scripts/context/stubs/mswin/luatools.lua | 98 |
1 files changed, 72 insertions, 26 deletions
diff --git a/scripts/context/stubs/mswin/luatools.lua b/scripts/context/stubs/mswin/luatools.lua index b6867c629..a74302b52 100644 --- a/scripts/context/stubs/mswin/luatools.lua +++ b/scripts/context/stubs/mswin/luatools.lua @@ -3550,20 +3550,44 @@ end setters = setters or { } setters.data = setters.data or { } +--~ local function set(t,what,value) +--~ local data, done = t.data, t.done +--~ 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 set(t,what,value) local data, done = t.data, t.done if type(what) == "string" then - what = aux.settings_to_array(what) -- inefficient but ok + what = aux.settings_to_hash(what) -- inefficient but ok end - for i=1,#what do - local w = what[i] + for w, v in next, what do + if v == "" then + v = value + else + v = toboolean(v) + end 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) + f[i](v) end end end @@ -3652,7 +3676,9 @@ function setters.show(t) end -- we could have used a bit of oo and the trackers:enable syntax but --- there is already a lot of code around using the singluar tracker +-- there is already a lot of code around using the singular tracker + +-- we could make this into a module function setters.new(name) local t @@ -5885,7 +5911,7 @@ local function collect_files(names) for k=1,#names do local fname = names[k] if trace_detail then - logs.report("fileio","using blobpath '%s'",fname) + logs.report("fileio","checking name '%s'",fname) end local bname = file.basename(fname) local dname = file.dirname(fname) @@ -5901,7 +5927,7 @@ local function collect_files(names) local files = blobpath and instance.files[blobpath] if files then if trace_detail then - logs.report("fileio","processing blobpath '%s' (%s)",blobpath,bname) + logs.report("fileio","deep checking '%s' (%s)",blobpath,bname) end local blobfile = files[bname] if not blobfile then @@ -5935,7 +5961,7 @@ local function collect_files(names) end end elseif trace_locating then - logs.report("fileio","no blobpath '%s' (%s)",blobpath,bname) + logs.report("fileio","no match in '%s' (%s)",blobpath,bname) end end end @@ -6149,7 +6175,13 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan else -- list search local filelist = collect_files(wantedfiles) - local doscan, recurse + local dirlist = { } + if filelist then + for i=1,#filelist do + dirlist[i] = file.dirname(filelist[i][2]) .. "/" + end + end + local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end @@ -6157,28 +6189,42 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end - if find(path,"//$") then recurse = true else recurse = false end local pathname = gsub(path,"^!+", '') done = false -- using file list - if filelist and not (done and not instance.allresults) and recurse then - -- compare list entries with permitted pattern + if filelist then + -- compare list entries with permitted pattern -- /xx /xx// + if not find(pathname,"/$") then + pathname = pathname .. "/" + end pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"/+$", '/.*') -- later usage of pathname + pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname + local expr = "^" .. pathname .. "$" + if trace_detail then + logs.report("fileio","using pattern %s for path %s",expr,path) + end for k=1,#filelist do local fl = filelist[k] local f = fl[2] - if find(f,expr) then - if trace_detail then - logs.report("fileio","file '%s' found in hash",f) - end + local d = dirlist[k] + if find(d,expr) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files done = true - if not instance.allresults then break end + if instance.allresults then + if trace_detail then + logs.report("fileio","match in hash for file '%s' on path '%s', continue scanning",f,d) + end + else + if trace_detail then + logs.report("fileio","match in hash for file '%s' on path '%s', quit scanning",f,d) + end + break + end + elseif trace_detail then + logs.report("fileio","no match in hash for file '%s' on path '%s'",f,d) end end end @@ -6583,7 +6629,7 @@ luatools with a recache feature.</p> 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_cache = false trackers.register("resolvers.cache", function(v) trace_cache = v end) -- not used yet caches = caches or { } @@ -7417,6 +7463,12 @@ end if environment.arguments["trace"] then resolvers.settrace(environment.arguments["trace"]) end +local trackspec = environment.argument("trackers") or environment.argument("track") + +if trackspec then + trackers.enable(trackspec) +end + runners = runners or { } messages = messages or { } @@ -7595,12 +7647,6 @@ 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 |