summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-05-06 22:03:57 +0000
committerKarl Berry <karl@freefriends.org>2023-05-06 22:03:57 +0000
commit996ab582db894fb0949df386489a5101ed07062e (patch)
treea124f1b8886ff8c004c9960709f056b3d898aa99 /Master/texmf-dist/scripts/context/lua
parent6a69999bbc827b94cfa79dae2264da0d4b2f0e02 (diff)
luametatex 2.10.08, context 2023.05.05 18:36
git-svn-id: svn://tug.org/texlive/trunk@67034 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/context/lua')
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-context.lua22
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-ctan.lua83
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-fonts.lua11
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-install-tikz.lua162
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-install.lua6
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-pdf.lua109
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtx-update.lua6
-rw-r--r--Master/texmf-dist/scripts/context/lua/mtxrun.lua135
-rw-r--r--Master/texmf-dist/scripts/context/lua/texlua.lua141
9 files changed, 596 insertions, 79 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-context.lua b/Master/texmf-dist/scripts/context/lua/mtx-context.lua
index 014a7d4efe4..a5dfd5a7d79 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-context.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-context.lua
@@ -704,6 +704,8 @@ function scripts.context.run(ctxdata,filename)
--
a_batchmode = (a_batchmode and "batchmode") or (a_nonstopmode and "nonstopmode") or (a_scrollmode and "scrollmode") or nil
--
+ local changed = { }
+ --
for i=1,#filelist do
--
local filename = filelist[i]
@@ -731,6 +733,10 @@ function scripts.context.run(ctxdata,filename)
-- local jobname = removesuffix(filename)
local ctxname = ctxdata and ctxdata.ctxname
--
+ if changed[jobname] == nil then
+ changed[jobname] = false
+ end
+ --
local analysis = preamble_analyze(filename)
--
if a_mkii or analysis.engine == 'pdftex' or analysis.engine == 'xetex' then
@@ -962,6 +968,7 @@ function scripts.context.run(ctxdata,filename)
if not multipass_forcedruns then
newhash = multipass_hashfiles(jobname)
if multipass_changed(oldhash,newhash) then
+ changed[jobname] = true
oldhash = newhash
else
break
@@ -1096,6 +1103,21 @@ function scripts.context.run(ctxdata,filename)
end
end
--
+ if #filelist > 1 then
+ local done = false
+ for k, v in sortedhash(changed) do
+ if v then
+ if not done then
+ report()
+ done = true
+ end
+ report("file %a was changed",k)
+ end
+ end
+ if done then
+ report()
+ end
+ end
end
function scripts.context.pipe() -- still used?
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-ctan.lua b/Master/texmf-dist/scripts/context/lua/mtx-ctan.lua
index 798a2da02f4..6de51caa3ce 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-ctan.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-ctan.lua
@@ -34,9 +34,9 @@ local helpinfo = [[
<flags>
<category name="basic">
<subcategory>
- <flag name="packages"><short>list available packages</short></flag>
- <flag name="topics"><short>list available topics</short></flag>
- <flag name="detail"><short>show details about package</short></flag>
+ <flag name="packages"><short>list available packages [--field=key|name|caption]</short></flag>
+ <flag name="topics"><short>list available topics [--field=key|name|details]</short></flag>
+ <flag name="details"><short>show details about package</short></flag>
<flag name="pattern" value="string"><short>use this pattern, otherwise first argument</short></flag>
</subcategory>
</category>
@@ -71,7 +71,7 @@ local shaped = characters and characters.shaped or lower
-- what is the url to fetch a zip
-- We cannot use the socket library because we don't compile that massive amount of
--- ssl code into lua(meta)tex. aybe some day one fo these small embedded libraries
+-- ssl code into lua(meta)tex. Maybe some day one fo these small embedded libraries
-- makes sense but there are so many changes in all that security stuff that it
-- defeats long term stability of the ecosystem anyway ... just like some of my old
-- devices suddenly are no longer accessible with modern browsers I expect it to
@@ -185,7 +185,7 @@ scripts.ctan.details = json and
-- report("key : %s",data.key or "-")
report("name : %s",data.name or "-")
report("caption : %s",data.caption or "-")
- report("path : %s",data.ctan.path or "-")
+ report("path : %s",data.ctan and data.ctan.path or "-")
report("")
end
end
@@ -207,7 +207,7 @@ or
scripts.ctan.packages = json and
- function(pattern)
+ function(pattern,field)
local data = validdata(fetched("packages"))
if data then
local found = {
@@ -216,9 +216,26 @@ scripts.ctan.packages = json and
}
pattern = checkedpattern(pattern)
for i=1,#data do
- local entry = data[i]
- if strfound(pattern,entry.caption) then
- found[#found+1] = { entry.key, entry.name, entry.caption }
+ local entry = data[i]
+ local key = entry.key
+ local name = entry.name
+ local caption = entry.caption
+ local where
+ if field == "name" then
+ where = name
+ elseif field == "caption" then
+ where = caption
+ elseif field == "key" then
+ where = key
+ end
+ if where then
+ if strfound(pattern,where) then
+ found[#found+1] = { key, name, caption }
+ end
+ else
+ if strfound(pattern,name) or strfound(pattern,caption) then
+ found[#found+1] = { key, name, caption }
+ end
end
end
showresult(found)
@@ -256,9 +273,27 @@ scripts.ctan.topics = json and
}
pattern = checkedpattern(pattern)
for i=1,#data do
- local entry = data[i]
- if strfound(pattern,entry.details) then
- found[#found+1] = { entry.key or entry.name, entry.details } -- inconsistency between json and xml
+ -- inconsistency between json and xml
+ local entry = data[i]
+ local key = entry.key
+ local name = entry.name
+ local details = entry.details
+ local where
+ if field == "name" then
+ where = name or key
+ elseif field == "details" then
+ where = details
+ elseif field == "key" then
+ where = key or name
+ end
+ if where then
+ if strfound(pattern,where) then
+ found[#found+1] = { key or name, details }
+ end
+ else
+ if strfound(pattern,name) or strfound(pattern,details) then
+ found[#found+1] = { key or name, details }
+ end
end
end
showresult(found)
@@ -292,9 +327,20 @@ local function whatever()
report("")
end
+-- scripts.ctan.packages(environment.argument("pattern") or environment.files[1])
+-- scripts.ctan.packages("font")
+-- scripts.ctan.details("tex")
+-- scripts.ctan.details("ipaex")
+
+-- scripts.ctan.packages("Półtawskiego")
+-- scripts.ctan.packages("Poltawskiego")
+
+-- scripts.ctan.topics("font")
+-- scripts.ctan.topics()
+
if environment.argument("packages") then
whatever()
- scripts.ctan.packages(environment.argument("pattern") or environment.files[1])
+ scripts.ctan.packages(environment.argument("pattern") or environment.files[1], environment.argument("field"))
elseif environment.argument("topics") then
whatever()
scripts.ctan.topics(environment.argument("pattern") or environment.files[1])
@@ -306,14 +352,3 @@ elseif environment.argument("exporthelp") then
else
application.help()
end
-
--- scripts.ctan.packages(environment.argument("pattern") or environment.files[1])
--- scripts.ctan.packages("font")
--- scripts.ctan.details("tex")
--- scripts.ctan.details("ipaex")
-
--- scripts.ctan.packages("Półtawskiego")
--- scripts.ctan.packages("Poltawskiego")
-
--- scripts.ctan.topics("font")
--- scripts.ctan.topics()
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua b/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua
index 37107ea1e3f..746a010c8a2 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-fonts.lua
@@ -358,9 +358,14 @@ local function list_specifications(t,info)
fontweight(entry.fontweight),
}
end
- table.insert(s,1,{"familyname","weight","style","width","variant","fontname","filename","subfont","fontweight"})
- table.insert(s,2,{"","","","","","","","",""})
- utilities.formatters.formatcolumns(s)
+ local h = {
+ {"familyname","weight","style","width","variant","fontname","filename","subfont","fontweight"},
+ {"","","","","","","","",""}
+ }
+ utilities.formatters.formatcolumns(s,false,h)
+ for k=1,#h do
+ write_nl(h[k])
+ end
for k=1,#s do
write_nl(s[k])
end
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-install-tikz.lua b/Master/texmf-dist/scripts/context/lua/mtx-install-tikz.lua
new file mode 100644
index 00000000000..74a2922418a
--- /dev/null
+++ b/Master/texmf-dist/scripts/context/lua/mtx-install-tikz.lua
@@ -0,0 +1,162 @@
+if not modules then modules = { } end modules ['mtx-install-tikz'] = {
+ version = 1.234,
+ comment = "companion to mtxrun.lua",
+ author = "Hans Hagen",
+ copyright = "ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Installing tikz is a bit tricky because there are many packages involved and it's
+-- sort of impossible to derive from the names what to include in the installation.
+-- I tried to use the ctan scrips we ship but there is no way to reliably derive a
+-- set from the topics or packages using the web api (there are also some
+-- inconsistencies between the jkson and xml interfaces that will not be fixed). A
+-- wildcard pull of everything tikz/pgf is likely to fail or at least gives files we
+-- don't want and/or need, the solution is to be specific.
+--
+-- We use curl and not the built in socket library because all kind of ssl and
+-- redirection can kick in and who know how it evolves.
+--
+-- We use the context unzipper because we cannot be sure if unzip is present on the
+-- system. In many cases windows, linux and osx installations lack it by default.
+--
+-- This script has no help info etc as it's a rather dumb downloader. One can always
+-- do a better job than this suboptimal quick hack. Let me know if I forget to wipe
+-- something.
+--
+-- mtxrun --script install-tikz
+--
+-- It should be run in the tex root and will quit when there is no texmf-context
+-- path found. The modules path will be created when absent.
+
+local okay, curl = pcall(require,"libs-imp-curl")
+
+local fetched = curl and curl.fetch and function(str)
+ local data, message = curl.fetch {
+ url = str,
+ followlocation = true,
+ sslverifyhost = false,
+ sslverifypeer = false,
+ }
+ if not data then
+ report("some error: %s",message)
+ end
+ return data
+end or function(str)
+ -- So, no redirect to http, which means that we cannot use the built in socket
+ -- library. What if the client is happy with http?
+ local data = os.resultof("curl -sSL " .. str)
+ return data
+end
+
+local ctanurl = "https://mirrors.ctan.org/install"
+local tmpzipfile = "temp.zip"
+local checkdir = "texmf-context"
+local targetdir = "texmf-modules"
+
+local report = logs.reporter("install")
+
+scripts = scripts or { }
+scripts.ctan = scripts.ctan or { }
+
+function scripts.ctan.install(list)
+ if type(list) ~= "table"then
+ report("unknown specification")
+ end
+ local zips = list.zips
+ local wipes = list.wipes
+ if type(zips) ~= "table" or type(wipes) ~= "table" then
+ report("incomplete specification")
+ elseif not lfs.isdir(checkdir) then
+ report("unknown subdirectory %a",checkdir)
+ elseif not dir.mkdirs(targetdir) then
+ report("unable to create %a",targetdir)
+ elseif not lfs.chdir(targetdir) then
+ report("unable to go into %a",targetdir)
+ else
+ report("installing into %a",targetdir)
+ for i=1,#zips do
+ local where = ctanurl .. "/" .. zips[i]
+ local data = fetched(where)
+ if string.find(data,"^PK") then
+ io.savedata(tmpzipfile,data)
+ report("from %a",where)
+ report("into %a",targetdir)
+ utilities.zipfiles.unzipdir {
+ zipname = tmpzipfile,
+ path = ".",
+ verbose = "steps",
+ }
+ os.remove(tmpzipfile)
+ else
+ report("unknown %a",where)
+ end
+ end
+
+ local function wiper(wipes)
+ for i=1,#wipes do
+ local s = wipes[i]
+ if type(s) == "table" then
+ wiper(s)
+ elseif type(s) == "string" then
+ local t = dir.glob(s)
+ report("wiping %i files in %a",#t,s)
+ for i=1,#t do
+ os.remove(t[i])
+ end
+ end
+ end
+ end
+
+ wiper(wipes)
+
+ report("renewing file database")
+ resolvers.renewcache()
+ resolvers.load()
+ end
+end
+
+local function wipers(s)
+ return {
+ "tex/context/third/" ..s.. "/**",
+ "doc/context/third/" ..s.. "/**",
+ "source/context/third/" ..s.. "/**",
+
+ "tex/context/" ..s.. "/**",
+ "doc/context/" ..s.. "/**",
+ "source/context/" ..s.. "/**",
+
+ "scripts/" ..s.. "/**",
+ }
+end
+
+local defaults = {
+ "tex/latex/**",
+ "tex/plain/**",
+
+ "doc/latex/**",
+ "doc/plain/**",
+ "doc/generic/**",
+
+ "source/latex/**",
+ "source/plain/**",
+ "source/generic/**",
+}
+
+local lists = {
+ tikz = {
+ zips = {
+ "graphics/pgf/base/pgf.tds.zip",
+ "graphics/pgf/contrib/pgfplots.tds.zip",
+ "graphics/pgf/contrib/circuitikz.tds.zip",
+ },
+ wipes = {
+ wipers("pgf"),
+ wipers("pgfplots"),
+ wipers("circuitikz"),
+ defaults,
+ }
+ },
+}
+
+scripts.ctan.install(lists.tikz)
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-install.lua b/Master/texmf-dist/scripts/context/lua/mtx-install.lua
index 7efd8f5edee..4b590128245 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-install.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-install.lua
@@ -124,9 +124,9 @@ local platforms = {
--
["linux-armhf"] = "linux-armhf",
--
- ["openbsd"] = "openbsd7.2",
- ["openbsd-i386"] = "openbsd7.2",
- ["openbsd-amd64"] = "openbsd7.2-amd64",
+ ["openbsd"] = "openbsd7.3",
+ ["openbsd-i386"] = "openbsd7.3",
+ ["openbsd-amd64"] = "openbsd7.3-amd64",
--
["freebsd"] = "freebsd",
["freebsd-i386"] = "freebsd",
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua b/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua
index 0ce17ec5b56..05973d2365d 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-pdf.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['mtx-pdf'] = {
local tonumber = tonumber
local format, gmatch, gsub, match, find = string.format, string.gmatch, string.gsub, string.match, string.find
local utfchar = utf.char
-local concat = table.concat
+local concat, insert, swapped = table.concat, table.insert, table.swapped
local setmetatableindex, sortedhash, sortedkeys = table.setmetatableindex, table.sortedhash, table.sortedkeys
local helpinfo = [[
@@ -28,6 +28,7 @@ local helpinfo = [[
<flag name="pretty"><short>replace newlines in metadata</short></flag>
<flag name="fonts"><short>show used fonts (<ref name="detail)"/></short></flag>
<flag name="object"><short>show object"/></short></flag>
+ <flag name="links"><short>show links"/></short></flag>
</subcategory>
<subcategory>
<example><command>mtxrun --script pdf --info foo.pdf</command></example>
@@ -365,6 +366,110 @@ function scripts.pdf.object(filename,n)
end
end
+function scripts.pdf.links(filename,asked)
+ local pdffile = loadpdffile(filename)
+ if pdffile then
+
+ local pages = pdffile.pages
+ local nofpages = pdffile.nofpages
+
+ if asked and (asked < 1 or asked > nofpages) then
+ report("")
+ report("no page %i, last page %i",asked,nofpages)
+ report("")
+ return
+ end
+
+ local reverse = swapped(pages)
+
+ local function show(pagenumber)
+ local page = pages[pagenumber]
+ local annots = page.Annots
+ if annots then
+ report("")
+ report("annotations @ page %i",pagenumber)
+ report("")
+ for i=1,#annots do
+ local annot = annots[i]
+ if annot.Subtype == "Link" then
+ local A = annot.A
+ if A then
+ local S = A.S
+ local D = A.D
+ if S == "GoTo" then
+ if D then
+ local D1 = D[1]
+ local R1 = reverse[D1]
+ if tonumber(R1) then
+ report("intern, page % 4i",R1 or 0)
+ else
+ report("intern, name %s",tostring(D1))
+ end
+ end
+ elseif S == "GoToR" then
+ if D then
+ local F = A.F
+ if F then
+ local D1 = D[1]
+ if tonumber(D1) then
+ report("extern, page % 4i, file %s",D1 + 1,F)
+ else
+ report("extern, page % 4i, file %s, name %s",0,F,D[1])
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+
+ if asked then
+ show(asked)
+ else
+ for pagenumber=1,nofpages do
+ show(pagenumber)
+ end
+ end
+
+ local destinations = pdffile.destinations
+ if destinations then
+ if asked then
+ report("")
+ report("destinations to page %i",asked)
+ report("")
+ for k, v in sortedhash(destinations) do
+ local D = v.D
+ if D then
+ local p = reverse[D[1]] or 0
+ if p == asked then
+ report(k)
+ end
+ end
+ end
+ else
+ report("")
+ report("destinations")
+ report("")
+ local list = setmetatableindex("table")
+ for k, v in sortedhash(destinations) do
+ local D = v.D
+ if D then
+ local p = reverse[D[1]]
+ report("tag %s, page % 4i",k,p)
+ insert(list[p],k)
+ end
+ end
+ for k, v in sortedhash(list) do
+ report("")
+ report("page %i, names % t",k,v)
+ end
+ end
+ end
+ end
+end
+
-- scripts.pdf.info("e:/tmp/oeps.pdf")
-- scripts.pdf.metadata("e:/tmp/oeps.pdf")
-- scripts.pdf.fonts("e:/tmp/oeps.pdf")
@@ -382,6 +487,8 @@ elseif environment.argument("fonts") then
scripts.pdf.fonts(filename)
elseif environment.argument("object") then
scripts.pdf.object(filename,tonumber(environment.argument("object")))
+elseif environment.argument("links") then
+ scripts.pdf.links(filename,tonumber(environment.argument("page")))
elseif environment.argument("exporthelp") then
application.export(environment.argument("exporthelp"),filename)
else
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-update.lua b/Master/texmf-dist/scripts/context/lua/mtx-update.lua
index daf23eb0911..19e3e686581 100644
--- a/Master/texmf-dist/scripts/context/lua/mtx-update.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtx-update.lua
@@ -178,9 +178,9 @@ update.platforms = {
--
["linux-armhf"] = "linux-armhf",
--
- ["openbsd"] = "openbsd7.2",
- ["openbsd-i386"] = "openbsd7.2",
- ["openbsd-amd64"] = "openbsd7.2-amd64",
+ ["openbsd"] = "openbsd7.3",
+ ["openbsd-i386"] = "openbsd7.3",
+ ["openbsd-amd64"] = "openbsd7.3-amd64",
--
["freebsd"] = "freebsd",
["freebsd-i386"] = "freebsd",
diff --git a/Master/texmf-dist/scripts/context/lua/mtxrun.lua b/Master/texmf-dist/scripts/context/lua/mtxrun.lua
index cd83189a40f..f8ef741105e 100644
--- a/Master/texmf-dist/scripts/context/lua/mtxrun.lua
+++ b/Master/texmf-dist/scripts/context/lua/mtxrun.lua
@@ -5136,7 +5136,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 18893, stripped down to: 11170
+-- original size: 19139, stripped down to: 11345
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -5154,7 +5154,7 @@ dir=dir or {}
local dir=dir
local lfs=lfs
local attributes=lfs.attributes
-local walkdir=lfs.dir
+local scandir=lfs.dir
local isdir=lfs.isdir
local isfile=lfs.isfile
local currentdir=lfs.currentdir
@@ -5185,6 +5185,15 @@ else
lfs.isdir=isdir
lfs.isfile=isfile
end
+local isreadable=file.isreadable
+local walkdir=function(p,...)
+ if isreadable(p.."/.") then
+ return scandir(p,...)
+ else
+ return function() end
+ end
+end
+lfs.walkdir=walkdir
function dir.current()
return (gsub(currentdir(),"\\","/"))
end
@@ -8657,7 +8666,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 14071, stripped down to: 10417
+-- original size: 14107, stripped down to: 10453
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -9136,13 +9145,13 @@ if bit32 and not streams.tocardinal1 then
local extract=bit32.extract
local char=string.char
streams.tocardinal1=char
- function streams.tocardinal2(n) return char(extract(8,8),extract(0,8)) end
- function streams.tocardinal3(n) return char(extract(16,8),extract(8,8),extract(0,8)) end
- function streams.tocardinal4(n) return char(extract(24,8),extract(16,8),extract(8,8),extract(0,8)) end
+ function streams.tocardinal2(n) return char(extract(n,8,8),extract(n,0,8)) end
+ function streams.tocardinal3(n) return char(extract(n,16,8),extract(n,8,8),extract(n,0,8)) end
+ function streams.tocardinal4(n) return char(extract(n,24,8),extract(n,16,8),extract(n,8,8),extract(n,0,8)) end
streams.tocardinal1le=char
- function streams.tocardinal2le(n) return char(extract(0,8),extract(8,8)) end
- function streams.tocardinal3le(n) return char(extract(0,8),extract(8,8),extract(16,8)) end
- function streams.tocardinal4le(n) return char(extract(0,8),extract(8,8),extract(16,8),extract(24,8)) end
+ function streams.tocardinal2le(n) return char(extract(n,0,8),extract(n,8,8)) end
+ function streams.tocardinal3le(n) return char(extract(n,0,8),extract(n,8,8),extract(n,16,8)) end
+ function streams.tocardinal4le(n) return char(extract(n,0,8),extract(n,8,8),extract(n,16,8),extract(n,24,8)) end
end
if not streams.readcstring then
local readchar=streams.readchar
@@ -9338,7 +9347,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 25542, stripped down to: 16783
+-- original size: 25716, stripped down to: 16805
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -9546,7 +9555,9 @@ function parsers.groupedsplitat(symbol,withaction)
if not pattern then
local symbols=S(symbol)
local separator=space^0*symbols*space^0
- local value=lbrace*C((nobrace+nestedbraces)^0)*rbrace+C((nestedbraces+(1-(space^0*(symbols+P(-1)))))^0)
+ local value=lbrace*C((nobrace+nestedbraces)^0)
+*(rbrace*(#symbols+P(-1)))
++C((nestedbraces+(1-(space^0*(symbols+P(-1)))))^0)
if withaction then
local withvalue=Carg(1)*value/function(f,s) return f(s) end
pattern=spaces*withvalue*(separator*withvalue)^0
@@ -9940,7 +9951,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fmt"] = package.loaded["util-fmt"] or true
--- original size: 2541, stripped down to: 1624
+-- original size: 3379, stripped down to: 2273
if not modules then modules={} end modules ['util-fmt']={
version=1.001,
@@ -9953,19 +9964,21 @@ utilities=utilities or {}
utilities.formatters=utilities.formatters or {}
local formatters=utilities.formatters
local concat,format=table.concat,string.format
-local tostring,type=tostring,type
+local tostring,type,unpack=tostring,type,unpack
local strip=string.strip
local lpegmatch=lpeg.match
local stripper=lpeg.patterns.stripzeros
function formatters.stripzeros(str)
return lpegmatch(stripper,str)
end
-function formatters.formatcolumns(result,between)
+function formatters.formatcolumns(result,between,header)
if result and #result>0 then
- between=between or " "
- local widths,numbers={},{}
+ local widths={}
+ local numbers={}
+ local templates={}
local first=result[1]
local n=#first
+ between=between or " "
for i=1,n do
widths[i]=0
end
@@ -9987,31 +10000,61 @@ function formatters.formatcolumns(result,between)
end
end
end
+ if header then
+ for i=1,#header do
+ local h=header[i]
+ for j=1,n do
+ local hj=tostring(h[j])
+ h[j]=hj
+ local w=#hj
+ if w>widths[j] then
+ widths[j]=w
+ end
+ end
+ end
+ end
for i=1,n do
local w=widths[i]
if numbers[i] then
if w>80 then
- widths[i]="%s"..between
- else
- widths[i]="%0"..w.."i"..between
+ templates[i]="%s"..between
+ else
+ templates[i]="% "..w.."i"..between
end
else
if w>80 then
- widths[i]="%s"..between
- elseif w>0 then
- widths[i]="%-"..w.."s"..between
+ templates[i]="%s"..between
+ elseif w>0 then
+ templates[i]="%-"..w.."s"..between
else
- widths[i]="%s"
+ templates[i]="%s"
end
end
end
- local template=strip(concat(widths))
+ local template=strip(concat(templates))
for i=1,#result do
local str=format(template,unpack(result[i]))
result[i]=strip(str)
end
+ if header then
+ for i=1,n do
+ local w=widths[i]
+ if w>80 then
+ templates[i]="%s"..between
+ elseif w>0 then
+ templates[i]="%-"..w.."s"..between
+ else
+ templates[i]="%s"
+ end
+ end
+ local template=strip(concat(templates))
+ for i=1,#header do
+ local str=format(template,unpack(header[i]))
+ header[i]=strip(str)
+ end
+ end
end
- return result
+ return result,header
end
@@ -14760,7 +14803,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sbx"] = package.loaded["util-sbx"] or true
--- original size: 21145, stripped down to: 13271
+-- original size: 21146, stripped down to: 13272
if not modules then modules={} end modules ['util-sbx']={
version=1.001,
@@ -15070,7 +15113,7 @@ local runners={
if trace then
report("resultof: %s",command)
end
- local handle=iopopen(command,"r")
+ local handle=iopopen(command,"rb")
if handle then
local result=handle:read("*all") or ""
handle:close()
@@ -16395,7 +16438,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true
--- original size: 62810, stripped down to: 36225
+-- original size: 62221, stripped down to: 36225
if not modules then modules={} end modules ['lxml-tab']={
version=1.001,
@@ -17876,7 +17919,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54733, stripped down to: 31258
+-- original size: 54589, stripped down to: 31258
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -19127,7 +19170,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-mis"] = package.loaded["lxml-mis"] or true
--- original size: 3574, stripped down to: 1808
+-- original size: 3542, stripped down to: 1808
if not modules then modules={} end modules ['lxml-mis']={
version=1.001,
@@ -19196,7 +19239,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true
--- original size: 34661, stripped down to: 21511
+-- original size: 34522, stripped down to: 21511
if not modules then modules={} end modules ['lxml-aux']={
version=1.001,
@@ -21703,7 +21746,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16456, stripped down to: 11636
+-- original size: 16433, stripped down to: 11636
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -22238,7 +22281,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-res"] = package.loaded["data-res"] or true
--- original size: 69576, stripped down to: 44470
+-- original size: 70711, stripped down to: 44839
if not modules then modules={} end modules ['data-res']={
version=1.001,
@@ -22306,13 +22349,15 @@ local criticalvars={
if environment.default_texmfcnf then
resolvers.luacnfspec="home:texmf/web2c;"..environment.default_texmfcnf
else
- resolvers.luacnfspec=concat ({
- "home:texmf/web2c",
- "selfautoparent:/texmf-local/web2c",
- "selfautoparent:/texmf-context/web2c",
- "selfautoparent:/texmf-dist/web2c",
- "selfautoparent:/texmf/web2c",
- },";")
+ local texroot=environment.texroot
+ resolvers.luacnfspec="home:texmf/web2c;selfautoparent:/texmf-local/web2c;selfautoparent:/texmf-context/web2c;selfautoparent:/texmf/web2c"
+ if texroot and isdir(texroot.."/texmf-context") then
+ elseif texroot and isdir(texroot.."/texmf-dist") then
+ resolvers.luacnfspec="home:texmf/web2c;selfautoparent:/texmf-local/web2c;selfautoparent:/texmf-dist/web2c;selfautoparent:/texmf/web2c"
+ elseif ostype~="windows" and isdir("/etc/texmf/web2c") then
+ resolvers.luacnfspec="home:texmf/web2c;/etc/texmf/web2c;selfautodir:/share/texmf/web2c"
+ else
+ end
end
local unset_variable="unset"
local formats=resolvers.formats
@@ -24247,7 +24292,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-con"] = package.loaded["data-con"] or true
--- original size: 5487, stripped down to: 3757
+-- original size: 5477, stripped down to: 3757
if not modules then modules={} end modules ['data-con']={
version=1.100,
@@ -24465,7 +24510,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 10805, stripped down to: 7951
+-- original size: 10789, stripped down to: 7951
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -25806,7 +25851,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true
--- original size: 11691, stripped down to: 8350
+-- original size: 12056, stripped down to: 8398
if not modules then modules={} end modules ['luat-fmt']={
version=1.001,
@@ -26093,8 +26138,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1035743
--- stripped bytes : 408144
+-- original bytes : 1037585
+-- stripped bytes : 408686
-- end library merge
diff --git a/Master/texmf-dist/scripts/context/lua/texlua.lua b/Master/texmf-dist/scripts/context/lua/texlua.lua
new file mode 100644
index 00000000000..5c0524a56e3
--- /dev/null
+++ b/Master/texmf-dist/scripts/context/lua/texlua.lua
@@ -0,0 +1,141 @@
+-- version = 1.000,
+-- comment = "companion to luametatex",
+-- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+-- copyright = "PRAGMA ADE / ConTeXt Development Team",
+-- license = "see context related readme files"
+
+-- If you copy or link 'luametatex' to 'texlua' and put this script in the same path
+-- we have a more pure Lua runner (as with luatex and texlua).
+
+-- todo: error trace
+-- todo: protect these locals
+
+local texlua_load = load
+local texlua_loadfile = loadfile
+local texlua_type = type
+local texlua_xpcall = xpcall
+local texlua_find = string.find
+local texlua_dump = string.dump
+local texlua_open = io.open
+local texlua_print = print
+local texlua_show = luac.print
+
+function texlua_inspect(v)
+ if texlua_type(v) == "function" then
+ local ok, str = texlua_xpcall(texlua_dump,function() end,v)
+ if ok then
+ v = str
+ end
+ end
+ if type(v) == "string" then
+ texlua_show(v,true)
+ else
+ texlua_print(v)
+ end
+end
+
+local function main_execute(str,loader)
+ if str and str ~= "" then
+ local str = loader(str)
+ if texlua_type(str) == "function" then
+ str()
+ end
+ end
+end
+
+local function main_compile(str,loader,out,strip)
+ if str and str ~= "" then
+ local str = loader(str)
+ if texlua_type(str) == "function" then
+ str = texlua_dump(str,strip)
+ if type(out) == "string" and out ~= "" then
+ local f = texlua_open(out,"wb")
+ if f then
+ f:write(str)
+ f:close()
+ end
+ elseif out == true then
+ texlua_inspect(str)
+ else
+ texlua_print(str)
+ end
+ end
+ end
+end
+
+local function main_help()
+ texlua_print("LuaMetaTeX in Lua mode:")
+ texlua_print("")
+ texlua_print("-o 'filename' output filename")
+ texlua_print("-e 'string' execute loaded string")
+ texlua_print("-f 'filename' execute loaded file")
+ texlua_print("-d 'string' dump bytecode of loaded string")
+ texlua_print("-c 'filename' dump bytecode of loaded file")
+ texlua_print("-i 'string' list bytecode of loaded string")
+ texlua_print("-l 'filename' list bytecode of loaded file")
+ texlua_print("-s strip byte code")
+ texlua_print(" 'filename' execute loaded file")
+end
+
+local function main()
+ local i = 1
+ local o = ""
+ local s = false
+ while true do
+ local option = arg[i] or ""
+ if option == "" then
+ if i == 1 then
+ main_help()
+ end
+ break
+ elseif option == "-e" then
+ i = i + 1
+ main_execute(arg[i],texlua_load)
+ o = ""
+ s = false
+ elseif option == "-f" then
+ i = i + 1
+ main_execute(arg[i],texlua_loadfile)
+ o = ""
+ s = false
+ elseif option == "-d" then
+ i = i + 1
+ main_compile(arg[i],texlua_load,o,s)
+ o = ""
+ s = false
+ elseif option == "-c" then
+ i = i + 1
+ main_compile(arg[i],texlua_loadfile,o,s)
+ o = ""
+ s = false
+ elseif option == "-i" then
+ i = i + 1
+ main_compile(arg[i],texlua_load,true)
+ o = ""
+ s = false
+ elseif option == "-l" then
+ i = i + 1
+ main_compile(arg[i],texlua_loadfile,true)
+ o = ""
+ s = false
+ elseif option == "-s" then
+ s = true
+ elseif option == "-o" then
+ i = i + 1
+ o = arg[i] or ""
+ if texlua_find(o,"^%-") then
+ help()
+ break
+ end
+ elseif not texlua_find(option,"^%-") then
+ main_execute(option,texlua_loadfile)
+ break
+ else
+ main_help()
+ break
+ end
+ i = i + 1
+ end
+end
+
+main()