diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-12-23 22:15:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-12-23 22:15:00 +0100 |
commit | 78ee07252af9126a45b146030034f4c769265121 (patch) | |
tree | a09240d01dce91fe176584898d7c66465ed2717e | |
parent | 608f6a9dca87c2073c2a74c7eb961ec3077f9f76 (diff) | |
download | context-78ee07252af9126a45b146030034f4c769265121.tar.gz |
beta 2009.12.23 22:15
-rw-r--r-- | scripts/context/lua/luatools.lua | 98 | ||||
-rw-r--r-- | scripts/context/lua/mtxrun.lua | 117 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/luatools.lua | 98 | ||||
-rw-r--r-- | scripts/context/stubs/mswin/mtxrun.lua | 117 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/luatools | 98 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mtxrun | 117 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/core-con.lua | 104 | ||||
-rw-r--r-- | tex/context/base/data-res.lua | 48 | ||||
-rw-r--r-- | tex/context/base/data-tmp.lua | 2 | ||||
-rw-r--r-- | tex/context/base/lxml-lpt.lua | 114 | ||||
-rw-r--r-- | tex/context/base/page-ini.mkiv | 6 | ||||
-rw-r--r-- | tex/context/base/strc-not.mkiv | 1 | ||||
-rw-r--r-- | tex/context/base/strc-pag.mkiv | 9 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 2 | ||||
-rw-r--r-- | web2c/context.cnf | 11 |
17 files changed, 722 insertions, 224 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua index b6867c629..a74302b52 100644 --- a/scripts/context/lua/luatools.lua +++ b/scripts/context/lua/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 diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 617bdadab..4ebfc1124 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3249,20 +3249,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 @@ -3351,7 +3375,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 @@ -4690,7 +4716,16 @@ apply_axis['following'] = function(list) end apply_axis['following-sibling'] = function(list) - return { } + local collected = { } + for l=1,#list do + local ll = list[l] +print(xml.tostring(ll)) + if ll.special ~= true then -- catch double root + collected[#collected+1] = ll + end + end + return collected +--~ return { } end apply_axis['namespace'] = function(list) @@ -8610,7 +8645,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) @@ -8626,7 +8661,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 @@ -8660,7 +8695,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 @@ -8874,7 +8909,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 @@ -8882,28 +8923,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 @@ -9308,7 +9363,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 { } @@ -10855,6 +10910,12 @@ logs.setprogram('MTXrun',"TDS Runner Tool 1.24",environment.arguments["verbose"] local instance = resolvers.reset() +local trackspec = environment.argument("trackers") or environment.argument("track") + +if trackspec then + trackers.enable(trackspec) +end + runners = runners or { } -- global messages = messages or { } @@ -11262,20 +11323,22 @@ function runners.find_mtx_script(filename) if fullname and fullname ~= "" then return fullname end + -- mtx- prefix checking + local mtxprefix = (filename:find("^mtx%-") and "") or "mtx-" -- context namespace, mtx-<filename> - fullname = "mtx-" .. filename + fullname = mtxprefix .. filename fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname end -- context namespace, mtx-<filename>s - fullname = "mtx-" .. basename .. "s" .. "." .. suffix + fullname = mtxprefix .. basename .. "s" .. "." .. suffix fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname end -- context namespace, mtx-<filename minus trailing s> - fullname = "mtx-" .. basename:gsub("s$","") .. "." .. suffix + fullname = mtxprefix .. basename:gsub("s$","") .. "." .. suffix fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname @@ -11469,12 +11532,6 @@ else end -local trackspec = environment.argument("trackers") or environment.argument("track") - -if trackspec then - trackers.enable(trackspec) -end - if is_mkii_stub then -- execute mkii script ok = runners.execute_script(filename,false,true) 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 diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 617bdadab..4ebfc1124 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3249,20 +3249,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 @@ -3351,7 +3375,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 @@ -4690,7 +4716,16 @@ apply_axis['following'] = function(list) end apply_axis['following-sibling'] = function(list) - return { } + local collected = { } + for l=1,#list do + local ll = list[l] +print(xml.tostring(ll)) + if ll.special ~= true then -- catch double root + collected[#collected+1] = ll + end + end + return collected +--~ return { } end apply_axis['namespace'] = function(list) @@ -8610,7 +8645,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) @@ -8626,7 +8661,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 @@ -8660,7 +8695,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 @@ -8874,7 +8909,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 @@ -8882,28 +8923,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 @@ -9308,7 +9363,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 { } @@ -10855,6 +10910,12 @@ logs.setprogram('MTXrun',"TDS Runner Tool 1.24",environment.arguments["verbose"] local instance = resolvers.reset() +local trackspec = environment.argument("trackers") or environment.argument("track") + +if trackspec then + trackers.enable(trackspec) +end + runners = runners or { } -- global messages = messages or { } @@ -11262,20 +11323,22 @@ function runners.find_mtx_script(filename) if fullname and fullname ~= "" then return fullname end + -- mtx- prefix checking + local mtxprefix = (filename:find("^mtx%-") and "") or "mtx-" -- context namespace, mtx-<filename> - fullname = "mtx-" .. filename + fullname = mtxprefix .. filename fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname end -- context namespace, mtx-<filename>s - fullname = "mtx-" .. basename .. "s" .. "." .. suffix + fullname = mtxprefix .. basename .. "s" .. "." .. suffix fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname end -- context namespace, mtx-<filename minus trailing s> - fullname = "mtx-" .. basename:gsub("s$","") .. "." .. suffix + fullname = mtxprefix .. basename:gsub("s$","") .. "." .. suffix fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname @@ -11469,12 +11532,6 @@ else end -local trackspec = environment.argument("trackers") or environment.argument("track") - -if trackspec then - trackers.enable(trackspec) -end - if is_mkii_stub then -- execute mkii script ok = runners.execute_script(filename,false,true) diff --git a/scripts/context/stubs/unix/luatools b/scripts/context/stubs/unix/luatools index b6867c629..a74302b52 100755 --- a/scripts/context/stubs/unix/luatools +++ b/scripts/context/stubs/unix/luatools @@ -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 diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 617bdadab..4ebfc1124 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3249,20 +3249,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 @@ -3351,7 +3375,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 @@ -4690,7 +4716,16 @@ apply_axis['following'] = function(list) end apply_axis['following-sibling'] = function(list) - return { } + local collected = { } + for l=1,#list do + local ll = list[l] +print(xml.tostring(ll)) + if ll.special ~= true then -- catch double root + collected[#collected+1] = ll + end + end + return collected +--~ return { } end apply_axis['namespace'] = function(list) @@ -8610,7 +8645,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) @@ -8626,7 +8661,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 @@ -8660,7 +8695,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 @@ -8874,7 +8909,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 @@ -8882,28 +8923,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 @@ -9308,7 +9363,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 { } @@ -10855,6 +10910,12 @@ logs.setprogram('MTXrun',"TDS Runner Tool 1.24",environment.arguments["verbose"] local instance = resolvers.reset() +local trackspec = environment.argument("trackers") or environment.argument("track") + +if trackspec then + trackers.enable(trackspec) +end + runners = runners or { } -- global messages = messages or { } @@ -11262,20 +11323,22 @@ function runners.find_mtx_script(filename) if fullname and fullname ~= "" then return fullname end + -- mtx- prefix checking + local mtxprefix = (filename:find("^mtx%-") and "") or "mtx-" -- context namespace, mtx-<filename> - fullname = "mtx-" .. filename + fullname = mtxprefix .. filename fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname end -- context namespace, mtx-<filename>s - fullname = "mtx-" .. basename .. "s" .. "." .. suffix + fullname = mtxprefix .. basename .. "s" .. "." .. suffix fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname end -- context namespace, mtx-<filename minus trailing s> - fullname = "mtx-" .. basename:gsub("s$","") .. "." .. suffix + fullname = mtxprefix .. basename:gsub("s$","") .. "." .. suffix fullname = found(fullname) or resolvers.find_file(fullname) if fullname and fullname ~= "" then return fullname @@ -11469,12 +11532,6 @@ else end -local trackspec = environment.argument("trackers") or environment.argument("track") - -if trackspec then - trackers.enable(trackspec) -end - if is_mkii_stub then -- execute mkii script ok = runners.execute_script(filename,false,true) diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index d9f7d7281..93055b27a 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.12.22 13:15} +\newcontextversion{2009.12.23 22:15} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index a5dd4eec6..962e1ef86 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.12.22 13:15} +\edef\contextversion{2009.12.23 22:15} %D For those who want to use this: diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua index b8ca17387..cca386ee4 100644 --- a/tex/context/base/core-con.lua +++ b/tex/context/base/core-con.lua @@ -309,7 +309,7 @@ function converters.abjadnodotnumerals(n) return texsprint(converters.toabjad(n, local vector = { normal = { - [0] = "○", + [0] = "〇", [1] = "一", [2] = "二", [3] = "三", @@ -343,7 +343,7 @@ local vector = { [100000000] = "亿", }, all = { - [0] = "○", + [0] = "〇", [1] = "一", [2] = "二", [3] = "三", @@ -363,7 +363,63 @@ local vector = { } } +--~ function tochinese(n,name) -- normal, caps, all +--~ local result = { } +--~ local vector = vector[name] or vector.normal +--~ while true do +--~ if n == 0 then +--~ break +--~ elseif n >= 100000000 then +--~ local m = floor(n/100000000) +--~ if m > 1 then result[#result+1] = tochinese(m) end +--~ result[#result+1] = vector[100000000] +--~ n = n % 100000000 +--~ elseif n >= 10000000 then +--~ result[#result+1] = tochinese(floor(n/10000)) +--~ result[#result+1] = vector[10000] +--~ n = n % 10000 +--~ elseif n >= 1000000 then +--~ result[#result+1] = tochinese(floor(n/10000)) +--~ result[#result+1] = vector[10000] +--~ n = n % 10000 +--~ elseif n >= 100000 then +--~ result[#result+1] = tochinese(floor(n/10000)) +--~ result[#result+1] = vector[10000] +--~ n = n % 10000 +--~ elseif n >= 10000 then +--~ local m = floor(n/10000) +--~ if m > 1 then result[#result+1] = vector[m] end +--~ result[#result+1] = vector[10000] +--~ n = n % 10000 +--~ elseif n >= 1000 then +--~ local m = floor(n/1000) +--~ if m > 1 then result[#result+1] = vector[m] end +--~ result[#result+1] = vector[1000] +--~ n = n % 1000 +--~ elseif n >= 100 then +--~ local m = floor(n/100) +--~ if m > 1 then result[#result+1] = vector[m] end +--~ result[#result+1] = vector[100] +--~ n = n % 100 +--~ elseif n >= 10 then +--~ local m = floor(n/10) +--~ if vector[m*10] then +--~ result[#result+1] = vector[m*10] +--~ else +--~ result[#result+1] = vector[m] +--~ result[#result+1] = vector[10] +--~ end +--~ n = n % 10 +--~ else +--~ result[#result+1] = vector[n] +--~ break +--~ end +--~ end +--~ return concat(result) +--~ end + function tochinese(n,name) -- normal, caps, all + -- improved version by Li Yanrui local result = { } local vector = vector[name] or vector.normal while true do @@ -371,39 +427,56 @@ function tochinese(n,name) -- normal, caps, all break elseif n >= 100000000 then local m = floor(n/100000000) - if m > 1 then result[#result+1] = tochinese(m) end + result[#result+1] = tochinese(m,name) result[#result+1] = vector[100000000] + local z = n - m * 100000000 + if z > 0 and z < 10000000 then result[#result+1] = vector[0] end n = n % 100000000 elseif n >= 10000000 then - result[#result+1] = tochinese(floor(n/10000)) + local m = floor(n/10000) + result[#result+1] = tochinese(m,name) result[#result+1] = vector[10000] + local z = n - m * 10000 + if z > 0 and z < 1000 then result[#result+1] = vector[0] end n = n % 10000 elseif n >= 1000000 then - result[#result+1] = tochinese(floor(n/10000)) + local m = floor(n/10000) + result[#result+1] = tochinese(m,name) result[#result+1] = vector[10000] + local z = n - m * 10000 + if z > 0 and z < 1000 then result[#result+1] = vector[0] end n = n % 10000 elseif n >= 100000 then - result[#result+1] = tochinese(floor(n/10000)) + local m = floor(n/10000) + result[#result+1] = tochinese(m,name) result[#result+1] = vector[10000] + local z = n - m * 10000 + if z > 0 and z < 1000 then result[#result+1] = vector[0] end n = n % 10000 - elseif n >= 10000 then + elseif n >= 10000 then local m = floor(n/10000) - if m > 1 then result[#result+1] = vector[m] end + result[#result+1] = vector[m] result[#result+1] = vector[10000] + local z = n - m * 10000 + if z > 0 and z < 1000 then result[#result+1] = vector[0] end n = n % 10000 - elseif n >= 1000 then + elseif n >= 1000 then local m = floor(n/1000) - if m > 1 then result[#result+1] = vector[m] end + result[#result+1] = vector[m] result[#result+1] = vector[1000] + local z = n - m * 1000 + if z > 0 and z < 100 then result[#result+1] = vector[0] end n = n % 1000 - elseif n >= 100 then + elseif n >= 100 then local m = floor(n/100) - if m > 1 then result[#result+1] = vector[m] end + result[#result+1] = vector[m] result[#result+1] = vector[100] + local z = n - m * 100 + if z > 0 and z < 10 then result[#result+1] = vector[0] end n = n % 100 - elseif n >= 10 then + elseif n >= 10 then local m = floor(n/10) - if vector[m*10] then + if m > 1 and vector[m*10] then result[#result+1] = vector[m*10] else result[#result+1] = vector[m] @@ -415,6 +488,9 @@ function tochinese(n,name) -- normal, caps, all break end end + if (result[1] == vector[1] and result[2] == vector[10]) then + result[1] = "" + end return concat(result) end diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index c7f360141..0299478ba 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -1418,7 +1418,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) @@ -1434,7 +1434,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 @@ -1468,7 +1468,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 @@ -1682,7 +1682,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 @@ -1690,28 +1696,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 diff --git a/tex/context/base/data-tmp.lua b/tex/context/base/data-tmp.lua index ba338b5a4..88e5d1e3b 100644 --- a/tex/context/base/data-tmp.lua +++ b/tex/context/base/data-tmp.lua @@ -24,7 +24,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 { } diff --git a/tex/context/base/lxml-lpt.lua b/tex/context/base/lxml-lpt.lua index 406d00c05..936288d34 100644 --- a/tex/context/base/lxml-lpt.lua +++ b/tex/context/base/lxml-lpt.lua @@ -12,6 +12,9 @@ local concat, remove, insert = table.concat, table.remove, table.insert local type, next, tonumber, tostring, setmetatable, loadstring = type, next, tonumber, tostring, setmetatable, loadstring local format, upper, lower, gmatch, gsub, find, rep = string.format, string.upper, string.lower, string.gmatch, string.gsub, string.find, string.rep +-- beware, this is not xpath ... e.g. position is different (currently) and +-- we have reverse-sibling as reversed preceding sibling + --[[ldx-- <p>This module can be used stand alone but also inside <l n='mkiv'/> in which case it hooks into the tracker code. Therefore we provide a few @@ -239,24 +242,92 @@ apply_axis['attribute'] = function(list) return { } end -apply_axis['following'] = function(list) +apply_axis['namespace'] = function(list) return { } end -apply_axis['following-sibling'] = function(list) +apply_axis['following'] = function(list) -- incomplete +--~ local collected = { } +--~ for l=1,#list do +--~ local ll = list[l] +--~ local p = ll.__p__ +--~ local d = p.dt +--~ for i=ll.ni+1,#d do +--~ local di = d[i] +--~ if type(di) == "table" then +--~ collected[#collected+1] = di +--~ break +--~ end +--~ end +--~ end +--~ return collected return { } end -apply_axis['namespace'] = function(list) +apply_axis['preceding'] = function(list) -- incomplete +--~ local collected = { } +--~ for l=1,#list do +--~ local ll = list[l] +--~ local p = ll.__p__ +--~ local d = p.dt +--~ for i=ll.ni-1,1,-1 do +--~ local di = d[i] +--~ if type(di) == "table" then +--~ collected[#collected+1] = di +--~ break +--~ end +--~ end +--~ end +--~ return collected return { } end -apply_axis['preceding'] = function(list) - return { } +apply_axis['following-sibling'] = function(list) + local collected = { } + for l=1,#list do + local ll = list[l] + local p = ll.__p__ + local d = p.dt + for i=ll.ni+1,#d do + local di = d[i] + if type(di) == "table" then + collected[#collected+1] = di + end + end + end + return collected end apply_axis['preceding-sibling'] = function(list) - return { } + local collected = { } + for l=1,#list do + local ll = list[l] + local p = ll.__p__ + local d = p.dt + for i=1,ll.ni-1 do + local di = d[i] + if type(di) == "table" then + collected[#collected+1] = di + end + end + end + return collected +end + +apply_axis['reverse-sibling'] = function(list) -- reverse preceding + local collected = { } + for l=1,#list do + local ll = list[l] + local p = ll.__p__ + local d = p.dt + for i=ll.ni-1,1,-1 do + local di = d[i] + if type(di) == "table" then + collected[#collected+1] = di + end + end + end + return collected end apply_axis['auto-descendant-or-self'] = apply_axis['descendant-or-self'] @@ -362,13 +433,19 @@ local function apply_nodes(list,directive,nodes) end end +local quit_expression = false + local function apply_expression(list,expression,order) local collected = { } + quit_expression = false for l=1,#list do local ll = list[l] if expression(list,ll,l,order) then -- nasty, alleen valid als n=1 collected[#collected+1] = ll end + if quit_expression then + break + end end return collected end @@ -392,7 +469,8 @@ local lp_builtin = P ( P("index") / "(ll.ni or 1)" + P("match") / "(ll.mi or 1)" + P("text") / "(ll.dt[1] or '')" + - P("name") / "(ll.ns~='' and ll.ns..':'..ll.tg)" + +--~ P("name") / "(ll.ns~='' and ll.ns..':'..ll.tg)" + + P("name") / "((ll.ns~='' and ll.ns..':'..ll.tg) or ll.tg)" + P("tag") / "ll.tg" + P("ns") / "ll.ns" ) * ((spaces * P("(") * spaces * P(")"))/"") @@ -422,6 +500,7 @@ local nested = lpeg.P{lparent * (noparent + lpeg.V(1))^0 * rparent} local value = lpeg.P(lparent * lpeg.C((noparent + nested)^0) * rparent) -- lpeg.P{"("*C(((1-S("()"))+V(1))^0)*")"} local lp_child = Cc("expr.child(ll,'") * R("az","AZ","--","__")^1 * Cc("')") +local lp_number = S("+-") * R("09")^1 local lp_string = Cc("'") * R("az","AZ","--","__")^1 * Cc("'") local lp_content = (P("'") * (1-P("'"))^0 * P("'") + P('"') * (1-P('"'))^0 * P('"')) @@ -430,6 +509,7 @@ local cleaner local lp_special = (C(P("name")+P("text")+P("tag")+P("count")+P("child"))) * value / function(t,s) if expressions[t] then s = s and s ~= "" and cleaner:match(s) +--~ print("!!!",t,s) if s and s ~= "" then return "expr." .. t .. "(ll," .. s ..")" else @@ -459,9 +539,11 @@ local converter = Cs ( cleaner = Cs ( ( --~ lp_fastpos + lp_reserved + + lp_number + lp_string + 1 )^1 ) + --~ expr local template_e = [[ @@ -544,6 +626,7 @@ local register_following = { kind = "axis", axis = "following" local register_following_sibling = { kind = "axis", axis = "following-sibling" } -- , apply = apply_axis["following-sibling"] } local register_preceding = { kind = "axis", axis = "preceding" } -- , apply = apply_axis["preceding"] } local register_preceding_sibling = { kind = "axis", axis = "preceding-sibling" } -- , apply = apply_axis["preceding-sibling"] } +local register_reverse_sibling = { kind = "axis", axis = "reverse-sibling" } -- , apply = apply_axis["reverse-sibling"] } local register_auto_descendant_or_self = { kind = "axis", axis = "auto-descendant-or-self" } -- , apply = apply_axis["auto-descendant-or-self"] } local register_auto_descendant = { kind = "axis", axis = "auto-descendant" } -- , apply = apply_axis["auto-descendant"] } @@ -570,8 +653,8 @@ local parser = Ct { "patterns", -- can be made a bit faster by moving pattern ou step = ((V("shortcuts") + P("/") + V("axis")) * spaces * V("nodes")^0 + V("error")) * spaces * V("expressions")^0 * spaces * V("finalizer")^0, axis = V("descendant") + V("child") + V("parent") + V("self") + V("root") + V("ancestor") + - V("descendant_or_self") + V("following") + V("following_sibling") + - V("preceding") + V("preceding_sibling") + V("ancestor_or_self") + + V("descendant_or_self") + V("following_sibling") + V("following") + + V("reverse_sibling") + V("preceding_sibling") + V("preceding") + V("ancestor_or_self") + #(1-P(-1)) * Cc(register_auto_child), initial = (P("/") * spaces * Cc(register_initial_child))^-1, @@ -605,6 +688,7 @@ local parser = Ct { "patterns", -- can be made a bit faster by moving pattern ou following_sibling = P('following-sibling::') * Cc(register_following_sibling ), preceding = P('preceding::') * Cc(register_preceding ), preceding_sibling = P('preceding-sibling::') * Cc(register_preceding_sibling ), + reverse_sibling = P('reverse-sibling::') * Cc(register_reverse_sibling ), nodes = (V("nodefunction") * spaces * P("(") * V("nodeset") * P(")") + V("nodetest") * V("nodeset")) / register_nodes, @@ -869,6 +953,18 @@ expressions.undefined = function(s) return s == nil end +expressions.quit = function(s) + if s or s == nil then + quit_expression = true + end + return true +end + +expressions.print = function(...) + print(...) + return true +end + expressions.contains = find expressions.find = find expressions.upper = upper diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index 476acfd1e..fae7611ac 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -523,7 +523,6 @@ {\forgetall \beforefinaloutput \the\everybeforeshipout - \setpagecounters \message{[-\the\realpageno]}% \setbox\scratchbox\hbox{\dopagebody#1#2}% \deadcycles\zerocount @@ -551,6 +550,7 @@ \fi#1#2% \resetselectiepagina \incrementpagenumber + \incrementsubpagenumber \checkpagedimensions \ifnum\outputpenalty>\superpenalty \else \dosupereject @@ -883,9 +883,9 @@ {%\getallmarks % now in following token register \the\everybeforepagebody \starttextproperties - \setnextsubpageno % nog eens: als in pagina (tbv standaard opmaak) +% \setnextsubpageno % nog eens: als in pagina (tbv standaard opmaak) \dontshowboxes % dan hier blokkeren en verderop resetten -% \shipoutfacingpage +% \shipoutfacingpage \checkmargeblokken \the\beforeeverypage \normalexpanded{\global\beforepage\emptytoks\the\beforepage}% \scratchtoks\beforepage\global\beforepage\emptytoks\the\scratchtoks % was \flushtoks\beforepage diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index 4c3fd2f22..09cf523ec 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -641,6 +641,7 @@ \edef\currentnote{#1}% \edef\currentdescriptionnumberentry{#2}% % \let\currentenumerationfullnumber\currentnoteenumerationfullnumber + \dontcomplain % should be done in startstoreddescription instead \dostartstoreddescription\begstrut\currentnotedescriptiontext\endstrut\dostopstoreddescription} \def\dostartstoreddescription diff --git a/tex/context/base/strc-pag.mkiv b/tex/context/base/strc-pag.mkiv index 4bcee80ea..c7cc701af 100644 --- a/tex/context/base/strc-pag.mkiv +++ b/tex/context/base/strc-pag.mkiv @@ -256,10 +256,13 @@ \def\setnextrealpageno{\global\realpageno\incrementedstructurecounter[\s!realpage]\relax} \def\setnextsubpageno {\global\subpageno \incrementedstructurecounter[\s!subpage ]\relax} -% Page numbers: +% Page numbers: (can move to lua) -\def\dodecrementpagenumber{\global\userpageno\decrementedstructurecounter[\s!userpage]\relax} -\def\doincrementpagenumber{\global\userpageno\incrementedstructurecounter[\s!userpage]\relax} +\def\dodecrementpagenumber {\global\userpageno\decrementedstructurecounter[\s!userpage]\relax} +\def\doincrementpagenumber {\global\userpageno\incrementedstructurecounter[\s!userpage]\relax} + +\def\decrementsubpagenumber{\global\subpageno \decrementedstructurecounter[\s!subpage ]\relax} +\def\incrementsubpagenumber{\global\subpageno \incrementedstructurecounter[\s!subpage ]\relax} \def\dosynchronizepagenumber{\global\let\@@pnstate\v!start} diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 52c46884c..652bc7473 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 12/22/09 13:19:25 +-- merge date : 12/23/09 22:18:55 do -- begin closure to overcome local limits and interference diff --git a/web2c/context.cnf b/web2c/context.cnf index d3c8d123b..1263aaf4f 100644 --- a/web2c/context.cnf +++ b/web2c/context.cnf @@ -98,16 +98,9 @@ CTXDEVTXPATH=unset CTXDEVMPPATH=unset CTXDEVMFPATH=unset -#~ TEXINPUTS = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/{pdftex,pdfetex,etex,xetex,omega,tex}/{context,plain,generic,}// -#~ TEXINPUTS = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/{pdftex,pdfetex,etex,xetex,omega,tex}/{$progname,plain,generic,}// -TEXINPUTS = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/tex/{$progname,plain,generic,}// - -% TEXINPUTS.context = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/{pdftex,pdfetex,etex,xetex,omega,tex}/{context,plain,generic,}// -% TEXINPUTS.context = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/{tex,omega}/{context,plain,generic}// -% TEXINPUTS.context = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/tex/{context,plain/base,generic/context,generic/hyphen,generic/omega}// +TEXINPUTS = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/tex/{$progname,plain,generic,}// TEXINPUTS.context = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/tex/{context,plain/base,generic}// MPINPUTS = .;{$MFRESOURCES}//;{$CTXDEVMPPATH};$TEXMF/metapost/{context,base,}// -#~ MFINPUTS = .;{$MPRESOURCES}//;{$CTXDEVMFPATH};$TEXMF/metafont/{context,base,}//;{$TEXMF/fonts,$VARTEXFONTS}/source// MFINPUTS = .;{$MPRESOURCES}//;{$CTXDEVMFPATH};$TEXMF/metafont/{context,base,}//;$TEXMF/fonts/source// BSTINPUTS = .;{$TXRESOURCES}//;{$CTXDEVTXPATH};$TEXMF/bibtex/bst// @@ -131,7 +124,7 @@ RUBYINPUTS = .;$CTXDEVRBPATH;$TEXMF/scripts/context/ruby JAVAINPUTS = .;$CTXDEVJVPATH;$TEXMF/scripts/context/java % LUAINPUTS = .;$TEXINPUTS;$TEXMFSCRIPTS -LUAINPUTS = .;$CTXDEVLUPATH;$TEXINPUTS;$TEXMF/scripts/context/lua +LUAINPUTS = .;$CTXDEVLUPATH;$TEXINPUTS;$TEXMF/scripts/context/lua// TEXMFSCRIPTS = .;$CTXDEVLUPATH;$TEXINPUTS;$CTXDEVRBPATH;$CTXDEVPLPATH;$TEXMF/scripts/context/{lua,ruby,perl}// % RUBYINPUTS = .;$CTXDEVPLPATH;$TEXMF/scripts/{$progname,$engine,}/ruby |