diff options
author | Marius <mariausol@gmail.com> | 2011-01-31 18:40:12 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-01-31 18:40:12 +0200 |
commit | 8f0a9674137499392552a70d470f614f0eb98b6c (patch) | |
tree | 6d67600678dc90e269c2800f9609e78f307254a1 /tex/context/base/supp-fil.lua | |
parent | cf65f174d2b790545f27134a5d41d39c942a1d5b (diff) | |
download | context-8f0a9674137499392552a70d470f614f0eb98b6c.tar.gz |
beta 2011.01.31 16:59
Diffstat (limited to 'tex/context/base/supp-fil.lua')
-rw-r--r-- | tex/context/base/supp-fil.lua | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/tex/context/base/supp-fil.lua b/tex/context/base/supp-fil.lua index 4370e1163..0ea1fa2b8 100644 --- a/tex/context/base/supp-fil.lua +++ b/tex/context/base/supp-fil.lua @@ -20,9 +20,11 @@ local find, gsub, match, format, concat = string.find, string.gsub, string.match local texcount = tex.count local isfile = lfs.isfile -local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end) +local trace_modules = false trackers.register("modules.loading", function(v) trace_modules = v end) +local trace_files = false trackers.register("resolvers.readfile", function(v) trace_files = v end) local report_modules = logs.new("modules") +local report_files = logs.new("resolvers") commands = commands or { } local commands = commands @@ -106,23 +108,44 @@ local function readfilename(specification,backtrack,treetoo) local name = specification.filename local fnd = found[name] if not fnd then - if fnd ~= "" and isfile(name) then + if isfile(name) then + if trace_files then + report_files("readfile local, found %s",fname) + end fnd = name end - if backtrack and (not fnd or fnd == "") then + if backtrack then local fname = name for i=1,backtrack,1 do fname = "../" .. fname if isfile(fname) then + if trace_files then + report_files("readfile backtracking, found %s",fname) + end fnd = fname break + elseif trace_files then + report_files("readfile backtracking, not found %s",fname) end end end if not fnd and treetoo then - fnd = resolvers.findtexfile(name) + fnd = resolvers.findtexfile(name) or "" + if trace_files then + if fnd ~= "" then + report_files("readfile tree lookup, found %s",fnd) + else + report_files("readfile tree lookup, not found %s",name) + end + end end found[name] = fnd + elseif trace_files then + if fnd ~= "" then + report_files("readfile reuse, already found: %s",fnd) + else + report_files("readfile reuse, already ñot found: %s",name) + end end return fnd or "" end @@ -309,16 +332,19 @@ function commands.uselibrary(name,patterns,action,failure) loaded[filename] = true for i=1,#patterns do local filename = format(patterns[i],filename) - -- local foundname = resolvers.find_file(filename) or "" + -- local foundname = resolvers.findfile(filename) or "" local foundname = finders.doreadfile("any",".",filename) if foundname ~= "" then action(name,foundname) done = true end end + if done then + break + end end end - if not done then + if failure and not done then failure(name) end end |