diff options
Diffstat (limited to 'scripts/context/stubs/unix')
-rwxr-xr-x | scripts/context/stubs/unix/ctxtools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/luatools | 52 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/makempy | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mpstools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mptopdf | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mtxrun | 92 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/mtxtools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/pdftools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/pstopdf | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/rlxtools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/runtools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/texexec | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/texfont | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/textools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/texutil | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/tmftools | 2 | ||||
-rwxr-xr-x | scripts/context/stubs/unix/xmltools | 2 |
17 files changed, 102 insertions, 72 deletions
diff --git a/scripts/context/stubs/unix/ctxtools b/scripts/context/stubs/unix/ctxtools deleted file mode 100755 index 4658a345a..000000000 --- a/scripts/context/stubs/unix/ctxtools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute ctxtools.rb "$@" diff --git a/scripts/context/stubs/unix/luatools b/scripts/context/stubs/unix/luatools index 692213b09..6feb7a9c5 100755 --- a/scripts/context/stubs/unix/luatools +++ b/scripts/context/stubs/unix/luatools @@ -1780,6 +1780,7 @@ function os.currentplatform(name,default) platform = "linux" end elseif name == "macosx" then + local architecture = os.resultof("echo $HOSTTYPE") if find(architecture,"i386") then platform = "osx-intel" elseif find(architecture,"x86_64") then @@ -1881,8 +1882,8 @@ function file.nameonly(name) return (gsub(match(name,"^.+[/\\](.-)$") or name,"%..*$","")) end -function file.extname(name) - return match(name,"^.+%.([^/\\]-)$") or "" +function file.extname(name,default) + return match(name,"^.+%.([^/\\]-)$") or default or "" end file.suffix = file.extname @@ -3757,7 +3758,7 @@ end if arg then - -- new, reconstruct quoted snippets (maybe better just remnove the " then and add them later) + -- new, reconstruct quoted snippets (maybe better just remove the " then and add them later) local newarg, instring = { }, false for index, argument in ipairs(arg) do @@ -4077,6 +4078,9 @@ if not modules then modules = { } end modules ['luat-log'] = { -- this is old code that needs an overhaul +--~ io.stdout:setvbuf("no") +--~ io.stderr:setvbuf("no") + local write_nl, write, format = texio.write_nl or print, texio.write or io.write, string.format local texcount = tex and tex.count @@ -4158,27 +4162,49 @@ function logs.tex.line(fmt,...) -- new end end +--~ function logs.tex.start_page_number() +--~ local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +--~ if real > 0 then +--~ if user > 0 then +--~ if sub > 0 then +--~ write(format("[%s.%s.%s",real,user,sub)) +--~ else +--~ write(format("[%s.%s",real,user)) +--~ end +--~ else +--~ write(format("[%s",real)) +--~ end +--~ else +--~ write("[-") +--~ end +--~ end + +--~ function logs.tex.stop_page_number() +--~ write("]") +--~ end + +local real, user, sub + function logs.tex.start_page_number() - local real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno + real, user, sub = texcount.realpageno, texcount.userpageno, texcount.subpageno +end + +function logs.tex.stop_page_number() if real > 0 then if user > 0 then if sub > 0 then - write(format("[%s.%s.%s",real,user,sub)) + logs.report("pages", "flushing page, realpage %s, userpage %s, subpage %s",real,user,sub) else - write(format("[%s.%s",real,user)) + logs.report("pages", "flushing page, realpage %s, userpage %s",real,user) end else - write(format("[%s",real)) + logs.report("pages", "flushing page, realpage %s",real) end else - write("[-") + logs.report("pages", "flushing page") end end -function logs.tex.stop_page_number() - write("]") -end - logs.tex.report_job_stat = statistics.show_job_stat -- xml logging @@ -4621,7 +4647,7 @@ function resolvers.settrace(n) -- no longer number but: 'locating' or 'detail' end end -resolvers.settrace(os.getenv("MTX.resolvers.TRACE") or os.getenv("MTX_INPUT_TRACE")) +resolvers.settrace(os.getenv("MTX_INPUT_TRACE")) function resolvers.osenv(key) local ie = instance.environment diff --git a/scripts/context/stubs/unix/makempy b/scripts/context/stubs/unix/makempy deleted file mode 100755 index 34892b284..000000000 --- a/scripts/context/stubs/unix/makempy +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute makempy.pl "$@" diff --git a/scripts/context/stubs/unix/mpstools b/scripts/context/stubs/unix/mpstools deleted file mode 100755 index 1a64d90b0..000000000 --- a/scripts/context/stubs/unix/mpstools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute mpstools.rb "$@" diff --git a/scripts/context/stubs/unix/mptopdf b/scripts/context/stubs/unix/mptopdf deleted file mode 100755 index f57a8b7a7..000000000 --- a/scripts/context/stubs/unix/mptopdf +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute mptopdf.pl "$@" diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index a187f0697..ceb9cb886 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -1789,6 +1789,7 @@ function os.currentplatform(name,default) platform = "linux" end elseif name == "macosx" then + local architecture = os.resultof("echo $HOSTTYPE") if find(architecture,"i386") then platform = "osx-intel" elseif find(architecture,"x86_64") then @@ -4773,8 +4774,9 @@ local lp_and = P("&") / " and " local lp_builtin = P ( P("first") / "1" + P("last") / "#list" + - P("position") / "l" + + P("position") / "l" + -- is element in finalizer P("rootposition") / "order" + + P("order") / "order" + P("index") / "(ll.ni or 1)" + P("match") / "(ll.mi or 1)" + P("text") / "(ll.dt[1] or '')" + @@ -6125,11 +6127,15 @@ local function position(collected,n) elseif n > 0 then return collected[n] else - return collected[1].mi -- match + return collected[1].mi or 0 end end end +local function match(collected) + return (collected and collected[1].mi) or 0 -- match +end + local function index(collected) if collected then return collected[1].ni @@ -6283,6 +6289,7 @@ finalizers.attribute = attribute finalizers.att = att finalizers.count = count finalizers.position = position +finalizers.match = match finalizers.index = index finalizers.attributes = attributes finalizers.chainattribute = chainattribute @@ -6334,10 +6341,14 @@ end xml.content = text -function xml.position(id,pattern,n) +function xml.position(id,pattern,n) -- element return position(xmlfilter(id,pattern),n) end +function xml.match(id,pattern) -- number + return match(xmlfilter(id,pattern)) +end + function xml.empty(id,pattern) return empty(xmlfilter(id,pattern)) end @@ -6801,7 +6812,7 @@ end -- of closure do -- create closure to overcome 200 locals limit -if not modules then modules = { } end modules ['luat-log'] = { +if not modules then modules = { } end modules ['trac-log'] = { version = 1.001, comment = "companion to trac-log.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -7078,8 +7089,12 @@ end logs.simpleline = logs.reportline -function logs.help(message,option) +function logs.reportbanner() -- for scripts too logs.report(banner) +end + +function logs.help(message,option) + logs.reportbanner() logs.reportline() logs.reportlines(message) local moreinfo = logs.moreinfo or "" @@ -7380,7 +7395,7 @@ function resolvers.settrace(n) -- no longer number but: 'locating' or 'detail' end end -resolvers.settrace(os.getenv("MTX.resolvers.TRACE") or os.getenv("MTX_INPUT_TRACE")) +resolvers.settrace(os.getenv("MTX_INPUT_TRACE")) function resolvers.osenv(key) local ie = instance.environment @@ -10639,7 +10654,7 @@ runners = runners or { } -- global messages = messages or { } messages.help = [[ ---script run an mtx script (--noquotes) +--script run an mtx script (--noquotes), no script gives list --execute run a script or program (--noquotes) --resolve resolve prefixed arguments --ctxlua run internally (using preloaded libs) @@ -10685,20 +10700,17 @@ runners.suffixes = { } runners.registered = { - texexec = { 'texexec.rb', true }, -- context mkii runner (only tool not to be luafied) + texexec = { 'texexec.rb', false }, -- context mkii runner (only tool not to be luafied) texutil = { 'texutil.rb', true }, -- old perl based index sorter for mkii (old versions need it) texfont = { 'texfont.pl', true }, -- perl script that makes mkii font metric files texfind = { 'texfind.pl', false }, -- perltk based tex searching tool, mostly used at pragma texshow = { 'texshow.pl', false }, -- perltk based context help system, will be luafied - -- texwork = { \texwork.pl', false }, -- perltk based editing environment, only used at pragma - + -- texwork = { 'texwork.pl', false }, -- perltk based editing environment, only used at pragma makempy = { 'makempy.pl', true }, mptopdf = { 'mptopdf.pl', true }, pstopdf = { 'pstopdf.rb', true }, -- converts ps (and some more) images, does some cleaning (replaced) - -- examplex = { 'examplex.rb', false }, concheck = { 'concheck.rb', false }, - runtools = { 'runtools.rb', true }, textools = { 'textools.rb', true }, tmftools = { 'tmftools.rb', true }, @@ -10710,7 +10722,6 @@ runners.registered = { xmltools = { 'xmltools.rb', true }, -- luatools = { 'luatools.lua', true }, mtxtools = { 'mtxtools.rb', true }, - pdftrimwhite = { 'pdftrimwhite.pl', false } } @@ -10763,7 +10774,7 @@ function runners.prepare() return "run" end -function runners.execute_script(fullname,internal) +function runners.execute_script(fullname,internal,nosplit) local noquote = environment.argument("noquotes") if fullname and fullname ~= "" then local state = runners.prepare() @@ -10803,17 +10814,19 @@ function runners.execute_script(fullname,internal) end end if result and result ~= "" then - local before, after = environment.split_arguments(fullname) -- already done - environment.arguments_before, environment.arguments_after = before, after + if not no_split then + local before, after = environment.split_arguments(fullname) -- already done + environment.arguments_before, environment.arguments_after = before, after + end if internal then - arg = { } for _,v in pairs(after) do arg[#arg+1] = v end + arg = { } for _,v in pairs(environment.arguments_after) do arg[#arg+1] = v end dofile(result) else local binary = runners.applications[file.extname(result)] if binary and binary ~= "" then result = binary .. " " .. result end - local command = result .. " " .. environment.reconstruct_commandline(after,noquote) + local command = result .. " " .. environment.reconstruct_commandline(environment.arguments_after,noquote) if logs.verbose then logs.simpleline() logs.simple("executing: %s",command) @@ -10821,7 +10834,7 @@ function runners.execute_script(fullname,internal) logs.simpleline() io.flush() end - local code = os.exec(command) -- maybe spawn + local code = os.exec(command) -- maybe spawn return code == 0 end end @@ -10855,7 +10868,7 @@ function runners.execute_program(fullname) return false end --- the --usekpse flag will fallback on kpse +-- the --usekpse flag will fallback on kpse (hm, we can better update mtx-stubs) local windows_stub = '@echo off\013\010setlocal\013\010set ownpath=%%~dp0%%\013\010texlua "%%ownpath%%mtxrun.lua" --usekpse --execute %s %%*\013\010endlocal\013\010' local unix_stub = '#!/bin/sh\010mtxrun --usekpse --execute %s \"$@\"\010' @@ -11096,22 +11109,35 @@ function runners.execute_ctx_script(filename,arguments) return true end else - logs.setverbose(true) - if filename == "" then - logs.simple("unknown script, no name given") + -- logs.setverbose(true) + if filename == "" or filename == "help" then local context = resolvers.find_file("mtx-context.lua") + logs.setverbose(true) if context ~= "" then local result = dir.glob((string.gsub(context,"mtx%-context","mtx-*"))) -- () needed local valid = { } + table.sort(result) for _, scriptname in ipairs(result) do - scriptname = string.match(scriptname,".*mtx%-([^%-]-)%.lua") - if scriptname then - valid[#valid+1] = scriptname + local scriptbase = string.match(scriptname,".*mtx%-([^%-]-)%.lua") + if scriptbase then + local data = io.loaddata(scriptname) + local banner, version = string.match(data,"[\n\r]logs%.extendbanner%s*%(%s*[\"\']([^\n\r]+)%s*(%d+%.%d+)") + if banner then + valid[#valid+1] = { scriptbase, version, banner } + end end end if #valid > 0 then - logs.simple("known scripts: %s",table.concat(valid,", ")) + logs.reportbanner() + logs.reportline() + logs.simple("no script name given, known scripts:") + logs.simple() + for k, v in ipairs(valid) do + logs.simple("%-12s %4s %s",v[1],v[2],v[3]) + end end + else + logs.simple("no script name given") end else filename = file.addsuffix(filename,"lua") @@ -11125,6 +11151,7 @@ function runners.execute_ctx_script(filename,arguments) end end + function runners.timedrun(filename) -- just for me if filename and filename ~= "" then runners.timed(function() os.execute(filename) end) @@ -11152,7 +11179,9 @@ instance.lsrmode = environment.argument("lsr") or false -- maybe the unset has to go to this level -if environment.argument("usekpse") or environment.argument("forcekpse") then +local is_mkii_stub = runners.registered[file.removesuffix(file.basename(filename))] + +if environment.argument("usekpse") or environment.argument("forcekpse") or is_mkii_stub then os.setenv("engine","") os.setenv("progname","") @@ -11187,7 +11216,7 @@ if environment.argument("usekpse") or environment.argument("forcekpse") then return (kpse_initialized():show_path(name)) or "" end - elseif environment.argument("usekpse") then + elseif environment.argument("usekpse") or is_mkii_stub then resolvers.load() @@ -11222,7 +11251,10 @@ if trackspec then trackers.enable(trackspec) end -if environment.argument("selfmerge") then +if is_mkii_stub then + -- execute mkii script + ok = runners.execute_script(filename,false,true) +elseif environment.argument("selfmerge") then -- embed used libraries utils.merger.selfmerge(own.name,own.libs,own.list) elseif environment.argument("selfclean") then diff --git a/scripts/context/stubs/unix/mtxtools b/scripts/context/stubs/unix/mtxtools deleted file mode 100755 index 3803c1c6f..000000000 --- a/scripts/context/stubs/unix/mtxtools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute mtxtools.rb "$@" diff --git a/scripts/context/stubs/unix/pdftools b/scripts/context/stubs/unix/pdftools deleted file mode 100755 index da7bd64cf..000000000 --- a/scripts/context/stubs/unix/pdftools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute pdftools.rb "$@" diff --git a/scripts/context/stubs/unix/pstopdf b/scripts/context/stubs/unix/pstopdf deleted file mode 100755 index 059812cce..000000000 --- a/scripts/context/stubs/unix/pstopdf +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute pstopdf.rb "$@" diff --git a/scripts/context/stubs/unix/rlxtools b/scripts/context/stubs/unix/rlxtools deleted file mode 100755 index d01987b3c..000000000 --- a/scripts/context/stubs/unix/rlxtools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute rlxtools.rb "$@" diff --git a/scripts/context/stubs/unix/runtools b/scripts/context/stubs/unix/runtools deleted file mode 100755 index e21c1a244..000000000 --- a/scripts/context/stubs/unix/runtools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute runtools.rb "$@" diff --git a/scripts/context/stubs/unix/texexec b/scripts/context/stubs/unix/texexec index 083e500c6..cd5900ff8 100755 --- a/scripts/context/stubs/unix/texexec +++ b/scripts/context/stubs/unix/texexec @@ -1,2 +1,2 @@ #!/bin/sh -mtxrun --usekpse --execute texexec.rb "$@" +mtxrun --usekpse --execute texexec "$@" diff --git a/scripts/context/stubs/unix/texfont b/scripts/context/stubs/unix/texfont deleted file mode 100755 index bc811a640..000000000 --- a/scripts/context/stubs/unix/texfont +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute texfont.pl "$@" diff --git a/scripts/context/stubs/unix/textools b/scripts/context/stubs/unix/textools deleted file mode 100755 index 76087ca57..000000000 --- a/scripts/context/stubs/unix/textools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute textools.rb "$@" diff --git a/scripts/context/stubs/unix/texutil b/scripts/context/stubs/unix/texutil deleted file mode 100755 index f5d9b6f1d..000000000 --- a/scripts/context/stubs/unix/texutil +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute texutil.rb "$@" diff --git a/scripts/context/stubs/unix/tmftools b/scripts/context/stubs/unix/tmftools deleted file mode 100755 index 48d32f0fd..000000000 --- a/scripts/context/stubs/unix/tmftools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute tmftools.rb "$@" diff --git a/scripts/context/stubs/unix/xmltools b/scripts/context/stubs/unix/xmltools deleted file mode 100755 index a673d1e7a..000000000 --- a/scripts/context/stubs/unix/xmltools +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mtxrun --usekpse --execute xmltools.rb "$@" |