diff options
22 files changed, 610 insertions, 289 deletions
diff --git a/context/data/texworks/TUG/TeXworks.ini b/context/data/texworks/TUG/TeXworks.ini index 8ef43433e..8c0a4a43d 100644 --- a/context/data/texworks/TUG/TeXworks.ini +++ b/context/data/texworks/TUG/TeXworks.ini @@ -16,30 +16,3 @@ binaryPaths= autoHideConsole=false openDialogDir= recentFileList= - -[engines] -size=6 -1\arguments=--autogenerate, --script, context, $fullname -1\name=ConTeXt MkIV -1\program=mtxrun.cmd -1\showPdf=true -2\arguments=--autogenerate, --script, check, $fullname -2\name=ConTeXt MkIV Check -2\program=mtxrun.cmd -2\showPdf=false -3\arguments=--autogenerate, --script, context, --purgeall -3\name=ConTeXt MkIV Purge -3\program=mtxrun.cmd -3\showPdf=false -4\arguments=/c, start, mtxrun.cmd, --autogenerate, --script, server, --auto -4\name=ConTeXt MkIV Server -4\program=cmd.exe -4\showPdf=false -5\name=ConTeXt MkIV Update -5\program=mtxrun.cmd -5\arguments=--autogenerate, --script, update, --force, --make -5\showPdf=false -6\name=ConTeXt MkIV Make -6\program=mtxrun.cmd -6\arguments=--autogenerate, --script, context, --generate, --make -6\showPdf=false diff --git a/context/data/texworks/configuration/tools.ini b/context/data/texworks/configuration/tools.ini new file mode 100644 index 000000000..73071028b --- /dev/null +++ b/context/data/texworks/configuration/tools.ini @@ -0,0 +1,35 @@ +[001] +name=ConTeXt MkIV +program=mtxrun +arguments=--autogenerate, --script, context, $fullname +showPdf=true + +[002] +name=ConTeXt MkIV Check +program=mtxrun +arguments=--autogenerate, --script, check, $fullname +showPdf=false + +[003] +name=ConTeXt MkIV Purge +program=mtxrun +arguments=--autogenerate, --script, context, --purgeall +showPdf=false + +[004] +name=ConTeXt MkIV Server +program=cmd.exe +arguments=/c, start, mtxrun, --autogenerate, --script, server, --auto +showPdf=false + +[005] +name=ConTeXt MkIV Update +program=mtxrun +arguments=--autogenerate, --script, update, --force, --make +showPdf=false + +[006] +name=ConTeXt MkIV Make +program=mtxrun +arguments=--autogenerate, --script, context, --generate, --make +showPdf=false diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua index a74302b52..8568595a6 100644 --- a/scripts/context/lua/luatools.lua +++ b/scripts/context/lua/luatools.lua @@ -1722,21 +1722,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -1778,18 +1780,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then @@ -4558,7 +4562,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -4969,8 +4973,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -6181,11 +6185,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -6193,22 +6197,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 857f95efd..d80c7242b 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -469,7 +469,7 @@ function scripts.context.multipass.makeoptionfile(jobname,ctxdata,kindofrun,curr setalways( "\\setupsystem[inputfile=%s]",environment.argument("input") or environment.files[1] or "\\jobname") setvalue ("result" , "\\setupsystem[file=%s]") setalways( "\\setupsystem[\\c!n=%s,\\c!m=%s]", kindofrun or 0, currentrun or 0) - -- setalways( "\\setupsystem[\\c!type=%s]",os.platform) + -- setalways( "\\setupsystem[\\c!type=%s]",os.type) -- windows or unix setvalues("path" , "\\usepath[%s]") setvalue ("setuppath" , "\\setupsystem[\\c!directory={%s}]") setvalue ("randomseed" , "\\setupsystem[\\c!random=%s]") diff --git a/scripts/context/lua/mtx-convert.lua b/scripts/context/lua/mtx-convert.lua index cb514720e..fe43c12f2 100644 --- a/scripts/context/lua/mtx-convert.lua +++ b/scripts/context/lua/mtx-convert.lua @@ -11,7 +11,7 @@ if not modules then modules = { } end modules ['mtx-convert'] = { graphics = graphics or { } graphics.converters = graphics.converters or { } -local gsprogram = (os.platform == "windows" and "gswin32c") or "gs" +local gsprogram = (os.type == "windows" and "gswin32c") or "gs" local gstemplate = "%s -q -sDEVICE=pdfwrite -dEPSCrop -dNOPAUSE -dNOCACHE -dBATCH -dAutoRotatePages=/None -dProcessColorModel=/DeviceCMYK -sOutputFile=%s %s -c quit" function graphics.converters.eps(oldname,newname) diff --git a/scripts/context/lua/mtx-mptopdf.lua b/scripts/context/lua/mtx-mptopdf.lua index 4243625ad..69950e008 100644 --- a/scripts/context/lua/mtx-mptopdf.lua +++ b/scripts/context/lua/mtx-mptopdf.lua @@ -10,74 +10,61 @@ scripts = scripts or { } scripts.mptopdf = scripts.mptopdf or { } scripts.mptopdf.aux = scripts.mptopdf.aux or { } -do - -- setup functions and variables here +local dosish = os.type == 'windows' +local miktex = dosish and environment.TEXSYSTEM and environment.TEXSYSTEM:find("miktex") +local escapeshell = environment.SHELL and environment.SHELL:find("sh") and true - local dosish, miktex, escapeshell = false, false, false +function scripts.mptopdf.aux.find_latex(fname) + local d = io.loaddata(fname) or "" + return d:find("\\documentstyle") or d:find("\\documentclass") or d:find("\\begin{document}") +end - if os.platform == 'windows' then - dosish = true - if environment.TEXSYSTEM and environment.TEXSYSTEM:find("miktex") then - miktex = true +function scripts.mptopdf.aux.do_convert (fname) + local command, done, pdfdest = "", 0, "" + if fname:find(".%d+$") or fname:find("%.mps$") then + if miktex then + command = "pdftex -undump=mptopdf" + else + command = "pdftex -fmt=mptopdf -progname=context" end - end - if environment.SHELL and environment.SHELL:find("sh") then - escapeshell = true - end - - function scripts.mptopdf.aux.find_latex(fname) - local d = io.loaddata(fname) or "" - return d:find("\\documentstyle") or d:find("\\documentclass") or d:find("\\begin{document}") - end - - function scripts.mptopdf.aux.do_convert (fname) - local command, done, pdfdest = "", 0, "" - if fname:find(".%d+$") or fname:find("%.mps$") then - if miktex then - command = "pdftex -undump=mptopdf" - else - command = "pdftex -fmt=mptopdf -progname=context" - end - if dosish then - command = string.format('%s \\relax "%s"',command,fname) - else - command = string.format('%s \\\\relax "%s"',command,fname) - end - os.execute(command) - local name, suffix = file.nameonly(fname), file.extname(fname) - local pdfsrc = name .. ".pdf" - if lfs.isfile(pdfsrc) then - pdfdest = name .. "-" .. suffix .. ".pdf" - os.rename(pdfsrc, pdfdest) - if lfs.isfile(pdfsrc) then -- rename failed - file.copy(pdfsrc, pdfdest) - end - done = 1 + if dosish then + command = string.format('%s \\relax "%s"',command,fname) + else + command = string.format('%s \\\\relax "%s"',command,fname) + end + os.execute(command) + local name, suffix = file.nameonly(fname), file.extname(fname) + local pdfsrc = name .. ".pdf" + if lfs.isfile(pdfsrc) then + pdfdest = name .. "-" .. suffix .. ".pdf" + os.rename(pdfsrc, pdfdest) + if lfs.isfile(pdfsrc) then -- rename failed + file.copy(pdfsrc, pdfdest) end + done = 1 end - return done, pdfdest end + return done, pdfdest +end - function scripts.mptopdf.aux.make_mps(fn,latex,rawmp,metafun) - local rest, mpbin = latex and " --tex=latex " or " ", "" - if rawmp then - if metafun then - mpbin = "mpost --progname=mpost --mem=metafun" - else - mpbin = "mpost --mem=mpost" - end +function scripts.mptopdf.aux.make_mps(fn,latex,rawmp,metafun) + local rest, mpbin = latex and " --tex=latex " or " ", "" + if rawmp then + if metafun then + mpbin = "mpost --progname=mpost --mem=metafun" else - if latex then - mpbin = "mpost --mem=mpost" - else - mpbin = "texexec --mptex" - end + mpbin = "mpost --mem=mpost" end - local runner = mpbin .. rest .. fn - logs.simple("running: %s\n", runner) - return (os.execute(runner)) - end - + else + if latex then + mpbin = "mpost --mem=mpost" + else + mpbin = "texexec --mptex" + end + end + local runner = mpbin .. rest .. fn + logs.simple("running: %s\n", runner) + return (os.execute(runner)) end function scripts.mptopdf.convertall() diff --git a/scripts/context/lua/mtx-texworks.lua b/scripts/context/lua/mtx-texworks.lua index 401408b32..e2063ad7e 100644 --- a/scripts/context/lua/mtx-texworks.lua +++ b/scripts/context/lua/mtx-texworks.lua @@ -23,26 +23,28 @@ local texworkssignal = "texworks-context.rme" local texworkininame = "texworks.ini" function scripts.texworks.start(indeed) - local is_mswin = os.platform == "windows" - local workname = (is_mswin and "texworks.exe") or "texworks" + local workname = (os.type == "windows" and "texworks.exe") or "texworks" local fullname = nil local binpaths = file.split_path(os.getenv("PATH")) or file.split_path(os.getenv("path")) - local datapath = resolvers.find_file(texworkssignal,"other text files") or "" + local usedsignal = texworkssignal + local datapath = resolvers.find_file(usedsignal,"other text files") or "" if datapath ~= "" then datapath = file.dirname(datapath) -- data if datapath == "" then - datapath = resolvers.ownpath + datapath = resolvers.clean_path(lfs.currentdir()) end else - datapath = resolvers.find_file(texworkininame,"other text files") or "" + usedsignal = texworkininame + datapath = resolvers.find_file(usedsignal,"other text files") or "" if datapath == "" then - datapath = resolvers.find_file(string.lower(texworkininame),"other text files") or "" + usedsignal = string.lower(usedsignal) + datapath = resolvers.find_file(usedsignal,"other text files") or "" end if datapath ~= "" and lfs.isfile(datapath) then datapath = file.dirname(datapath) -- TUG datapath = file.dirname(datapath) -- data if datapath == "" then - datapath = resolvers.ownpath + datapath = resolvers.clean_path(lfs.currentdir()) end end end @@ -56,7 +58,7 @@ function scripts.texworks.start(indeed) end for i=1,#binpaths do local p = file.join(binpaths[i],workname) - if lfs.isfile(p) then + if lfs.isfile(p) and lfs.attributes(p,"size") > 10000 then -- avoind stub fullname = p break end @@ -71,8 +73,10 @@ function scripts.texworks.start(indeed) os.setenv("TW_INIPATH",datapath) os.setenv("TW_LIBPATH",datapath) if not indeed or environment.argument("verbose") then - logs.simple("data path: %s", datapath) - logs.simple("full name: %s", fullname) + logs.simple("used signal: %s", usedsignal) + logs.simple("data path : %s", datapath) + logs.simple("full name : %s", fullname) + logs.simple("set paths : TW_INIPATH TW_LIBPATH") end if indeed then os.launch(fullname) diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index 4ebfc1124..89cda6978 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -1731,21 +1731,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -1787,18 +1789,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then @@ -4484,6 +4488,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 @@ -4711,7 +4718,43 @@ apply_axis['attribute'] = function(list) return { } end -apply_axis['following'] = function(list) +apply_axis['namespace'] = function(list) + return { } +end + +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['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 @@ -4719,25 +4762,48 @@ apply_axis['following-sibling'] = function(list) 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 + 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 ---~ return { } end -apply_axis['namespace'] = function(list) - return { } -end - -apply_axis['preceding'] = function(list) - return { } +apply_axis['preceding-sibling'] = function(list) + 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['preceding-sibling'] = function(list) - return { } +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'] @@ -4843,13 +4909,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 @@ -4873,7 +4945,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(")"))/"") @@ -4903,6 +4976,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('"')) @@ -4911,6 +4985,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 @@ -4940,9 +5015,11 @@ local converter = Cs ( cleaner = Cs ( ( --~ lp_fastpos + lp_reserved + + lp_number + lp_string + 1 )^1 ) + --~ expr local template_e = [[ @@ -5025,6 +5102,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"] } @@ -5051,8 +5129,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, @@ -5086,6 +5164,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, @@ -5350,6 +5429,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 @@ -7292,7 +7383,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -7703,8 +7794,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -8915,11 +9006,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -8927,22 +9018,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/scripts/context/stubs/mswin/luatools.lua b/scripts/context/stubs/mswin/luatools.lua index a74302b52..8568595a6 100644 --- a/scripts/context/stubs/mswin/luatools.lua +++ b/scripts/context/stubs/mswin/luatools.lua @@ -1722,21 +1722,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -1778,18 +1780,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then @@ -4558,7 +4562,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -4969,8 +4973,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -6181,11 +6185,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -6193,22 +6197,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index 4ebfc1124..89cda6978 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -1731,21 +1731,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -1787,18 +1789,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then @@ -4484,6 +4488,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 @@ -4711,7 +4718,43 @@ apply_axis['attribute'] = function(list) return { } end -apply_axis['following'] = function(list) +apply_axis['namespace'] = function(list) + return { } +end + +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['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 @@ -4719,25 +4762,48 @@ apply_axis['following-sibling'] = function(list) 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 + 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 ---~ return { } end -apply_axis['namespace'] = function(list) - return { } -end - -apply_axis['preceding'] = function(list) - return { } +apply_axis['preceding-sibling'] = function(list) + 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['preceding-sibling'] = function(list) - return { } +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'] @@ -4843,13 +4909,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 @@ -4873,7 +4945,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(")"))/"") @@ -4903,6 +4976,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('"')) @@ -4911,6 +4985,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 @@ -4940,9 +5015,11 @@ local converter = Cs ( cleaner = Cs ( ( --~ lp_fastpos + lp_reserved + + lp_number + lp_string + 1 )^1 ) + --~ expr local template_e = [[ @@ -5025,6 +5102,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"] } @@ -5051,8 +5129,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, @@ -5086,6 +5164,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, @@ -5350,6 +5429,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 @@ -7292,7 +7383,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -7703,8 +7794,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -8915,11 +9006,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -8927,22 +9018,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/scripts/context/stubs/unix/luatools b/scripts/context/stubs/unix/luatools index a74302b52..8568595a6 100755 --- a/scripts/context/stubs/unix/luatools +++ b/scripts/context/stubs/unix/luatools @@ -1722,21 +1722,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -1778,18 +1780,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then @@ -4558,7 +4562,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -4969,8 +4973,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -6181,11 +6185,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -6193,22 +6197,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 4ebfc1124..89cda6978 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -1731,21 +1731,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -1787,18 +1789,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then @@ -4484,6 +4488,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 @@ -4711,7 +4718,43 @@ apply_axis['attribute'] = function(list) return { } end -apply_axis['following'] = function(list) +apply_axis['namespace'] = function(list) + return { } +end + +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['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 @@ -4719,25 +4762,48 @@ apply_axis['following-sibling'] = function(list) 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 + 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 ---~ return { } end -apply_axis['namespace'] = function(list) - return { } -end - -apply_axis['preceding'] = function(list) - return { } +apply_axis['preceding-sibling'] = function(list) + 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['preceding-sibling'] = function(list) - return { } +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'] @@ -4843,13 +4909,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 @@ -4873,7 +4945,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(")"))/"") @@ -4903,6 +4976,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('"')) @@ -4911,6 +4985,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 @@ -4940,9 +5015,11 @@ local converter = Cs ( cleaner = Cs ( ( --~ lp_fastpos + lp_reserved + + lp_number + lp_string + 1 )^1 ) + --~ expr local template_e = [[ @@ -5025,6 +5102,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"] } @@ -5051,8 +5129,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, @@ -5086,6 +5164,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, @@ -5350,6 +5429,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 @@ -7292,7 +7383,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -7703,8 +7794,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -8915,11 +9006,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -8927,22 +9018,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 93055b27a..fa0aaeb10 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.23 22:15} +\newcontextversion{2009.12.24 17:55} %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 962e1ef86..1b5bcfded 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.23 22:15} +\edef\contextversion{2009.12.24 17:55} %D For those who want to use this: diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua index 0299478ba..be4193e6a 100644 --- a/tex/context/base/data-res.lua +++ b/tex/context/base/data-res.lua @@ -65,7 +65,7 @@ resolvers.generators.notfound = { nil } resolvers.cacheversion = '1.0.1' resolvers.cnfname = 'texmf.cnf' resolvers.luaname = 'texmfcnf.lua' -resolvers.homedir = os.env[os.platform == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' +resolvers.homedir = os.env[os.type == "windows" and 'USERPROFILE'] or os.env['HOME'] or '~' resolvers.cnfdefault = '{$SELFAUTODIR,$SELFAUTOPARENT}{,{/share,}/texmf{-local,.local,}/web2c}' local dummy_path_expr = "^!*unset/*$" @@ -476,8 +476,8 @@ function resolvers.getownpath() resolvers.ownpath = os.selfdir else local binary = resolvers.ownbin - if os.platform == "windows" then - binary = file.replacesuffix(binary,"exe") + if os.binsuffix ~= "" then + binary = file.replacesuffix(binary,os.binsuffix) end for p in gmatch(os.getenv("PATH"),"[^"..io.pathseparator.."]+") do local b = file.join(p,binary) @@ -1688,11 +1688,11 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan dirlist[i] = file.dirname(filelist[i][2]) .. "/" end end - local doscan if trace_detail then logs.report("fileio","checking filename '%s'",filename) end -- a bit messy ... esp the doscan setting here + local doscan for k=1,#pathlist do local path = pathlist[k] if find(path,"^!!") then doscan = false else doscan = true end @@ -1700,22 +1700,25 @@ local function collect_instance_files(filename,collected) -- todo : plugin (scan done = false -- using file list if filelist then + local expression -- compare list entries with permitted pattern -- /xx /xx// if not find(pathname,"/$") then - pathname = pathname .. "/" + expression = pathname .. "/" + else + expression = pathname end - pathname = gsub(pathname,"([%-%.])","%%%1") -- this also influences - pathname = gsub(pathname,"//+$", '/.*') -- later usage of pathname - pathname = gsub(pathname,"//", '/.-/') -- not ok for /// but harmless - local expr = "^" .. pathname .. "$" + expression = gsub(expression,"([%-%.])","%%%1") -- this also influences + expression = gsub(expression,"//+$", '/.*') -- later usage of pathname + expression = gsub(expression,"//", '/.-/') -- not ok for /// but harmless + expression = "^" .. expression .. "$" if trace_detail then - logs.report("fileio","using pattern %s for path %s",expr,path) + logs.report("fileio","using pattern '%s' for path '%s'",expression,pathname) end for k=1,#filelist do local fl = filelist[k] local f = fl[2] local d = dirlist[k] - if find(d,expr) then + if find(d,expression) then --- todo, test for readable result[#result+1] = fl[3] resolvers.register_in_trees(f) -- for tracing used files diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua index b8a5c3d1a..b60dfb7fa 100644 --- a/tex/context/base/l-os.lua +++ b/tex/context/base/l-os.lua @@ -28,21 +28,23 @@ function os.resultof(command) end end ---~ os.type : windows | unix (new, we already guessed os.platform) ---~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.type : windows | unix (new, we already guessed os.platform) +--~ os.name : windows | msdos | linux | macosx | solaris | .. | generic (new) +--~ os.platform : extended os.name with architecture if not io.fileseparator then if find(os.getenv("PATH"),";") then - io.fileseparator, io.pathseparator, os.platform = "\\", ";", os.type or "windows" + io.fileseparator, io.pathseparator, os.type = "\\", ";", os.type or "mswin" else - io.fileseparator, io.pathseparator, os.platform = "/" , ":", os.type or "unix" + io.fileseparator, io.pathseparator, os.type = "/" , ":", os.type or "unix" end end -os.platform = os.platform or os.type or (io.pathseparator == ";" and "windows") or "unix" +os.type = os.type or (io.pathseparator == ";" and "windows") or "unix" +os.name = os.name or (os.type == "windows" and "mswin" ) or "linux" function os.launch(str) - if os.platform == "windows" then + if os.type == "windows" then os.execute("start " .. str) -- os.spawn ? else os.execute(str .. " &") -- os.spawn ? @@ -84,18 +86,20 @@ end -- no need for function anymore as we have more clever code and helpers now -os.platform = os.name +os.platform = os.name or os.type or "linux" os.libsuffix = 'so' +os.binsuffix = '' local name = os.name -if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" then +if name == "windows" or name == "mswin" or name == "win32" or name == "msdos" or os.type == "windows" then if os.getenv("PROCESSOR_ARCHITECTURE") == "AMD64" then os.platform = "mswin-64" else os.platform = "mswin" end os.libsuffix = 'dll' + os.binsuffix = 'exe' else local architecture = os.getenv("HOSTTYPE") or "" if architecture == "" then diff --git a/tex/context/base/l-pdfview.lua b/tex/context/base/l-pdfview.lua index 78dfb230b..24b3afc2d 100644 --- a/tex/context/base/l-pdfview.lua +++ b/tex/context/base/l-pdfview.lua @@ -25,7 +25,7 @@ local allcalls = { ['xpdf'] = nil, } -if os.platform == "windows" then +if os.type == "windows" then opencalls['okular'] = 'start "test" "c:/program files/kde/bin/okular.exe" --unique' -- todo: get focus else opencalls['okular'] = 'okular --unique' diff --git a/tex/context/base/luat-iop.lua b/tex/context/base/luat-iop.lua index aaa2c3bdc..d2d80f503 100644 --- a/tex/context/base/luat-iop.lua +++ b/tex/context/base/luat-iop.lua @@ -138,11 +138,11 @@ end function io.inp.modes.handy() io.inp.inhibit('%.%.') - if os.platform == 'linux' then - io.inp.inhibit('^/etc') - else + if os.type == 'windows' then io.inp.inhibit('/windows/') io.inp.inhibit('/winnt/') + else + io.inp.inhibit('^/etc') end end function io.out.modes.handy() diff --git a/tex/context/base/tabl-tbl.mkii b/tex/context/base/tabl-tbl.mkii index 15e827e68..eafb41d47 100644 --- a/tex/context/base/tabl-tbl.mkii +++ b/tex/context/base/tabl-tbl.mkii @@ -1221,7 +1221,8 @@ \dotabulaterule \ifnum\noftabulatelines>\plusone \ifnum\noftabulatelines<\minusnoftabulatelines - \vskip\topskip\allowbreak\vskip-\topskip + % \vskip \topskip\allowbreak \vskip-\topskip + \vskip1\topskip\allowbreak1\vskip-\topskip \vskip-\tabulateparameter\c!rulethickness \dotabulaterule \fi diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index 8e4505977..6d7eb16ae 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1180,12 +1180,23 @@ \prevdepth\strutdp \dotabulatenobreak}} +% see *** +% +% \enabletrackers[nodes.page_vspacing] +% \starttext +% \starttabulate[||] \dorecurse{100}{\NC Eins \NC \NR \HL} \stoptabulate +% \stoptext + \def\tabulateMLfive{\TABLEnoalign {\dotabulateruleseperator \dotabulaterule \ifnum\noftabulatelines>\plusone \ifnum\noftabulatelines<\minusnoftabulatelines - \vskip\topskip\allowbreak\vskip-\topskip + % *** somehow topskip messes up as it's intercepted + % \vskip \topskip\allowbreak\vskip- \topskip + % messy anyhow so this needs to be improved, so for + % the momenet we keep this bugged variant + \vskip1\topskip\allowbreak\vskip-1\topskip \vskip-\tabulateparameter\c!rulethickness \dotabulaterule \fi diff --git a/tex/context/base/trac-lmx.lua b/tex/context/base/trac-lmx.lua index a272564de..1ea4443cb 100644 --- a/tex/context/base/trac-lmx.lua +++ b/tex/context/base/trac-lmx.lua @@ -187,7 +187,7 @@ end lmx.lmxfile = function(filename) return filename end -- beware, these can be set! lmx.htmfile = function(filename) return filename end -- beware, these can be set! -if os.platform == "windows" then +if os.type == "windows" then lmx.popupfile = function(filename) os.execute("start " .. filename) end else lmx.popupfile = function(filename) os.execute(filename) end diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 652bc7473..4cbf701b7 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/23/09 22:18:55 +-- merge date : 12/24/09 18:00:24 do -- begin closure to overcome local limits and interference |