summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/luatools.lua52
-rw-r--r--scripts/context/lua/luatools.rme2
-rw-r--r--scripts/context/lua/mtx-babel.lua2
-rw-r--r--scripts/context/lua/mtx-cache.lua2
-rw-r--r--scripts/context/lua/mtx-chars.lua24
-rw-r--r--scripts/context/lua/mtx-check.lua2
-rw-r--r--scripts/context/lua/mtx-context.lua2
-rw-r--r--scripts/context/lua/mtx-convert.lua2
-rw-r--r--scripts/context/lua/mtx-fonts.lua2
-rw-r--r--scripts/context/lua/mtx-interface.lua2
-rw-r--r--scripts/context/lua/mtx-metatex.lua2
-rw-r--r--scripts/context/lua/mtx-modules.lua2
-rw-r--r--scripts/context/lua/mtx-package.lua2
-rw-r--r--scripts/context/lua/mtx-patterns.lua2
-rw-r--r--scripts/context/lua/mtx-profile.lua2
-rw-r--r--scripts/context/lua/mtx-server.lua2
-rw-r--r--scripts/context/lua/mtx-texworks.lua2
-rw-r--r--scripts/context/lua/mtx-timing.lua2
-rw-r--r--scripts/context/lua/mtx-tools.lua2
-rw-r--r--scripts/context/lua/mtx-update.lua2
-rw-r--r--scripts/context/lua/mtx-watch.lua2
-rw-r--r--scripts/context/lua/mtxrun.lua92
-rw-r--r--scripts/context/lua/mtxrun.rme21
-rw-r--r--scripts/context/ruby/newimgtopdf.rb8
-rw-r--r--scripts/context/ruby/newpstopdf.rb8
-rw-r--r--scripts/context/ruby/newtexexec.rb8
-rw-r--r--scripts/context/ruby/newtexutil.rb8
-rw-r--r--scripts/context/stubs/mswin/context.cmd5
-rwxr-xr-xscripts/context/stubs/mswin/context.exebin0 -> 5631 bytes
-rwxr-xr-xscripts/context/stubs/mswin/ctxtools.bat5
-rw-r--r--scripts/context/stubs/mswin/luatools.cmd5
-rwxr-xr-xscripts/context/stubs/mswin/luatools.exebin0 -> 5631 bytes
-rw-r--r--scripts/context/stubs/mswin/luatools.lua52
-rwxr-xr-xscripts/context/stubs/mswin/makempy.bat5
-rw-r--r--scripts/context/stubs/mswin/metatex.cmd5
-rwxr-xr-xscripts/context/stubs/mswin/metatex.exebin0 -> 5631 bytes
-rwxr-xr-xscripts/context/stubs/mswin/mpstools.bat5
-rwxr-xr-xscripts/context/stubs/mswin/mptopdf.bat5
-rw-r--r--scripts/context/stubs/mswin/mtxrun.cmd5
-rw-r--r--scripts/context/stubs/mswin/mtxrun.dllbin0 -> 7679 bytes
-rwxr-xr-xscripts/context/stubs/mswin/mtxrun.exebin0 -> 5631 bytes
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua92
-rwxr-xr-xscripts/context/stubs/mswin/mtxtools.bat5
-rw-r--r--scripts/context/stubs/mswin/mtxworks.cmd1
-rwxr-xr-xscripts/context/stubs/mswin/mtxworks.exebin0 -> 5631 bytes
-rwxr-xr-xscripts/context/stubs/mswin/pdftools.bat5
-rwxr-xr-xscripts/context/stubs/mswin/pstopdf.bat5
-rwxr-xr-xscripts/context/stubs/mswin/rlxtools.bat5
-rwxr-xr-xscripts/context/stubs/mswin/runtools.bat5
-rwxr-xr-xscripts/context/stubs/mswin/texexec.bat5
-rw-r--r--scripts/context/stubs/mswin/texexec.cmd5
-rwxr-xr-xscripts/context/stubs/mswin/texexec.exebin0 -> 5631 bytes
-rwxr-xr-xscripts/context/stubs/mswin/texfont.bat5
-rw-r--r--scripts/context/stubs/mswin/texmfstart.cmd5
-rwxr-xr-xscripts/context/stubs/mswin/texmfstart.exebin0 -> 5631 bytes
-rwxr-xr-xscripts/context/stubs/mswin/textools.bat5
-rwxr-xr-xscripts/context/stubs/mswin/texutil.bat5
-rwxr-xr-xscripts/context/stubs/mswin/tmftools.bat5
-rwxr-xr-xscripts/context/stubs/mswin/xmltools.bat5
-rw-r--r--scripts/context/stubs/source/mtxrun_dll.c214
-rw-r--r--scripts/context/stubs/source/mtxrun_exe.c10
-rw-r--r--scripts/context/stubs/source/readme.txt36
-rwxr-xr-xscripts/context/stubs/unix/ctxtools2
-rwxr-xr-xscripts/context/stubs/unix/luatools52
-rwxr-xr-xscripts/context/stubs/unix/makempy2
-rwxr-xr-xscripts/context/stubs/unix/mpstools2
-rwxr-xr-xscripts/context/stubs/unix/mptopdf2
-rwxr-xr-xscripts/context/stubs/unix/mtxrun92
-rwxr-xr-xscripts/context/stubs/unix/mtxtools2
-rwxr-xr-xscripts/context/stubs/unix/pdftools2
-rwxr-xr-xscripts/context/stubs/unix/pstopdf2
-rwxr-xr-xscripts/context/stubs/unix/rlxtools2
-rwxr-xr-xscripts/context/stubs/unix/runtools2
-rwxr-xr-xscripts/context/stubs/unix/texexec2
-rwxr-xr-xscripts/context/stubs/unix/texfont2
-rwxr-xr-xscripts/context/stubs/unix/textools2
-rwxr-xr-xscripts/context/stubs/unix/texutil2
-rwxr-xr-xscripts/context/stubs/unix/tmftools2
-rwxr-xr-xscripts/context/stubs/unix/xmltools2
79 files changed, 613 insertions, 330 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua
index 692213b09..6feb7a9c5 100644
--- a/scripts/context/lua/luatools.lua
+++ b/scripts/context/lua/luatools.lua
@@ -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/lua/luatools.rme b/scripts/context/lua/luatools.rme
index b320e1184..901e9a9a3 100644
--- a/scripts/context/lua/luatools.rme
+++ b/scripts/context/lua/luatools.rme
@@ -1,3 +1,3 @@
On MSWindows the luatools.lua script is called
-with luatools.cmd. On Unix you can either rename
+with luatools.exe. On Unix you can either rename
luatools.lua to luatools, or use a symlink.
diff --git a/scripts/context/lua/mtx-babel.lua b/scripts/context/lua/mtx-babel.lua
index e241e9334..01e2ba4b2 100644
--- a/scripts/context/lua/mtx-babel.lua
+++ b/scripts/context/lua/mtx-babel.lua
@@ -415,7 +415,7 @@ do
end
-logs.extendbanner("Babel Conversion Tools 1.2",true)
+logs.extendbanner("Babel Input To UTF Conversion 1.20",true)
messages.help = [[
--language=string conversion language (e.g. greek)
diff --git a/scripts/context/lua/mtx-cache.lua b/scripts/context/lua/mtx-cache.lua
index a1fbed825..9f54d9754 100644
--- a/scripts/context/lua/mtx-cache.lua
+++ b/scripts/context/lua/mtx-cache.lua
@@ -76,7 +76,7 @@ function scripts.cache.list(all)
end)
end
-logs.extendbanner("Cache Tools 0.10")
+logs.extendbanner("ConTeXt & MetaTeX Cache Management 0.10")
messages.help = [[
--purge remove not used files
diff --git a/scripts/context/lua/mtx-chars.lua b/scripts/context/lua/mtx-chars.lua
index d4330ca30..0b93587a3 100644
--- a/scripts/context/lua/mtx-chars.lua
+++ b/scripts/context/lua/mtx-chars.lua
@@ -11,17 +11,17 @@ local format, concat, utfchar, upper = string.format, table.concat, unicode.utf8
scripts = scripts or { }
scripts.chars = scripts.chars or { }
-local banner = [[
--- filename : char-mth.lua
--- comment : companion to char-mth.tex (in ConTeXt)
--- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
--- license : see context related readme files
--- comment : generated from data file downloaded from STIX website
-
-if not versions then versions = { } end versions['char-mth'] = 1.001
-if not characters then characters = { } end
-]]
-
+--~ local banner = [[
+--~ -- filename : char-mth.lua
+--~ -- comment : companion to char-mth.tex (in ConTeXt)
+--~ -- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
+--~ -- license : see context related readme files
+--~ -- comment : generated from data file downloaded from STIX website
+--~
+--~ if not versions then versions = { } end versions['char-mth'] = 1.001
+--~ if not characters then characters = { } end
+--~ ]]
+--~
--~ function scripts.chars.stixtomkiv(inname,outname)
--~ if inname == "" then
--~ logs.report("aquiring math data","invalid datafilename")
@@ -301,7 +301,7 @@ function scripts.chars.makeencoutf()
end
end
-logs.extendbanner("Character Tools 0.10")
+logs.extendbanner("MkII Character Table Generators 0.10")
messages.help = [[
--stix convert stix table to math table
diff --git a/scripts/context/lua/mtx-check.lua b/scripts/context/lua/mtx-check.lua
index 6be7f2765..436a205e0 100644
--- a/scripts/context/lua/mtx-check.lua
+++ b/scripts/context/lua/mtx-check.lua
@@ -123,7 +123,7 @@ function scripts.checker.check(filename)
end
end
-logs.extendbanner("Syntax Checking 0.10",true)
+logs.extendbanner("Basic ConTeXt Syntax Checking 0.10",true)
messages.help = [[
--convert check tex file for errors
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index b146b3c09..2ed661774 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -1381,7 +1381,7 @@ function scripts.context.update()
end
end
-logs.extendbanner("ConTeXt Tools 0.51",true)
+logs.extendbanner("ConTeXt Process Management 0.51",true)
messages.help = [[
--run process (one or more) files (default action)
diff --git a/scripts/context/lua/mtx-convert.lua b/scripts/context/lua/mtx-convert.lua
index 5e9a71573..cb514720e 100644
--- a/scripts/context/lua/mtx-convert.lua
+++ b/scripts/context/lua/mtx-convert.lua
@@ -118,7 +118,7 @@ function scripts.convert.convertgiven()
end
-logs.extendbanner("Graphic Conversion Tools 0.10",true)
+logs.extendbanner("ConTeXT Graphic Conversion Helpers 0.10",true)
messages.help = [[
--convertall convert all graphics on path
diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua
index 4d3e52382..bc93eaaa9 100644
--- a/scripts/context/lua/mtx-fonts.lua
+++ b/scripts/context/lua/mtx-fonts.lua
@@ -281,7 +281,7 @@ function scripts.fonts.save()
end
end
-logs.extendbanner("Font Tools 0.21",true)
+logs.extendbanner("ConTeXt Font Database Management 0.21",true)
messages.help = [[
--save save open type font in raw table
diff --git a/scripts/context/lua/mtx-interface.lua b/scripts/context/lua/mtx-interface.lua
index 264a2dbe4..4aaa3b5a0 100644
--- a/scripts/context/lua/mtx-interface.lua
+++ b/scripts/context/lua/mtx-interface.lua
@@ -234,7 +234,7 @@ function scripts.interface.messages()
end
end
-logs.extendbanner("Interface Tools 0.11",true)
+logs.extendbanner("ConTeXt Interface Related Goodies 0.11",true)
messages.help = [[
--scite generate scite interface
diff --git a/scripts/context/lua/mtx-metatex.lua b/scripts/context/lua/mtx-metatex.lua
index f8c871a7b..4453e2ccb 100644
--- a/scripts/context/lua/mtx-metatex.lua
+++ b/scripts/context/lua/mtx-metatex.lua
@@ -49,7 +49,7 @@ function scripts.metatex.timed(action)
statistics.timed(action)
end
-logs.extendbanner("MetaTeX Tools 0.10",true)
+logs.extendbanner("MetaTeX Process Management 0.10",true)
messages.help = [[
--run process (one or more) files (default action)
diff --git a/scripts/context/lua/mtx-modules.lua b/scripts/context/lua/mtx-modules.lua
index 1a6593004..9ade1fc23 100644
--- a/scripts/context/lua/mtx-modules.lua
+++ b/scripts/context/lua/mtx-modules.lua
@@ -147,7 +147,7 @@ end
-- context --ctx=m-modules.ctx xxx.mkiv
-logs.extendbanner("Module Documentation Tools 1.0",true)
+logs.extendbanner("ConTeXt Module Documentation Generators 1.00",true)
messages.help = [[
--convert convert source files (tex, mkii, mkiv, mp) to 'ted' files
diff --git a/scripts/context/lua/mtx-package.lua b/scripts/context/lua/mtx-package.lua
index 06c89907a..b36fc0ed8 100644
--- a/scripts/context/lua/mtx-package.lua
+++ b/scripts/context/lua/mtx-package.lua
@@ -55,7 +55,7 @@ function scripts.package.merge_luatex_files(name,strip)
end
end
-logs.extendbanner("Package Tools 0.1",true)
+logs.extendbanner("Distribution Related Goodies 0.10",true)
messages.help = [[
--merge merge 'loadmodule' into merge file
diff --git a/scripts/context/lua/mtx-patterns.lua b/scripts/context/lua/mtx-patterns.lua
index 7f130465b..758ea55c9 100644
--- a/scripts/context/lua/mtx-patterns.lua
+++ b/scripts/context/lua/mtx-patterns.lua
@@ -337,7 +337,7 @@ function scripts.patterns.convert()
end
end
-logs.extendbanner("Pattern Tools 0.20",true)
+logs.extendbanner("ConTeXt Pattern File Management 0.20",true)
messages.help = [[
--convert generate context language files (mnemonic driven, if not given then all)
diff --git a/scripts/context/lua/mtx-profile.lua b/scripts/context/lua/mtx-profile.lua
index 1db9682ac..9e2aed288 100644
--- a/scripts/context/lua/mtx-profile.lua
+++ b/scripts/context/lua/mtx-profile.lua
@@ -148,7 +148,7 @@ end
--~ scripts.profiler.analyse("t:/manuals/mk/mk-fonts-profile.lua")
--~ scripts.profiler.analyse("t:/manuals/mk/mk-introduction-profile.lua")
-logs.extendbanner("LuaTeX Profiler 1.00",true)
+logs.extendbanner("ConTeXt MkIV LuaTeX Profiler 1.00",true)
messages.help = [[
--analyse analyse lua calls
diff --git a/scripts/context/lua/mtx-server.lua b/scripts/context/lua/mtx-server.lua
index a1a5d51b3..871354394 100644
--- a/scripts/context/lua/mtx-server.lua
+++ b/scripts/context/lua/mtx-server.lua
@@ -326,7 +326,7 @@ function scripts.webserver.run(configuration)
end
end
-logs.extendbanner("Simple Webserver 0.10")
+logs.extendbanner("Simple Webserver For Helpers 0.10")
messages.help = [[
--start start server
diff --git a/scripts/context/lua/mtx-texworks.lua b/scripts/context/lua/mtx-texworks.lua
index 77d257480..401408b32 100644
--- a/scripts/context/lua/mtx-texworks.lua
+++ b/scripts/context/lua/mtx-texworks.lua
@@ -80,7 +80,7 @@ function scripts.texworks.start(indeed)
end
-logs.extendbanner("TeXworks startup script 1.0",true)
+logs.extendbanner("TeXworks Startup Script 1.00",true)
messages.help = [[
--start [--verbose] start texworks
diff --git a/scripts/context/lua/mtx-timing.lua b/scripts/context/lua/mtx-timing.lua
index 1dcb9aa0e..375d5d90b 100644
--- a/scripts/context/lua/mtx-timing.lua
+++ b/scripts/context/lua/mtx-timing.lua
@@ -186,7 +186,7 @@ function scripts.timings.xhtml(filename)
end
end
-logs.extendbanner("ConTeXt Timing Tools 0.1",true)
+logs.extendbanner("ConTeXt Timing Tools 0.10",true)
messages.help = [[
--xhtml make xhtml file
diff --git a/scripts/context/lua/mtx-tools.lua b/scripts/context/lua/mtx-tools.lua
index 87fd51dc6..ca2faaf29 100644
--- a/scripts/context/lua/mtx-tools.lua
+++ b/scripts/context/lua/mtx-tools.lua
@@ -44,7 +44,7 @@ function scripts.tools.disarmutfbomb()
end
end
-logs.extendbanner("All Kind Of Tools 1.0",true)
+logs.extendbanner("Some File Related Goodies 1.00",true)
messages.help = [[
--disarmutfbomb remove utf bomb if present
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
index 3dd2f0e47..61d6b0d84 100644
--- a/scripts/context/lua/mtx-update.lua
+++ b/scripts/context/lua/mtx-update.lua
@@ -445,7 +445,7 @@ function scripts.update.make()
logs.report("make","done")
end
-logs.extendbanner("Download Tools 0.20",true)
+logs.extendbanner("ConTeXt Minimals Updater 0.21",true)
messages.help = [[
--platform=string platform (windows, linux, linux-64, osx-intel, osx-ppc, linux-ppc)
diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua
index 2e4dcf6ef..44f61ae6b 100644
--- a/scripts/context/lua/mtx-watch.lua
+++ b/scripts/context/lua/mtx-watch.lua
@@ -239,7 +239,7 @@ function scripts.watch.show_logs(path) -- removes duplicates
end
end
-logs.extendbanner("Watchdog 1.00",true)
+logs.extendbanner("ConTeXt Request Watchdog 1.00",true)
messages.help = [[
--logpath optional path for log files
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index a187f0697..ceb9cb886 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -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/lua/mtxrun.rme b/scripts/context/lua/mtxrun.rme
index 9cb56486a..9850e389d 100644
--- a/scripts/context/lua/mtxrun.rme
+++ b/scripts/context/lua/mtxrun.rme
@@ -1,3 +1,18 @@
-On MSWindows the mtxrun.lua script is called
-with mtxrun.cmd. On Unix you can either rename
-mtxrun.lua to mtxrun, or use a symlink.
+On MSWindows the mtxrun.lua script is called with
+mtxrun.exe. On Unix you can either rename mtxrun.lua
+to mtxrun, or use a symlink.
+
+You can create additional stubs, like
+
+copy mtxrun.exe luatools.exe
+copy mtxrun.exe texexec.exe
+copy mtxrun.exe context.exe
+copy mtxrun.exe mtx-server.exe
+
+The mtxrun.exe program is rather dump and only
+intercepts mtxrun, luatools and texmfstart (for
+old times sake) and passes the buck to mtxrun.lua
+which happens to know enough of mkii to deal
+with kpse based lookups and therefore acts like
+texmfstart but when used with mkiv it behaves
+more clever and looks for more.
diff --git a/scripts/context/ruby/newimgtopdf.rb b/scripts/context/ruby/newimgtopdf.rb
deleted file mode 100644
index 563ae5b80..000000000
--- a/scripts/context/ruby/newimgtopdf.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-# program : imgtopdf
-# copyright : PRAGMA Advanced Document Engineering
-# version : 2002-2005
-# author : Hans Hagen
-
-load(File.join(File.expand_path(File.dirname($0)),'imgtopdf.rb'))
diff --git a/scripts/context/ruby/newpstopdf.rb b/scripts/context/ruby/newpstopdf.rb
deleted file mode 100644
index a45b4cab8..000000000
--- a/scripts/context/ruby/newpstopdf.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-# program : pstopdf
-# copyright : PRAGMA Advanced Document Engineering
-# version : 2002-2005
-# author : Hans Hagen
-
-load(File.join(File.expand_path(File.dirname($0)),'pstopdf.rb'))
diff --git a/scripts/context/ruby/newtexexec.rb b/scripts/context/ruby/newtexexec.rb
deleted file mode 100644
index 6b4db52dc..000000000
--- a/scripts/context/ruby/newtexexec.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-# program : texexec
-# copyright : PRAGMA Advanced Document Engineering
-# version : 1997-2006
-# author : Hans Hagen
-
-load(File.join(File.expand_path(File.dirname($0)),'texexec.rb'))
diff --git a/scripts/context/ruby/newtexutil.rb b/scripts/context/ruby/newtexutil.rb
deleted file mode 100644
index d6dd06a71..000000000
--- a/scripts/context/ruby/newtexutil.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-# program : texexec
-# copyright : PRAGMA Advanced Document Engineering
-# version : 1997-2006
-# author : Hans Hagen
-
-load(File.join(File.expand_path(File.dirname($0)),'texutil.rb'))
diff --git a/scripts/context/stubs/mswin/context.cmd b/scripts/context/stubs/mswin/context.cmd
deleted file mode 100644
index 64ac1ea91..000000000
--- a/scripts/context/stubs/mswin/context.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --script context %*
-endlocal
diff --git a/scripts/context/stubs/mswin/context.exe b/scripts/context/stubs/mswin/context.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/context.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/ctxtools.bat b/scripts/context/stubs/mswin/ctxtools.bat
deleted file mode 100755
index 8047c9b68..000000000
--- a/scripts/context/stubs/mswin/ctxtools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute ctxtools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/luatools.cmd b/scripts/context/stubs/mswin/luatools.cmd
deleted file mode 100644
index 4bc998d65..000000000
--- a/scripts/context/stubs/mswin/luatools.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%luatools.lua" %*
-endlocal
diff --git a/scripts/context/stubs/mswin/luatools.exe b/scripts/context/stubs/mswin/luatools.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/luatools.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/luatools.lua b/scripts/context/stubs/mswin/luatools.lua
index 692213b09..6feb7a9c5 100644
--- a/scripts/context/stubs/mswin/luatools.lua
+++ b/scripts/context/stubs/mswin/luatools.lua
@@ -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/mswin/makempy.bat b/scripts/context/stubs/mswin/makempy.bat
deleted file mode 100755
index 03eaa8a28..000000000
--- a/scripts/context/stubs/mswin/makempy.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute makempy.pl %*
-endlocal
diff --git a/scripts/context/stubs/mswin/metatex.cmd b/scripts/context/stubs/mswin/metatex.cmd
deleted file mode 100644
index 858f28f8f..000000000
--- a/scripts/context/stubs/mswin/metatex.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --script metatex %*
-endlocal
diff --git a/scripts/context/stubs/mswin/metatex.exe b/scripts/context/stubs/mswin/metatex.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/metatex.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/mpstools.bat b/scripts/context/stubs/mswin/mpstools.bat
deleted file mode 100755
index 8bd25674c..000000000
--- a/scripts/context/stubs/mswin/mpstools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute mpstools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/mptopdf.bat b/scripts/context/stubs/mswin/mptopdf.bat
deleted file mode 100755
index f29881763..000000000
--- a/scripts/context/stubs/mswin/mptopdf.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute mptopdf.pl %*
-endlocal
diff --git a/scripts/context/stubs/mswin/mtxrun.cmd b/scripts/context/stubs/mswin/mtxrun.cmd
deleted file mode 100644
index f30148ddb..000000000
--- a/scripts/context/stubs/mswin/mtxrun.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" %*
-endlocal
diff --git a/scripts/context/stubs/mswin/mtxrun.dll b/scripts/context/stubs/mswin/mtxrun.dll
new file mode 100644
index 000000000..f8e720f55
--- /dev/null
+++ b/scripts/context/stubs/mswin/mtxrun.dll
Binary files differ
diff --git a/scripts/context/stubs/mswin/mtxrun.exe b/scripts/context/stubs/mswin/mtxrun.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/mtxrun.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index a187f0697..ceb9cb886 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -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/mswin/mtxtools.bat b/scripts/context/stubs/mswin/mtxtools.bat
deleted file mode 100755
index 9554220c4..000000000
--- a/scripts/context/stubs/mswin/mtxtools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute mtxtools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/mtxworks.cmd b/scripts/context/stubs/mswin/mtxworks.cmd
deleted file mode 100644
index 322d9464d..000000000
--- a/scripts/context/stubs/mswin/mtxworks.cmd
+++ /dev/null
@@ -1 +0,0 @@
-mtxrun --script texworks --start
diff --git a/scripts/context/stubs/mswin/mtxworks.exe b/scripts/context/stubs/mswin/mtxworks.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/mtxworks.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/pdftools.bat b/scripts/context/stubs/mswin/pdftools.bat
deleted file mode 100755
index 5e893fb2a..000000000
--- a/scripts/context/stubs/mswin/pdftools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute pdftools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/pstopdf.bat b/scripts/context/stubs/mswin/pstopdf.bat
deleted file mode 100755
index f8d4325f4..000000000
--- a/scripts/context/stubs/mswin/pstopdf.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute pstopdf.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/rlxtools.bat b/scripts/context/stubs/mswin/rlxtools.bat
deleted file mode 100755
index 82f09665a..000000000
--- a/scripts/context/stubs/mswin/rlxtools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute rlxtools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/runtools.bat b/scripts/context/stubs/mswin/runtools.bat
deleted file mode 100755
index f471e747d..000000000
--- a/scripts/context/stubs/mswin/runtools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute runtools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/texexec.bat b/scripts/context/stubs/mswin/texexec.bat
deleted file mode 100755
index acbe41fd8..000000000
--- a/scripts/context/stubs/mswin/texexec.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute texexec.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/texexec.cmd b/scripts/context/stubs/mswin/texexec.cmd
deleted file mode 100644
index acbe41fd8..000000000
--- a/scripts/context/stubs/mswin/texexec.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute texexec.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/texexec.exe b/scripts/context/stubs/mswin/texexec.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/texexec.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/texfont.bat b/scripts/context/stubs/mswin/texfont.bat
deleted file mode 100755
index 98e9f7c76..000000000
--- a/scripts/context/stubs/mswin/texfont.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute texfont.pl %*
-endlocal
diff --git a/scripts/context/stubs/mswin/texmfstart.cmd b/scripts/context/stubs/mswin/texmfstart.cmd
deleted file mode 100644
index 47a10cc54..000000000
--- a/scripts/context/stubs/mswin/texmfstart.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse %*
-endlocal
diff --git a/scripts/context/stubs/mswin/texmfstart.exe b/scripts/context/stubs/mswin/texmfstart.exe
new file mode 100755
index 000000000..968f672b6
--- /dev/null
+++ b/scripts/context/stubs/mswin/texmfstart.exe
Binary files differ
diff --git a/scripts/context/stubs/mswin/textools.bat b/scripts/context/stubs/mswin/textools.bat
deleted file mode 100755
index 3b047ba7d..000000000
--- a/scripts/context/stubs/mswin/textools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute textools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/texutil.bat b/scripts/context/stubs/mswin/texutil.bat
deleted file mode 100755
index f01ced1a3..000000000
--- a/scripts/context/stubs/mswin/texutil.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute texutil.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/tmftools.bat b/scripts/context/stubs/mswin/tmftools.bat
deleted file mode 100755
index 689a93c65..000000000
--- a/scripts/context/stubs/mswin/tmftools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute tmftools.rb %*
-endlocal
diff --git a/scripts/context/stubs/mswin/xmltools.bat b/scripts/context/stubs/mswin/xmltools.bat
deleted file mode 100755
index 572cc9b8b..000000000
--- a/scripts/context/stubs/mswin/xmltools.bat
+++ /dev/null
@@ -1,5 +0,0 @@
-@echo off
-setlocal
-set ownpath=%~dp0%
-texlua "%ownpath%mtxrun.lua" --usekpse --execute xmltools.rb %*
-endlocal
diff --git a/scripts/context/stubs/source/mtxrun_dll.c b/scripts/context/stubs/source/mtxrun_dll.c
new file mode 100644
index 000000000..6cac18c9b
--- /dev/null
+++ b/scripts/context/stubs/source/mtxrun_dll.c
@@ -0,0 +1,214 @@
+/*
+
+Copyright:
+
+The originally 'runscript' program was written by in 2009 by
+T.M.Trzeciak and is public domain. This derived mtxrun program
+is an adapted version by Hans Hagen.
+
+Comment:
+
+In ConTeXt MkIV we have two core scripts: luatools.lua and
+mtxrun.lua where the second one is used to launch other scripts.
+Normally a user will use a call like:
+
+mtxrun --script font --reload
+
+Here mtxrun is a lua script. In order to avoid the usage of a cmd
+file on windows this runner will start texlua directly. In TeXlive
+a runner is added for each cmd file but we don't want that overhead
+(and extra files). By using an exe we can call these scripts in
+batch files without the need for using call.
+
+We also don't want to use other runners, like those that use kpse
+to locate the script as this is exactly what mtxrun itself is doing
+already. Therefore the runscript program is adapted to a more direct
+approach suitable for mtxrun.
+
+Compilation:
+
+with gcc (size optimized):
+
+gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c
+gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun
+
+with tcc (ver. 0.9.24), extra small size
+
+tcc -shared -o runscript.dll runscript_dll.c
+tcc -o runscript.exe runscript_exe.c runscript.def
+
+*/
+
+#include <windows.h>
+#include <stdio.h>
+
+#define IS_WHITESPACE(c) ((c == ' ') || (c == '\t'))
+#define MAX_CMD 32768
+//~ #define DRYRUN
+
+static char dirname [MAX_PATH];
+static char basename[MAX_PATH];
+static char progname[MAX_PATH];
+static char cmdline [MAX_CMD];
+
+__declspec(dllexport) int dllrunscript( int argc, char *argv[] ) {
+
+ int i;
+
+ static char path[MAX_PATH];
+
+ // get file name of this executable and split it into parts
+
+ DWORD nchars = GetModuleFileNameA(NULL, path, MAX_PATH);
+ if ( !nchars || (nchars == MAX_PATH) ) {
+ fprintf(stderr, "mtxrun: unable to determine a valid own name\n");
+ return -1;
+ }
+
+ // file extension part
+
+ i = strlen(path);
+
+ while ( i && (path[i] != '.') && (path[i] != '\\') ) i--;
+
+ strcpy(basename, path);
+
+ if ( basename[i] == '.' ) basename[i] = '\0'; //remove file extension
+
+ // file name part
+
+ while ( i && (path[i] != '\\') ) i--;
+
+ if ( path[i] != '\\' ) {
+ fprintf(stderr, "mtxrun: the runner has no directory part in its name: %s\n", path);
+ return -1;
+ }
+
+ strcpy(dirname, path);
+ dirname[i+1] = '\0'; //remove file name, leave trailing backslash
+ strcpy(progname, &basename[i+1]);
+
+ // find program to execute
+
+ if ( (strlen(basename)+100 >= MAX_PATH) ) {
+ fprintf(stderr, "mtxrun: the runners path is too long: %s\n", path);
+ return -1;
+ }
+
+ // check .lua
+
+ strcpy(path, dirname);
+ strcat(path, "mtxrun.lua");
+
+ if ( GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES ) {
+ goto PROGRAM_FOUND;
+ } else {
+ fprintf(stderr, "mtxrun: the mtxrun.lua file is not in the same path\n");
+ return -1;
+ }
+
+PROGRAM_FOUND:
+
+ strcpy(cmdline,"texlua.exe ");
+
+ if ( ( strcmp(progname,"mtxrun") == 0 ) || ( strcmp(progname,"luatools") == 0 ) ) {
+ strcat(cmdline, dirname);
+ strcat(cmdline,progname);
+ strcat(cmdline, ".lua");
+ } else if ( ( strcmp(progname,"texmfstart") == 0 ) ) {
+ strcat(cmdline, dirname);
+ strcat(cmdline,"mtxrun.lua");
+ } else {
+ strcat(cmdline, dirname);
+ strcat(cmdline, "mtxrun.lua --script ");
+ strcat(cmdline,progname);
+ }
+
+ // get the command line for this process
+
+ char *argstr;
+ argstr = GetCommandLineA();
+ if ( argstr == NULL ) {
+ fprintf(stderr, "mtxrun: fetching the command line string fails\n");
+ return -1;
+ }
+
+ // skip over argv[0] (it can contain embedded double quotes if launched from cmd.exe!)
+
+ int argstrlen = strlen(argstr);
+ int quoted = 0;
+ for ( i = 0; ( i < argstrlen) && ( !IS_WHITESPACE(argstr[i]) || quoted ); i++ )
+
+ if (argstr[i] == '"') quoted = !quoted;
+
+ // while ( IS_WHITESPACE(argstr[i]) ) i++; // arguments leading whitespace
+
+ argstr = &argstr[i];
+
+ if ( strlen(cmdline) + strlen(argstr) >= MAX_CMD ) {
+ fprintf(stderr, "mtxrun: the command line string is too long:\n%s%s\n", cmdline, argstr);
+ return -1;
+ }
+
+ // pass through all the arguments
+
+ strcat(cmdline, argstr);
+
+#ifdef DRYRUN
+ printf("progname : %s\n", progname);
+ printf("dirname : %s\n", dirname);
+ printf("arguments : %s\n", &argstr[-i]);
+ for (i = 0; i < argc; i++) {
+ printf("argv[%d] : %s\n", i, argv[i]);
+ }
+ printf("commandline : %s\n", cmdline);
+ return;
+#endif
+
+ // create child process
+
+ STARTUPINFOA si; // ANSI variant
+ PROCESS_INFORMATION pi;
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ si.dwFlags = STARTF_USESTDHANDLES;// | STARTF_USESHOWWINDOW;
+
+ //si.dwFlags = STARTF_USESHOWWINDOW;
+ //si.wShowWindow = SW_HIDE ; // can be used to hide console window (requires STARTF_USESHOWWINDOW flag)
+
+ si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+ si.hStdError = GetStdHandle(STD_ERROR_HANDLE);
+
+ ZeroMemory( &pi, sizeof(pi) );
+ if( !CreateProcessA(
+ NULL, // module name (uses command line if NULL)
+ cmdline, // command line
+ NULL, // process security attributes
+ NULL, // thread security attributes
+ TRUE, // handle inheritance
+ 0, // creation flags, e.g. CREATE_NEW_CONSOLE, CREATE_NO_WINDOW, DETACHED_PROCESS
+ NULL, // pointer to environment block (uses parent if NULL)
+ NULL, // starting directory (uses parent if NULL)
+ &si, // STARTUPINFO structure
+ &pi ) // PROCESS_INFORMATION structure
+ ) {
+ fprintf(stderr, "mtxrun: unable to create a process for: %s\n", cmdline);
+ return -1;
+ }
+ CloseHandle( pi.hThread ); // thread handle is not needed
+ DWORD ret = 0;
+ if ( WaitForSingleObject( pi.hProcess, INFINITE ) == WAIT_OBJECT_0 ) {
+ if ( !GetExitCodeProcess( pi.hProcess, &ret) ) {
+ fprintf(stderr, "mtxrun: unable to fetch the exit code for process: %s\n", cmdline);
+ return -1;
+ }
+ } else {
+ fprintf(stderr, "mtxrun: the script has been terminated unexpectedly: %s\n", cmdline);
+ return -1;
+ }
+ CloseHandle( pi.hProcess );
+
+ return ret;
+
+}
diff --git a/scripts/context/stubs/source/mtxrun_exe.c b/scripts/context/stubs/source/mtxrun_exe.c
new file mode 100644
index 000000000..ad014455b
--- /dev/null
+++ b/scripts/context/stubs/source/mtxrun_exe.c
@@ -0,0 +1,10 @@
+// This is the .exe part of the mtxrun program, see mtxrun_dll.c
+// for more details.
+
+#include <windows.h>
+
+__declspec(dllimport) int dllrunscript( argc, argv );
+
+int main( int argc, char *argv[] ) {
+ return dllrunscript( argc, argv );
+}
diff --git a/scripts/context/stubs/source/readme.txt b/scripts/context/stubs/source/readme.txt
new file mode 100644
index 000000000..354d85b09
--- /dev/null
+++ b/scripts/context/stubs/source/readme.txt
@@ -0,0 +1,36 @@
+Copyright:
+
+The originally 'runscript' program was written by in 2009 by
+T.M.Trzeciak and is public domain. This derived mtxrun program
+is an adapted version by Hans Hagen.
+
+Comment:
+
+In ConTeXt MkIV we have two core scripts: luatools.lua and
+mtxrun.lua where the second one is used to launch other scripts.
+Normally a user will use a call like:
+
+mtxrun --script font --reload
+
+Here mtxrun is a lua script. In order to avoid the usage of a cmd
+file on windows this runner will start texlua directly. In TeXlive
+a runner is added for each cmd file but we don't want that overhead
+(and extra files). By using an exe we can call these scripts in
+batch files without the need for using call.
+
+We also don't want to use other runners, like those that use kpse
+to locate the script as this is exactly what mtxrun itself is doing
+already. Therefore the runscript program is adapted to a more direct
+approach suitable for mtxrun.
+
+Compilation:
+
+with gcc (size optimized):
+
+gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c
+gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun
+
+with tcc (ver. 0.9.24), extra small size
+
+tcc -shared -o runscript.dll runscript_dll.c
+tcc -o runscript.exe runscript_exe.c runscript.def
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 "$@"