summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2019-04-04 14:11:01 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2019-04-04 14:11:01 +0200
commit64f6e8fc0c6cb9254a6fe3db0b4ab31c51cf8524 (patch)
tree1b36a0b35f5b6d516d27fe817a27249d4c6d9c78 /scripts
parent70a938c4934f042face9805fc4c392c0676b11d5 (diff)
downloadcontext-64f6e8fc0c6cb9254a6fe3db0b4ab31c51cf8524.tar.gz
2019-04-04 13:38:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/context.lua41
-rw-r--r--scripts/context/lua/mtx-bibtex.lua2
-rw-r--r--scripts/context/lua/mtx-context.lua29
-rw-r--r--scripts/context/lua/mtx-dvi.lua4
-rw-r--r--scripts/context/lua/mtx-fcd.lua2
-rw-r--r--scripts/context/lua/mtx-fonts.lua2
-rw-r--r--scripts/context/lua/mtx-grep.lua2
-rw-r--r--scripts/context/lua/mtx-install.lua538
-rw-r--r--scripts/context/lua/mtx-tools.lua5
-rw-r--r--scripts/context/lua/mtxlibs.lua1
-rw-r--r--scripts/context/lua/mtxrun.lua1333
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua1333
-rw-r--r--scripts/context/stubs/unix/mtxrun1333
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua1333
14 files changed, 5000 insertions, 958 deletions
diff --git a/scripts/context/lua/context.lua b/scripts/context/lua/context.lua
new file mode 100644
index 000000000..b44312cfa
--- /dev/null
+++ b/scripts/context/lua/context.lua
@@ -0,0 +1,41 @@
+-- This file is a companion to "context(.exe)" and is effectively the same
+-- as:
+--
+-- mtxrun -script context ...
+--
+-- which will locate "mtx-context.lua" and load that one. The binary is a
+-- copy of "luametatex(.exe)" aka luatex 2.0 for context lmtx. In a similar
+-- fashion "mtxrun(.exe)" will load the "mtrun.lua" script.
+--
+-- The installation of context should do this on Windows:
+--
+-- luametatex.exe -> tex/texmf-win64/bin/luatex.exe
+-- luametatex.exe -> tex/texmf-win64/bin/mtxrun.exe
+-- luametatex.exe -> tex/texmf-win64/bin/context.exe
+-- mtxrun.lua -> tex/texmf-win64/bin/mtxrun.lua
+-- context.lua -> tex/texmf-win64/bin/context.lua
+--
+-- and this on Unix:
+--
+-- luametatex -> tex/texmf-linux-64/bin/luatex
+-- luametatex -> tex/texmf-linux-64/bin/mtxrun
+-- luametatex -> tex/texmf-linux-64/bin/context
+-- mtxrun.lua -> tex/texmf-linux-64/bin/mtxrun.lua
+-- context.lua -> tex/texmf-linux-64/bin/context.lua
+--
+-- The static binary is smaller than 3MB so the few copies provide no real
+-- overhead.
+
+local selfpath = os.selfpath
+
+if not arg or not selfpath then
+ print("invalid stub")
+ os.exit()
+end
+
+arg[0] = "mtxrun"
+
+table.insert(arg,1,"mtx-context")
+table.insert(arg,1,"--script")
+
+dofile(selfpath .. "/" .. "mtxrun.lua")
diff --git a/scripts/context/lua/mtx-bibtex.lua b/scripts/context/lua/mtx-bibtex.lua
index 92036e3a5..d30cc2f6a 100644
--- a/scripts/context/lua/mtx-bibtex.lua
+++ b/scripts/context/lua/mtx-bibtex.lua
@@ -127,7 +127,7 @@ function scripts.bibtex.search(files,pattern,list)
utilities.formatters.formatcolumns(result)
logs.newline()
for i=1,#result do
- texio.write_nl(result[i])
+ logs.writer(result[i])
end
logs.newline()
else
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index c50c4a77a..4466992fd 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -159,7 +159,7 @@ local formatofinterface = {
local defaultformats = {
"cont-en",
- "cont-nl",
+ -- "cont-nl",
}
-- purging files (we should have an mkii and mkiv variants)
@@ -209,7 +209,11 @@ local persistent_runfiles = {
}
local special_runfiles = {
- "%-mpgraph", "%-mprun", "%-temp%-"
+ "%-mpgraph", "%-mprun", "%-temp%-",
+}
+
+local extra_runfiles = {
+ "^l_m_t_x_.-%.pdf$",
}
local function purge_file(dfile,cfile)
@@ -446,8 +450,7 @@ local function pdf_open(name,method)
end
pdfview.open(pdfname)
statistics.stoptiming("pdfview")
- -- report("pdfview overhead after opening: %0.3f seconds",statistics.elapsedtime("pdfview"))
- report("pdfview overhead: %0.3f seconds",statistics.elapsedtime("pdfview"))
+ report("pdfview overhead: %s seconds",statistics.elapsedtime("pdfview"))
end
local function pdf_close(name,method)
@@ -461,7 +464,6 @@ local function pdf_close(name,method)
pdfname = name .. ".pdf" -- agressive
pdfview.close(pdfname)
statistics.stoptiming("pdfview")
- -- report("pdfview overhead after closing: %0.3f seconds",statistics.elapsedtime("pdfview"))
end
-- result file handling
@@ -539,7 +541,7 @@ end
local function luatex_command(l_flags,c_flags,filename,engine)
return format('%s %s %s "%s"',
- engine or "luatex",
+ engine or (status and status.luatex_engine) or "luatex",
flags_to_string(l_flags),
flags_to_string(c_flags,true),
filename
@@ -874,10 +876,12 @@ function scripts.context.run(ctxdata,filename)
--
report("run %s: %s",currentrun,command)
print("") -- cleaner, else continuation on same line
- local returncode, errorstring = os.spawn(command)
+-- local returncode, errorstring = os.spawn(command)
+ local returncode = os.execute(command)
-- todo: remake format when no proper format is found
if not returncode then
- report("fatal error: no return code, message: %s",errorstring or "?")
+-- report("fatal error: no return code, message: %s",errorstring or "?")
+ report("fatal error: no return code")
if resultname then
result_save_error(oldbase,newbase)
end
@@ -1194,7 +1198,7 @@ function scripts.context.make(name)
scripts.context.generate()
end
local list = (name and { name }) or (environment.filenames[1] and environment.filenames) or defaultformats
- local engine = getargument("engine") or "luatex"
+ local engine = getargument("engine") or (status and status.luatex_engine) or "luatex"
if getargument("jit") then
engine = "luajittex"
end
@@ -1203,7 +1207,7 @@ function scripts.context.make(name)
name = formatofinterface[name] or name or ""
if name == "" then
-- nothing
- elseif engine == "luatex" or engine == "luajittex" then
+ elseif engine == "luametatex" or engine == "luatex" or engine == "luajittex" then
make_mkiv_format(name,engine)
elseif engine == "pdftex" or engine == "xetex" then
make_mkii_format(name,engine)
@@ -1362,6 +1366,11 @@ function scripts.context.purge(all,pattern,mkiitoo)
end
end
end
+ for i=1,#extra_runfiles do
+ if find(basename,extra_runfiles[i]) then
+ deleted[#deleted+1] = purge_file(name)
+ end
+ end
end
if #deleted > 0 then
report("purged files: %s", concat(deleted,", "))
diff --git a/scripts/context/lua/mtx-dvi.lua b/scripts/context/lua/mtx-dvi.lua
index 57f146ee6..901b9561f 100644
--- a/scripts/context/lua/mtx-dvi.lua
+++ b/scripts/context/lua/mtx-dvi.lua
@@ -83,7 +83,7 @@ local f_postamble_end = formatters["postamble end offset=%s version=%s"]
local f_define_font = formatters["define font k=%i checksum=%i scale=%p designsize=%p area=%s name=%s"]
local currentdepth = 0
-local usedprinter = texio and texio.write_ln or print
+local usedprinter = (logs and logs.writer) or (texio and texio.write_nl) or print
local handler = { } for i=0,255 do handler[i] = false end
@@ -379,7 +379,7 @@ function scripts.dvi.list(filename,printer)
local position = 0
f:seek("set",position)
local format = formatters["%0" .. #tostring(filesize) .. "i : %s"]
- local flush = printer or (texio and texio.write_ln) or print
+ local flush = printer or usedprinter
usedprinter = function(str)
flush(format(position,str))
position = f:seek()
diff --git a/scripts/context/lua/mtx-fcd.lua b/scripts/context/lua/mtx-fcd.lua
index 76087cc37..87b06dff0 100644
--- a/scripts/context/lua/mtx-fcd.lua
+++ b/scripts/context/lua/mtx-fcd.lua
@@ -66,7 +66,7 @@ local application = logs.application {
}
local report = application.report
-local writeln = print -- texio.write_nl
+local writeln = (logs and logs.writer) or (texio and texio.write_nl) or print
local find, char, byte, lower, gsub, format = string.find, string.char, string.byte, string.lower, string.gsub, string.format
diff --git a/scripts/context/lua/mtx-fonts.lua b/scripts/context/lua/mtx-fonts.lua
index 5fab67082..2e50543c3 100644
--- a/scripts/context/lua/mtx-fonts.lua
+++ b/scripts/context/lua/mtx-fonts.lua
@@ -14,7 +14,7 @@ local suffix, addsuffix, removesuffix, replacesuffix = file.suffix, file.addsuff
local nameonly, basename, joinpath, collapsepath = file.nameonly, file.basename, file.join, file.collapsepath
local lower = string.lower
local concat = table.concat
-local write_nl = texio.write_nl
+local write_nl = (logs and logs.writer) or (texio and texio.write_nl) or print
local otlversion = 3.106
diff --git a/scripts/context/lua/mtx-grep.lua b/scripts/context/lua/mtx-grep.lua
index 0c4364630..9a4237737 100644
--- a/scripts/context/lua/mtx-grep.lua
+++ b/scripts/context/lua/mtx-grep.lua
@@ -69,7 +69,7 @@ local crlf = cr * lf
local newline = crlf + cr + lf
local content = lpeg.C((1-newline)^0) * newline + lpeg.C(lpeg.P(1)^1)
-local write_nl = texio.write_nl
+local write_nl = (logs and logs.writer) or (texio and texio.write_nl) or print
-- local pattern = "LIJST[@TYPE='BULLET']/LIJSTITEM[contains(text(),'Kern')]"
diff --git a/scripts/context/lua/mtx-install.lua b/scripts/context/lua/mtx-install.lua
new file mode 100644
index 000000000..66f1556c9
--- /dev/null
+++ b/scripts/context/lua/mtx-install.lua
@@ -0,0 +1,538 @@
+if not modules then modules = { } end modules ['mtx-install'] = {
+ version = 1.002,
+ comment = "companion to mtxrun.lua",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- todo: initial install from zip
+
+local helpinfo = [[
+<?xml version="1.0"?>
+<application>
+ <metadata>
+ <entry name="name">mtx-install</entry>
+ <entry name="detail">ConTeXt Installer</entry>
+ <entry name="version">2.00</entry>
+ </metadata>
+ <flags>
+ <category name="basic">
+ <subcategory>
+ <flag name="platform" value="string"><short>platform (windows, linux, linux-64, osx-intel, osx-ppc, linux-ppc)</short></flag>
+ <flag name="server" value="string"><short>repository url (rsync://contextgarden.net)</short></flag>
+ <flag name="modules" value="string"><short>extra modules (can be list or 'all')</short></flag>
+ <flag name="fonts" value="string"><short>additional fonts (can be list or 'all')</short></flag>
+ <flag name="goodies" value="string"><short>extra binaries (like scite and texworks)</short></flag>
+ <flag name="install"><short>install context</short></flag>
+ <flag name="update"><short>update context</short></flag>
+ <flag name="identify"><short>create list of files</short></flag>
+ </subcategory>
+ </category>
+ </flags>
+</application>
+]]
+
+local gsub, find, escapedpattern = string.gsub, string.find, string.escapedpattern
+local round = math.round
+local savetable, loadtable, sortedhash = table.save, table.load, table.sortedhash
+local copyfile, joinfile, filesize, dirname, addsuffix, basename = file.copy, file.join, file.size, file.dirname, file.addsuffix, file.basename
+local isdir, isfile, walkdir, pushdir, popdir, currentdir = lfs.isdir, lfs.isfile, lfs.dir, lfs.chdir, dir.push, dir.pop, currentdir
+local mkdirs, globdir = dir.mkdirs, dir.glob
+local osremove, osexecute, ostype = os.remove, os.execute, os.type
+local savedata = io.savedata
+local formatters = string.formatters
+
+local fetch = socket.http.request
+
+local application = logs.application {
+ name = "mtx-install",
+ banner = "ConTeXt Installer 2.00",
+ helpinfo = helpinfo,
+}
+
+local report = application.report
+
+scripts = scripts or { }
+scripts.install = scripts.install or { }
+local install = scripts.install
+
+local texformats = {
+ "cont-en",
+ "cont-nl",
+ "cont-cz",
+ "cont-de",
+ "cont-fa",
+ "cont-it",
+ "cont-ro",
+ "cont-uk",
+ "cont-pe",
+}
+
+local platforms = {
+ ["mswin"] = "mswin",
+ ["windows"] = "mswin",
+ ["win32"] = "mswin",
+ ["win"] = "mswin",
+ --
+ ["mswin-64"] = "win64",
+ ["windows-64"] = "win64",
+ ["win64"] = "win64",
+ --
+ ["linux"] = "linux",
+ ["linux-32"] = "linux",
+ ["linux32"] = "linux",
+ --
+ ["linux-64"] = "linux-64",
+ ["linux64"] = "linux-64",
+ --
+ ["linuxmusl-64"] = "linuxmusl-64",
+ --
+ ["linux-armhf"] = "linux-armhf",
+ --
+ ["freebsd"] = "freebsd",
+ --
+ ["freebsd-amd64"] = "freebsd-amd64",
+ --
+ ["kfreebsd"] = "kfreebsd-i386",
+ ["kfreebsd-i386"] = "kfreebsd-i386",
+ --
+ ["kfreebsd-amd64"] = "kfreebsd-amd64",
+ --
+ ["linux-ppc"] = "linux-ppc",
+ ["ppc"] = "linux-ppc",
+ --
+ ["osx"] = "osx-intel",
+ ["macosx"] = "osx-intel",
+ ["osx-intel"] = "osx-intel",
+ ["osxintel"] = "osx-intel",
+ --
+ ["osx-ppc"] = "osx-ppc",
+ ["osx-powerpc"] = "osx-ppc",
+ ["osxppc"] = "osx-ppc",
+ ["osxpowerpc"] = "osx-ppc",
+ --
+ ["osx-64"] = "osx-64",
+ --
+ ["solaris-intel"] = "solaris-intel",
+ --
+ ["solaris-sparc"] = "solaris-sparc",
+ ["solaris"] = "solaris-sparc",
+ --
+ ["unknown"] = "unknown",
+}
+
+function install.identify()
+
+ -- We have to be in "...../tex" where subdirectories are prefixed with
+ -- "texmf". We strip the "tex/texm*/" from the name in the list.
+
+ local function collect(root,tree)
+
+ local path = root .. "/" .. tree
+
+ if isdir(path) then
+
+ local prefix = path .. "/"
+ local files = globdir(prefix .. "**")
+ local pattern = escapedpattern("^" .. prefix)
+
+ local details = { }
+ local total = 0
+
+ for i=1,#files do
+ local name = files[i]
+ local size = filesize(name)
+ local base = gsub(name,pattern,"")
+ local stamp = md5.hex(io.loaddata(name))
+ details[i] = { base, size, stamp }
+ total = total + size
+ end
+ report("%-20s : %4i files, %3.0f MB",tree,#files,total/(1000*1000))
+
+ savetable(path .. ".tma",details)
+
+ end
+
+ end
+
+ local sourceroot = file.join(dir.current(),"tex")
+
+ for d in walkdir("./tex") do
+ if find(d,"%texmf") then
+ collect(sourceroot,d)
+ end
+ end
+
+ savetable("./tex/status.tma",{
+ name = "context",
+ version = "lmtx",
+ date = os.date("%Y-%m-%d"),
+ })
+
+end
+
+function install.update()
+
+ local function validdir(d)
+ local ok = isdir(d)
+ if not ok then
+ mkdirs(d)
+ ok = isdir(d)
+ end
+ return ok
+ end
+
+ local function download(what,url,target,total,done)
+ local data = fetch(url .. "/" .. target)
+ if data then
+ if total and done then
+ report("%-8s : %3i %% : %8i : %s",what,round(100*done/total),#data,target)
+ else
+ report("%-8s : %8i : %s",what,#data,target)
+ end
+ if validdir(dirname(target)) then
+ savedata(target,data)
+ else
+ -- message
+ end
+ end
+ end
+
+ local function remove(what,target)
+ report("%-8s : %8i : %s",what,filesize(target),target)
+ osremove(target)
+ end
+
+ local function ispresent(target)
+ return isfile(target)
+ end
+
+ local function hashed(list)
+ local hash = { }
+ for i=1,#list do
+ local l = list[i]
+ hash[l[1]] = l
+ end
+ return hash
+ end
+
+ local function run(fmt,...)
+ local command = formatters[fmt](...)
+ -- command = gsub(command,"/","\\")
+ report("running: %s",command)
+ osexecute(command)
+ end
+
+ local function prepare(tree)
+ tree = joinfile("tex",tree)
+ mkdirs(tree)
+ end
+
+ local function update(url,what,zipfile,skiplist)
+
+ local tree = joinfile("tex",what)
+
+ local ok = validdir(tree)
+ if not validdir(tree) then
+ report("invalid directory %a",tree)
+ return
+ end
+
+ local lua = tree .. ".tma"
+ local all = url .. "/" .. lua
+ local old = loadtable(lua)
+ local new = fetch(all)
+
+ if new then
+ new = loadstring(new)
+ if new then
+ new = new()
+ end
+ end
+
+ if not new then
+ report("invalid database %a",all)
+ return
+ end
+
+ local total = 0
+ local done = 0
+ local count = 0
+
+ if not old then
+
+ if zipfile then
+ zipfile = addsuffix(what,"zip")
+ end
+ if zipfile then
+ local zipurl = url .. "/" .. zipfile
+ report("fetching %a",zipurl)
+ local zipdata = fetch(zipurl)
+ if zipdata then
+ io.savedata(zipfile,zipdata)
+ else
+ zipfile = false
+ end
+ end
+
+ if type(zipfile) == "string" and isfile(zipfile) then
+
+ -- todo: pcall
+
+ report("unzipping %a",zipfile)
+
+ local specification = {
+ zipname = zipfile,
+ path = ".",
+ -- verbose = true,
+ verbose = "steps",
+ }
+
+ if utilities.zipfiles.unzipdir(specification) then
+ osremove(zipfile)
+ goto done
+ else
+ osremove(zipfile)
+ end
+
+ end
+
+ count = #new
+
+ report("installing %s, %i files",tree,count)
+
+ for i=1,count do
+ total = total + new[i][2]
+ end
+
+ for i=1,count do
+ local entry = new[i]
+ local name = entry[1]
+ local size = entry[2]
+ local target = joinfile(tree,name)
+ done = done + size
+ if not skiplist or not skiplist[basename(name)] then
+ download("new",url,target,total,done)
+ else
+ report("skipping %s",target)
+ end
+ end
+
+ ::done::
+
+ else
+
+ report("updating %s, %i files",tree,#new)
+
+ local hold = hashed(old)
+ local hnew = hashed(new)
+ local todo = { }
+
+ for newname, newhash in sortedhash(hnew) do
+ local target = joinfile(tree,newname)
+ if not skiplist or not skiplist[basename(newname)] then
+ local oldhash = hold[newname]
+ local action = nil
+ if not oldhash then
+ action = "added"
+ elseif oldhash[3] ~= newhash[3] then
+ action = "changed"
+ elseif not ispresent(joinfile(tree,newname)) then
+ action = "missing"
+ end
+ if action then
+ local size = newhash[2]
+ total = total + size
+ todo[#todo+1] = { action, target, size }
+ end
+ else
+ report("skipping %s",target)
+ end
+ end
+
+ count = #todo
+
+ for i=1,count do
+ local entry = todo[i]
+ download(entry[1],url,entry[2],total,done)
+ done = done + entry[3]
+ end
+
+ for oldname, oldhash in sortedhash(hold) do
+ local newhash = hnew[oldname]
+ local target = joinfile(tree,oldname)
+ if not newhash and ispresent(target) then
+ remove("removed",target)
+ end
+ end
+
+ end
+
+ savetable(lua,new)
+
+ return { tree, count, done }
+
+ end
+
+ local targetroot = dir.current()
+
+ local server = environment.arguments.server or ""
+ local instance = environment.arguments.instance or ""
+ local osplatform = os.platform
+ local platform = platforms[osplatform]
+
+ if server == "" then
+ server = "lmtx.contextgarden.net,lmtx.pragma-ade.com,lmtx.pragma-ade.nl,dmz.pragma-ade.nl"
+ end
+ if instance == "" then
+ instance = "install-lmtx"
+ end
+ if not platform then
+ report("unknown platform")
+ return
+ end
+
+ local list = utilities.parsers.settings_to_array(server)
+ local server = false
+
+ for i=1,#list do
+ local host = list[i]
+ local data, status, detail = fetch("http://" .. host .. "/" .. instance .. "/tex/status.tma")
+ if status == 200 and type(data) == "string" then
+ local t = loadstring(data)
+ if type(t) == "function" then
+ t = t()
+ end
+ if type(t) == "table" and t.name == "context" and t.version == "lmtx" then
+ server = host
+ break
+ end
+ end
+ end
+
+ if not server then
+ report("provide valid server and instance")
+ return
+ end
+
+ local url = "http://" .. server .. "/" .. instance .. "/"
+
+ local texmfplatform = "texmf-" .. platform
+
+ report("server : %s",server)
+ report("instance : %s",instance)
+ report("platform : %s",osplatform)
+ report("system : %s",ostype)
+
+ local status = { }
+ local skiplist = {
+ ["mtxrun"] = true,
+ ["context"] = true,
+ ["mtxrun.exe"] = true,
+ ["context.exe"] = true,
+ }
+
+ status[#status+1] = update(url,"texmf",true)
+ status[#status+1] = update(url,"texmf-context",true)
+ status[#status+1] = update(url,texmfplatform,false,skiplist)
+
+ prepare("texmf-cache")
+ prepare("texmf-project")
+ prepare("texmf-fonts")
+ prepare("texmf-local")
+ prepare("texmf-modules")
+
+ local binpath = joinfile(targetroot,"tex",texmfplatform,"bin")
+
+ local luametatex = "luametatex"
+ local mtxrun = "mtxrun"
+ local context = "context"
+
+ if ostype == "windows" then
+ luametatex = addsuffix(luametatex,"exe")
+ mtxrun = addsuffix(mtxrun,"exe")
+ context = addsuffix(context,"exe")
+ end
+
+ local luametatexbin = joinfile(binpath,luametatex)
+ local mtxrunbin = joinfile(binpath,mtxrun)
+ local contextbin = joinfile(binpath,context)
+
+ local cdir = currentdir()
+ local pdir = pushdir(binpath)
+
+ report("current : %S",cdir)
+ report("target : %S",pdir)
+
+ if pdir ~= cdir then
+
+ report("removing : %s",mtxrun)
+ report("removing : %s",context)
+
+ osremove(mtxrun)
+ osremove(context)
+
+ if isfile(luametatex) then
+ lfs.symlink(luametatex,mtxrun)
+ lfs.symlink(luametatex,context)
+ end
+
+ if isfile(mtxrun) then
+ report("linked : %s",mtxrun)
+ else
+ copyfile(luametatex,mtxrun)
+ report("copied : %s",mtxrun)
+ end
+ if isfile(context) then
+ report("linked : %s",context)
+ else
+ copyfile(luametatex,context)
+ report("copied : %s",context)
+ end
+
+ end
+
+ popdir()
+
+ if lfs.setexecutable(luametatexbin) then
+ report("xbit set : %s",luametatexbin)
+ else
+ -- report("xbit bad : %s",luametatexbin)
+ end
+ if lfs.setexecutable(mtxrunbin) then
+ report("xbit set : %s",mtxrunbin)
+ else
+ -- report("xbit bad : %s",mtxrunbin)
+ end
+ if lfs.setexecutable(contextbin) then
+ report("xbit set : %s",contextbin)
+ else
+ -- report("xbit bad : %s",contextbin)
+ end
+
+ run("%s --generate",mtxrunbin)
+ run("%s --make en", contextbin)
+
+ -- in calling script: update mtxrun.exe and mtxrun.lua
+
+ report("")
+ for i=1,#status do
+ report("%-20s : %4i files with %9i bytes installed",unpack(status[i]))
+ end
+ report("")
+
+ report("update, done")
+end
+
+if environment.argument("identify") then
+ install.identify()
+elseif environment.argument("install") then
+ install.update()
+elseif environment.argument("update") then
+ install.update()
+elseif environment.argument("exporthelp") then
+ application.export(environment.argument("exporthelp"),environment.files[1])
+else
+ application.help()
+end
diff --git a/scripts/context/lua/mtx-tools.lua b/scripts/context/lua/mtx-tools.lua
index 146c46f36..be2177111 100644
--- a/scripts/context/lua/mtx-tools.lua
+++ b/scripts/context/lua/mtx-tools.lua
@@ -53,7 +53,8 @@ local application = logs.application {
helpinfo = helpinfo,
}
-local report = application.report
+local report = application.report
+local writeln = (logs and logs.writer) or (texio and texio.write_nl) or print
scripts = scripts or { }
scripts.tools = scripts.tools or { }
@@ -189,7 +190,7 @@ function scripts.tools.dirtoxml()
result = table.concat(result,"\n")
if not outputfile or outputfile == "" then
- texio.write_nl(result)
+ writeln(result)
else
io.savedata(outputfile,result)
end
diff --git a/scripts/context/lua/mtxlibs.lua b/scripts/context/lua/mtxlibs.lua
index 9c8cd28ca..94dc658f3 100644
--- a/scripts/context/lua/mtxlibs.lua
+++ b/scripts/context/lua/mtxlibs.lua
@@ -67,6 +67,7 @@ local owntree = ownpath
local ownlibs = {
+ "l-bit32.lua",
"l-lua.lua",
"l-macro.lua",
"l-sandbox.lua",
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 611f7c8dd..a79ffc029 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -61,9 +61,140 @@ if not modules then modules = { } end modules ['mtxrun'] = {
do -- create closure to overcome 200 locals limit
+package.loaded["l-bit32"] = package.loaded["l-bit32"] or true
+
+-- original size: 3607, stripped down to: 3009
+
+if not modules then modules={} end modules ['l-bit32']={
+ version=1.001,
+ license="the same as regular Lua",
+ source="bitwise.lua, v 1.24 2014/12/26 17:20:53 roberto",
+ comment="drop-in for bit32, adapted a bit by Hans Hagen",
+}
+if bit32 then
+elseif utf8 then
+ load ([[
+local select = select -- instead of: arg = { ... }
+bit32 = {
+ bnot = function (a)
+ return ~a & 0xFFFFFFFF
+ end,
+ band = function (x, y, z, ...)
+ if not z then
+ return ((x or -1) & (y or -1)) & 0xFFFFFFFF
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) | (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x | y | z
+ for i=1,select("#",...) do
+ res = res | select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bxor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x ~ y ~ z
+ for i=1,select("#",...) do
+ res = res ~ select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ btest = function (x, y, z, ...)
+ if not z then
+ return (((x or -1) & (y or -1)) & 0xFFFFFFFF) ~= 0
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return (res & 0xFFFFFFFF) ~= 0
+ end
+ end,
+ lshift = function (a, b)
+ return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF
+ end,
+ rshift = function (a, b)
+ return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF
+ end,
+ arshift = function (a, b)
+ a = a & 0xFFFFFFFF
+ if b <= 0 or (a & 0x80000000) == 0 then
+ return (a >> b) & 0xFFFFFFFF
+ else
+ return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF
+ end
+ end,
+ lrotate = function (a ,b)
+ b = b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ rrotate = function (a, b)
+ b = -b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ extract = function (a, f, w)
+ return (a >> f) & ~(-1 << (w or 1))
+ end,
+ replace = function (a, v, f, w)
+ local mask = ~(-1 << (w or 1))
+ return ((a & ~(mask << f)) | ((v & mask) << f)) & 0xFFFFFFFF
+ end,
+}
+ ]] ) ()
+elseif bit then
+ load ([[
+local band, bnot, rshift, lshift = bit.band, bit.bnot, bit.rshift, bit.lshift
+bit32 = {
+ arshift = bit.arshift,
+ band = band,
+ bnot = bnot,
+ bor = bit.bor,
+ bxor = bit.bxor,
+ btest = function(...)
+ return band(...) ~= 0
+ end,
+ extract = function(a,f,w)
+ return band(rshift(a,f),2^(w or 1)-1)
+ end,
+ lrotate = bit.rol,
+ lshift = lshift,
+ replace = function(a,v,f,w)
+ local mask = 2^(w or 1)-1
+ return band(a,bnot(lshift(mask,f)))+lshift(band(v,mask),f)
+ end,
+ rrotate = bit.ror,
+ rshift = rshift,
+}
+ ]] ) ()
+else
+ xpcall(function() local _,t=require("bit32") if t then bit32=t end return end,function() end)
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 6204, stripped down to: 2852
+-- original size: 6330, stripped down to: 2831
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -180,8 +311,7 @@ if not FFISUPPORTED then
elseif not ffi.number then
ffi.number=tonumber
end
-if not bit32 then
- bit32=require("l-bit32")
+if LUAVERSION>5.3 then
end
@@ -1962,7 +2092,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40960, stripped down to: 21348
+-- original size: 41332, stripped down to: 21508
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1973,7 +2103,7 @@ if not modules then modules={} end modules ['l-table']={
}
local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select
local table,string=table,string
-local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
+local concat,sort=table.concat,table.sort
local format,lower,dump=string.format,string.lower,string.dump
local getmetatable,setmetatable=getmetatable,setmetatable
local lpegmatch,patterns=lpeg.match,lpeg.patterns
@@ -1983,7 +2113,8 @@ function table.getn(t)
return t and #t
end
function table.strip(tab)
- local lst,l={},0
+ local lst={}
+ local l=0
for i=1,#tab do
local s=lpegmatch(stripper,tab[i]) or ""
if s=="" then
@@ -1996,7 +2127,8 @@ function table.strip(tab)
end
function table.keys(t)
if t then
- local keys,k={},0
+ local keys={}
+ local k=0
for key in next,t do
k=k+1
keys[k]=key
@@ -2027,27 +2159,30 @@ local function compare(a,b)
end
local function sortedkeys(tab)
if tab then
- local srt,category,s={},0,0
+ local srt={}
+ local category=0
+ local s=0
for key in next,tab do
s=s+1
srt[s]=key
- if category==3 then
- elseif category==1 then
- if type(key)~="string" then
- category=3
- end
- elseif category==2 then
- if type(key)~="number" then
- category=3
- end
- else
+ if category~=3 then
local tkey=type(key)
- if tkey=="string" then
- category=1
- elseif tkey=="number" then
- category=2
+ if category==1 then
+ if tkey~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if tkey~="number" then
+ category=3
+ end
else
- category=3
+ if tkey=="string" then
+ category=1
+ elseif tkey=="number" then
+ category=2
+ else
+ category=3
+ end
end
end
end
@@ -2064,7 +2199,8 @@ local function sortedkeys(tab)
end
local function sortedhashonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="string" then
s=s+1
@@ -2081,7 +2217,8 @@ local function sortedhashonly(tab)
end
local function sortedindexonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="number" then
s=s+1
@@ -2098,7 +2235,8 @@ local function sortedindexonly(tab)
end
local function sortedhashkeys(tab,cmp)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if key then
s=s+1
@@ -2174,7 +2312,9 @@ function table.prepend(t,list)
return t
end
function table.merge(t,...)
- t=t or {}
+ if not t then
+ t={}
+ end
for i=1,select("#",...) do
for k,v in next,(select(i,...)) do
t[k]=v
@@ -2203,7 +2343,8 @@ function table.imerge(t,...)
return t
end
function table.imerged(...)
- local tmp,ntmp={},0
+ local tmp={}
+ local ntmp=0
for i=1,select("#",...) do
local nst=select(i,...)
for j=1,#nst do
@@ -2235,7 +2376,9 @@ local function fastcopy(old,metatabletoo)
end
end
local function copy(t,tables)
- tables=tables or {}
+ if not tables then
+ tables={}
+ end
local tcopy={}
if not tables[t] then
tables[t]=tcopy
@@ -2282,7 +2425,8 @@ function table.tohash(t,value)
return h
end
function table.fromhash(t)
- local hsh,h={},0
+ local hsh={}
+ local h=0
for k,v in next,t do
if v then
h=h+1
@@ -2383,7 +2527,8 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
if root and next(root)~=nil then
- local first,last=nil,0
+ local first=nil
+ local last=0
if compact then
last=#root
for k=1,last do
@@ -2642,7 +2787,8 @@ local function serialize(_handle,root,name,specification)
handle("}")
end
function table.serialize(root,name,specification)
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
@@ -2656,13 +2802,15 @@ function table.tofile(filename,root,name,specification)
local f=io.open(filename,'w')
if f then
if maxtab>1 then
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
if n>maxtab then
f:write(concat(t,"\n"),"\n")
- t,n={},0
+ t={}
+ n=0
end
end
serialize(flush,root,name,specification)
@@ -2764,8 +2912,12 @@ local function are_equal(a,b,n,m)
if a==b then
return true
elseif a and b and #a==#b then
- n=n or 1
- m=m or #a
+ if not n then
+ n=1
+ end
+ if not m then
+ m=#a
+ end
for i=n,m do
local ai,bi=a[i],b[i]
if ai==bi then
@@ -2865,7 +3017,8 @@ function table.mirrored(t)
end
function table.reversed(t)
if t then
- local tt,tn={},#t
+ local tt={}
+ local tn=#t
if tn>0 then
local ttn=0
for i=tn,1,-1 do
@@ -2978,7 +3131,9 @@ function table.sorted(t,...)
end
function table.values(t,s)
if t then
- local values,keys,v={},{},0
+ local values={}
+ local keys={}
+ local v=0
for key,value in next,t do
if not keys[value] then
v=v+1
@@ -3610,7 +3765,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 19347, stripped down to: 10258
+-- original size: 18985, stripped down to: 10149
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -3775,17 +3930,8 @@ local launchers={
unix="xdg-open %s &> /dev/null &",
}
function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
-end
-if not os.times then
- function os.times()
- return {
- utime=os.gettimeofday(),
- stime=0,
- cutime=0,
- cstime=0,
- }
- end
+ local command=format(launchers[os.name] or launchers.unix,str)
+ execute(command)
end
local gettimeofday=os.gettimeofday or os.clock
os.gettimeofday=gettimeofday
@@ -4062,7 +4208,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-file"] = package.loaded["l-file"] or true
--- original size: 21804, stripped down to: 9980
+-- original size: 21984, stripped down to: 10148
if not modules then modules={} end modules ['l-file']={
version=1.001,
@@ -4242,40 +4388,45 @@ local reslasher=lpeg.replacer(P("\\"),"/")
function file.reslash(str)
return str and lpegmatch(reslasher,str)
end
-function file.is_writable(name)
- if not name then
- elseif lfs.isdir(name) then
- name=name.."/m_t_x_t_e_s_t.tmp"
- local f=io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f=io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f=io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+ file.is_readable=lfs.isreadablefile
+ file.is_writable=lfs.iswritablefile
+else
+ function file.is_writable(name)
+ if not name then
+ elseif lfs.isdir(name) then
+ name=name.."/m_t_x_t_e_s_t.tmp"
+ local f=io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
- end
- return false
-end
-local readable=P("r")*Cc(true)
-function file.is_readable(name)
- if name then
- local a=attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
return false
end
+ local readable=P("r")*Cc(true)
+ function file.is_readable(name)
+ if name then
+ local a=attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
+ end
end
file.isreadable=file.is_readable
file.iswritable=file.is_writable
@@ -4906,7 +5057,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 18002, stripped down to: 10681
+-- original size: 18253, stripped down to: 10816
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -4971,13 +5122,15 @@ local function glob_pattern_function(path,patt,recurse,action)
end
local dirs
local nofdirs=0
- for name in walkdir(usedpath) do
+ for name,mode,size,time in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
- action(full)
+ action(full,size,time)
end
elseif recurse and mode=="directory" then
if dirs then
@@ -5013,10 +5166,12 @@ local function glob_pattern_table(path,patt,recurse,result)
local dirs
local nofdirs=0
local noffiles=#result
- for name,a in walkdir(usedpath) do
+ for name,mode in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
noffiles=noffiles+1
@@ -5067,7 +5222,7 @@ local function collectpattern(path,patt,recurse,result)
if not find(path,"/$") then
path=path..'/'
end
- for name in scanner,first do
+ for name in scanner,first do
if name=="." then
elseif name==".." then
else
@@ -5158,10 +5313,12 @@ local function globfiles(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if recurse then
globfiles(path.."/"..name,recurse,func,files)
@@ -5184,10 +5341,12 @@ local function globdirs(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if not func or func(name) then
noffiles=noffiles+1
@@ -5368,8 +5527,7 @@ local stack={}
function dir.push(newdir)
local curdir=currentdir()
insert(stack,curdir)
- if newdir and newdir~="" then
- chdir(newdir)
+ if newdir and newdir~="" and chdir(newdir) then
return newdir
else
return curdir
@@ -6310,7 +6468,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 43539, stripped down to: 21641
+-- original size: 44146, stripped down to: 22098
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6326,7 +6484,6 @@ local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,s
local load,dump=load,string.dump
local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
local unpack,concat=table.unpack,table.concat
-local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
@@ -6665,8 +6822,8 @@ local environment={
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
formattedfloat=number.formattedfloat,
- stripzero=lpeg.patterns.stripzero,
- stripzeros=lpeg.patterns.stripzeros,
+ stripzero=patterns.stripzero,
+ stripzeros=patterns.stripzeros,
FORMAT=string.f9,
}
local arguments={ "a1" }
@@ -6753,7 +6910,7 @@ local format_F=function(f)
end
local format_k=function(b,a)
n=n+1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0,a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g=function(f)
n=n+1
@@ -7109,9 +7266,9 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+anything)^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=patterns.luaescape })
local dquote=patterns.dquote
local equote=patterns.escaped+dquote/'\\"'+1
local cquote=Cc('"')
@@ -7143,6 +7300,27 @@ local f_16_16=formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+if not string.explode then
+ local tsplitat=lpeg.tsplitat
+ local p_utf=patterns.utf8character
+ local p_check=C(p_utf)*(P("+")*Cc(true))^0
+ local p_split=Ct(C(p_utf)^0)
+ local p_space=Ct((C(1-P(" ")^1)+P(" ")^1)^0)
+ function string.explode(str,symbol)
+ if symbol=="" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a,b=lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+end
end -- of closure
@@ -7151,7 +7329,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 28756, stripped down to: 16104
+-- original size: 28866, stripped down to: 16134
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7173,7 +7351,8 @@ local formatters=string.formatters
local utftoeight=utf.toeight
local splitter=lpeg.tsplitat(".")
function utilities.tables.definetable(target,nofirst,nolast)
- local composed,t=nil,{}
+ local composed=nil
+ local t={}
local snippets=lpegmatch(splitter,target)
for i=1,#snippets-(nolast and 1 or 0) do
local name=snippets[i]
@@ -7614,18 +7793,19 @@ local function serialize(root,name,specification)
end
if root and next(root)~=nil then
local first=nil
- local last=0
- last=#root
- for k=1,last do
- if rawget(root,k)==nil then
- last=k-1
- break
- end
- end
+ local last=#root
if last>0 then
- first=1
+ for k=1,last do
+ if rawget(root,k)==nil then
+ last=k-1
+ break
+ end
+ end
+ if last>0 then
+ first=1
+ end
end
- local sk=sortedkeys(root)
+ local sk=sortedkeys(root)
for i=1,#sk do
local k=sk[i]
local v=root[k]
@@ -7813,7 +7993,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fil"] = package.loaded["util-fil"] or true
--- original size: 8607, stripped down to: 6727
+-- original size: 11530, stripped down to: 9007
if not modules then modules={} end modules ['util-fil']={
version=1.001,
@@ -8022,6 +8202,32 @@ if bit32 then
local b=char(n%256)
f:write(b,a)
end
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
else
local floor=math.floor
function files.writecardinal2(f,n)
@@ -8030,16 +8236,32 @@ else
local b=char(n%256)
f:write(b,a)
end
-end
-function files.writecardinal4(f,n)
- local a=char(n%256)
- n=rshift(n,8)
- local b=char(n%256)
- n=rshift(n,8)
- local c=char(n%256)
- n=rshift(n,8)
- local d=char(n%256)
- f:write(d,c,b,a)
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
end
function files.writestring(f,s)
f:write(char(byte(s,1,#s)))
@@ -8052,10 +8274,18 @@ if fio and fio.readcardinal1 then
files.readcardinal2=fio.readcardinal2
files.readcardinal3=fio.readcardinal3
files.readcardinal4=fio.readcardinal4
+ files.readcardinal1le=fio.readcardinal1le or files.readcardinal1le
+ files.readcardinal2le=fio.readcardinal2le or files.readcardinal2le
+ files.readcardinal3le=fio.readcardinal3le or files.readcardinal3le
+ files.readcardinal4le=fio.readcardinal4le or files.readcardinal4le
files.readinteger1=fio.readinteger1
files.readinteger2=fio.readinteger2
files.readinteger3=fio.readinteger3
files.readinteger4=fio.readinteger4
+ files.readinteger1le=fio.readinteger1le or files.readinteger1le
+ files.readinteger2le=fio.readinteger2le or files.readinteger2le
+ files.readinteger3le=fio.readinteger3le or files.readinteger3le
+ files.readinteger4le=fio.readinteger4le or files.readinteger4le
files.readfixed2=fio.readfixed2
files.readfixed4=fio.readfixed4
files.read2dot14=fio.read2dot14
@@ -8076,6 +8306,24 @@ if fio and fio.readcardinal1 then
skipposition(f,4*(n or 1))
end
end
+if fio and fio.writecardinal1 then
+ files.writecardinal1=fio.writecardinal1
+ files.writecardinal2=fio.writecardinal2
+ files.writecardinal3=fio.writecardinal3
+ files.writecardinal4=fio.writecardinal4
+ files.writecardinal1le=fio.writecardinal1le
+ files.writecardinal2le=fio.writecardinal2le
+ files.writecardinal3le=fio.writecardinal3le
+ files.writecardinal4le=fio.writecardinal4le
+ files.writeinteger1=fio.writeinteger1 or fio.writecardinal1
+ files.writeinteger2=fio.writeinteger2 or fio.writecardinal2
+ files.writeinteger3=fio.writeinteger3 or fio.writecardinal3
+ files.writeinteger4=fio.writeinteger4 or fio.writecardinal4
+ files.writeinteger1le=files.writeinteger1le or fio.writecardinal1le
+ files.writeinteger2le=files.writeinteger2le or fio.writecardinal2le
+ files.writeinteger3le=files.writeinteger3le or fio.writecardinal3le
+ files.writeinteger4le=files.writeinteger4le or fio.writecardinal4le
+end
if fio and fio.readcardinaltable then
files.readcardinaltable=fio.readcardinaltable
files.readintegertable=fio.readintegertable
@@ -8113,7 +8361,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 11065, stripped down to: 8209
+-- original size: 11332, stripped down to: 8420
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -8138,6 +8386,11 @@ function streams.openstring(f,zerobased)
return { f,1,#f,zerobased or false }
end
end
+function streams.getstring(f)
+ if f then
+ return f[1]
+ end
+end
function streams.close()
end
function streams.size(f)
@@ -8228,7 +8481,7 @@ function streams.readcardinal2(f)
local a,b=byte(f[1],i,j)
return 0x100*a+b
end
-function streams.readcardinal2LE(f)
+function streams.readcardinal2le(f)
local i=f[2]
local j=i+1
f[2]=j+1
@@ -8300,6 +8553,13 @@ function streams.readcardinal4(f)
local a,b,c,d=byte(f[1],i,j)
return 0x1000000*a+0x10000*b+0x100*c+d
end
+function streams.readcardinal4le(f)
+ local i=f[2]
+ local j=i+3
+ f[2]=j+1
+ local d,c,b,a=byte(f[1],i,j)
+ return 0x1000000*a+0x10000*b+0x100*c+d
+end
function streams.readinteger4(f)
local i=f[2]
local j=i+3
@@ -8699,7 +8959,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 23400, stripped down to: 15802
+-- original size: 24132, stripped down to: 16210
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -8724,7 +8984,7 @@ local sortedhash=table.sortedhash
local sortedkeys=table.sortedkeys
local tohash=table.tohash
local hashes={}
-utilities.parsers.hashes=hashes
+parsers.hashes=hashes
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -8944,7 +9204,9 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,sortedkeys(h)
+ local t={}
+ local tn=0
+ local s=sortedkeys(h)
omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
@@ -8982,7 +9244,7 @@ function parsers.array_to_string(a,separator)
end
end
local pattern=Cf(Ct("")*Cg(C((1-S(", "))^1)*S(", ")^0*Cc(true))^1,rawset)
-function utilities.parsers.settings_to_set(str)
+function parsers.settings_to_set(str)
return str and lpegmatch(pattern,str) or {}
end
hashes.settings_to_set=table.setmetatableindex(function(t,k)
@@ -8992,7 +9254,8 @@ hashes.settings_to_set=table.setmetatableindex(function(t,k)
end)
getmetatable(hashes.settings_to_set).__mode="kv"
function parsers.simple_hash_to_string(h,separator)
- local t,tn={},0
+ local t={}
+ local tn=0
for k,v in sortedhash(h) do
if v then
tn=tn+1
@@ -9004,11 +9267,11 @@ end
local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1)
local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
local splitter=setting^1
-function utilities.parsers.options_to_hash(str,target)
+function parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or {}) or {}
end
local splitter=lpeg.tsplitat(" ")
-function utilities.parsers.options_to_array(str)
+function parsers.options_to_array(str)
return str and lpegmatch(splitter,str) or {}
end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
@@ -9021,7 +9284,8 @@ local function repeater(n,str)
if n==1 then
return unpack(s)
else
- local t,tn={},0
+ local t={}
+ local tn=0
for i=1,n do
for j=1,#s do
tn=tn+1
@@ -9192,7 +9456,7 @@ setmetatableindex(cache,function(t,k)
return pattern
end)
local commalistiterator=cache[","]
-function utilities.parsers.iterator(str,separator)
+function parsers.iterator(str,separator)
local n=#str
if n==0 then
return dummy
@@ -9234,10 +9498,10 @@ end
local name=C((1-S(", "))^1)
local parser=(Carg(1)*name/initialize)*(S(", ")^1*(Carg(1)*name/fetch))^0
local merge=Cf(parser,process)
-function utilities.parsers.mergehashes(hash,list)
+function parsers.mergehashes(hash,list)
return lpegmatch(merge,list,1,hash)
end
-function utilities.parsers.runtime(time)
+function parsers.runtime(time)
if not time then
time=os.runtime()
end
@@ -9254,13 +9518,24 @@ local apply=P("->")
local method=C((1-apply)^1)
local token=lbrace*C((1-rbrace)^1)*rbrace+C(anything^1)
local pattern=spacing*(method*spacing*apply+Carg(1))*spacing*token
-function utilities.parsers.splitmethod(str,default)
+function parsers.splitmethod(str,default)
if str then
return lpegmatch(pattern,str,1,default or false)
else
return default or false,""
end
end
+local p_year=lpegpatterns.digit^4/tonumber
+local pattern=Cf(Ct("")*(
+ (Cg(Cc("year")*p_year)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("day")*cardinal)
+ )+(Cg(Cc("day")*cardinal)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("year")*p_year)
+ )
+ )*P(" ")*Cg(Cc("hour")*cardinal)*P(":")*Cg(Cc("min")*cardinal)*(P(":")*Cg(Cc("sec")*cardinal))^-1
+,rawset)
+lpegpatterns.splittime=pattern
+function parsers.totime(str)
+ return lpegmatch(pattern,str)
+end
end -- of closure
@@ -9269,7 +9544,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fmt"] = package.loaded["util-fmt"] or true
--- original size: 2274, stripped down to: 1607
+-- original size: 2541, stripped down to: 1624
if not modules then modules={} end modules ['util-fmt']={
version=1.001,
@@ -9305,8 +9580,8 @@ function formatters.formatcolumns(result,between)
local tj=type(rj)
if tj=="number" then
numbers[j]=true
- end
- if tj~="string" then
+ rj=tostring(rj)
+ elseif tj~="string" then
rj=tostring(rj)
r[j]=rj
end
@@ -9372,13 +9647,13 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-socket"] = package.loaded["util-soc-imp-socket"] or true
--- original size: 4870, stripped down to: 3527
+-- original size: 4905, stripped down to: 3562
local type,tostring,setmetatable=type,tostring,setmetatable
local min=math.min
local format=string.format
-local socket=require("socket.core")
+local socket=socket or package.loaded.socket or require("socket.core")
local connect=socket.connect
local tcp4=socket.tcp4
local tcp6=socket.tcp6
@@ -9548,7 +9823,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-copas"] = package.loaded["util-soc-imp-copas"] or true
--- original size: 25844, stripped down to: 14821
+-- original size: 25959, stripped down to: 14893
local socket=socket or require("socket")
@@ -9585,6 +9860,7 @@ local copas={
autoclose=true,
running=false,
report=report,
+ trace=false,
}
local function statushandler(status,...)
if status then
@@ -9594,7 +9870,9 @@ local function statushandler(status,...)
if type(err)=="table" then
err=err[1]
end
- report("error: %s",tostring(err))
+ if copas.trace then
+ report("error: %s",tostring(err))
+ end
return nil,err
end
function socket.protect(func)
@@ -9608,7 +9886,9 @@ function socket.newtry(finalizer)
if not status then
local detail=select(2,...)
pcall(finalizer,detail)
- report("error: %s",tostring(detail))
+ if copas.trace then
+ report("error: %s",tostring(detail))
+ end
return
end
return...
@@ -10561,12 +10841,12 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-mime"] = package.loaded["util-soc-imp-mime"] or true
--- original size: 2328, stripped down to: 1874
+-- original size: 2373, stripped down to: 1931
local type,tostring=type,tostring
-local mime=require("mime.core")
-local ltn12=ltn12 or require("ltn12")
+local mime=mime or package.loaded.mime or require("mime.core")
+local ltn12=ltn12 or package.loaded.ltn12 or require("ltn12")
local filtercycle=ltn12.filter.cycle
local function report(fmt,first,...)
if logs then
@@ -12518,7 +12798,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32608, stripped down to: 20925
+-- original size: 32618, stripped down to: 20935
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -12563,7 +12843,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if runningtex then
+if runningtex and texio then
if texio.setescape then
texio.setescape(0)
end
@@ -13399,7 +13679,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 9072, stripped down to: 6055
+-- original size: 8966, stripped down to: 5972
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -13546,13 +13826,11 @@ function statistics.show()
end
register("lua properties",function()
local hashchar=tonumber(status.luatex_hashchars)
- local hashtype=status.luatex_hashtype
local mask=lua.mask or "ascii"
- return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
+ return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
jit and "luajit" or "lua",
LUAVERSION,
statistics.memused(),
- hashtype or "default",
hashchar and 2^hashchar or "unknown",
mask,
mask=="utf" and "τεχ" or "tex")
@@ -13935,7 +14213,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-deb"] = package.loaded["util-deb"] or true
--- original size: 9955, stripped down to: 6693
+-- original size: 10136, stripped down to: 6832
if not modules then modules={} end modules ['util-deb']={
version=1.001,
@@ -13959,7 +14237,13 @@ local dummycalls=10*1000
local nesting=0
local names={}
local initialize=false
-if not (FFISUPPORTED and ffi) then
+if lua.getpreciseticks then
+ initialize=function()
+ ticks=lua.getpreciseticks
+ seconds=lua.getpreciseseconds
+ initialize=false
+ end
+elseif not (FFISUPPORTED and ffi) then
elseif os.type=="windows" then
initialize=function()
local kernel=ffilib("kernel32","system")
@@ -15062,7 +15346,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-env"] = package.loaded["util-env"] or true
--- original size: 9517, stripped down to: 5360
+-- original size: 9738, stripped down to: 5531
if not modules then modules={} end modules ['util-env']={
version=1.001,
@@ -15136,8 +15420,11 @@ environment.arguments=allocate()
environment.files=allocate()
environment.sortedflags=nil
function environment.initializearguments(arg)
- local arguments,files={},{}
- environment.arguments,environment.files,environment.sortedflags=arguments,files,nil
+ local arguments={}
+ local files={}
+ environment.arguments=arguments
+ environment.files=files
+ environment.sortedflags=nil
for index=1,#arg do
local argument=arg[index]
if index>0 then
@@ -15156,6 +15443,11 @@ function environment.initializearguments(arg)
end
end
end
+ if not environment.ownname then
+ if os.selfpath and os.selfname then
+ environment.ownname=file.addsuffix(file.join(os.selfpath,os.selfname),"lua")
+ end
+ end
environment.ownname=file.reslash(environment.ownname or arg[0] or 'unknown.lua')
end
function environment.setargument(name,value)
@@ -15434,6 +15726,468 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-zip"] = package.loaded["util-zip"] or true
+
+-- original size: 18645, stripped down to: 11291
+
+if not modules then modules={} end modules ['util-zip']={
+ version=1.001,
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tostring,tonumber=type,tostring,tonumber
+local sort=table.sort
+local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub
+local osdate,ostime=os.date,os.time
+local ioopen=io.open
+local loaddata,savedata=io.loaddata,io.savedata
+local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs
+local files=utilities.files
+local openfile=files.open
+local closefile=files.close
+local readstring=files.readstring
+local readcardinal2=files.readcardinal2le
+local readcardinal4=files.readcardinal4le
+local setposition=files.setposition
+local getposition=files.getposition
+local band=bit32.band
+local rshift=bit32.rshift
+local lshift=bit32.lshift
+local decompress,calculatecrc
+if flate then
+ decompress=flate.flate_decompress
+ calculatecrc=flate.update_crc32
+else
+ local zlibdecompress=zlib.decompress
+ local zlibchecksum=zlib.crc32
+ decompress=function(source,targetsize)
+ local target=zlibdecompress(source,-15)
+ if target then
+ return target
+ else
+ return false,1
+ end
+ end
+ calculatecrc=function(buffer,initial)
+ return zlibchecksum(initial or 0,buffer)
+ end
+end
+local zipfiles={}
+utilities.zipfiles=zipfiles
+local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
+ function openzipfile(name)
+ return {
+ name=name,
+ handle=openfile(name,0),
+ }
+ end
+ local function collect(z)
+ if not z.list then
+ local list={}
+ local hash={}
+ local position=0
+ local index=0
+ local handle=z.handle
+ while true do
+ setposition(handle,position)
+ local signature=readstring(handle,4)
+ if signature=="PK\3\4" then
+ local version=readcardinal2(handle)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ local filetime=readcardinal2(handle)
+ local filedate=readcardinal2(handle)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local filename=readstring(handle,namelength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ local skipped=0
+ local size=0
+ if encrypted then
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ end
+ position=position+30+namelength+extralength+skipped
+ if descriptor then
+ setposition(handle,position+compressed)
+ crc32=readcardinal4(handle)
+ compressed=readcardinal4(handle)
+ uncompressed=readcardinal4(handle)
+ end
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=position,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ }
+ hash[filename]=data
+ list[index]=data
+ else
+ end
+ position=position+compressed
+ else
+ break
+ end
+ z.list=list
+ z.hash=hash
+ end
+ end
+ end
+ function getziplist(z)
+ local list=z.list
+ if not list then
+ collect(z)
+ end
+ return z.list
+ end
+ function getziphash(z)
+ local hash=z.hash
+ if not hash then
+ collect(z)
+ end
+ return z.hash
+ end
+ function foundzipfile(z,name)
+ return getziphash(z)[name]
+ end
+ function closezipfile(z)
+ local f=z.handle
+ if f then
+ closefile(f)
+ z.handle=nil
+ end
+ end
+ function unzipfile(z,filename,check)
+ local hash=z.hash
+ if not hash then
+ hash=zipfiles.hash(z)
+ end
+ local data=hash[filename]
+ if not data then
+ end
+ if data then
+ local handle=z.handle
+ local position=data.position
+ local compressed=data.compressed
+ if compressed>0 then
+ setposition(handle,position)
+ local result=readstring(handle,compressed)
+ if data.method==8 then
+ result=decompress(result,data.uncompressed)
+ end
+ if check and data.crc32~=calculatecrc(result) then
+ print("checksum mismatch")
+ return ""
+ end
+ return result
+ else
+ return ""
+ end
+ end
+ end
+ zipfiles.open=openzipfile
+ zipfiles.close=closezipfile
+ zipfiles.unzip=unzipfile
+ zipfiles.hash=getziphash
+ zipfiles.list=getziplist
+ zipfiles.found=foundzipfile
+end
+if flate then do
+ local writecardinal1=files.writebyte
+ local writecardinal2=files.writecardinal2le
+ local writecardinal4=files.writecardinal4le
+ local logwriter=logs.writer
+ local globpattern=dir.globpattern
+ local compress=flate.flate_compress
+ local checksum=flate.update_crc32
+ local function fromdostime(dostime,dosdate)
+ return ostime {
+ year=rshift(dosdate,9)+1980,
+ month=band(rshift(dosdate,5),0x0F),
+ day=band((dosdate ),0x1F),
+ hour=band(rshift(dostime,11) ),
+ min=band(rshift(dostime,5),0x3F),
+ sec=band((dostime ),0x1F),
+ }
+ end
+ local function todostime(time)
+ local t=osdate("*t",time)
+ return
+ lshift(t.year-1980,9)+lshift(t.month,5)+t.day,
+ lshift(t.hour,11)+lshift(t.min,5)+rshift(t.sec,1)
+ end
+ local function openzip(filename,level,comment,verbose)
+ local f=ioopen(filename,"wb")
+ if f then
+ return {
+ filename=filename,
+ handle=f,
+ list={},
+ level=tonumber(level) or 3,
+ comment=tostring(comment),
+ verbose=verbose,
+ uncompressed=0,
+ compressed=0,
+ }
+ end
+ end
+ local function writezip(z,name,data,level,time)
+ local f=z.handle
+ local list=z.list
+ local level=tonumber(level) or z.level or 3
+ local method=8
+ local zipped=compress(data,level)
+ local checksum=checksum(data)
+ local verbose=z.verbose
+ if not zipped then
+ method=0
+ zipped=data
+ end
+ local start=f:seek()
+ local compressed=#zipped
+ local uncompressed=#data
+ z.compressed=z.compressed+compressed
+ z.uncompressed=z.uncompressed+uncompressed
+ if verbose then
+ local pct=100*compressed/uncompressed
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,name))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,name))
+ end
+ end
+ f:write("\x50\x4b\x03\x04")
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,method)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ f:write(name)
+ f:write(zipped)
+ list[#list+1]={ #zipped,#data,name,checksum,start,time or 0 }
+ end
+ local function closezip(z)
+ local f=z.handle
+ local list=z.list
+ local comment=z.comment
+ local verbose=z.verbose
+ local count=#list
+ local start=f:seek()
+ for i=1,count do
+ local l=list[i]
+ local compressed=l[1]
+ local uncompressed=l[2]
+ local name=l[3]
+ local checksum=l[4]
+ local start=l[5]
+ local time=l[6]
+ local date,time=todostime(time)
+ f:write('\x50\x4b\x01\x02')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,8)
+ writecardinal2(f,time)
+ writecardinal2(f,date)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,0)
+ writecardinal4(f,start)
+ f:write(name)
+ end
+ local stop=f:seek()
+ local size=stop-start
+ f:write('\x50\x4b\x05\x06')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,count)
+ writecardinal2(f,count)
+ writecardinal4(f,size)
+ writecardinal4(f,start)
+ if type(comment)=="string" and comment~="" then
+ writecardinal2(f,#comment)
+ f:write(comment)
+ else
+ writecardinal2(f,0)
+ end
+ if verbose then
+ local compressed=z.compressed
+ local uncompressed=z.uncompressed
+ local filename=z.filename
+ local pct=100*compressed/uncompressed
+ logwriter("")
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,filename))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,filename))
+ end
+ end
+ f:close()
+ end
+ local function zipdir(zipname,path,level,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ level=zipname.level
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ if not isdir(path) then
+ return
+ end
+ path=gsub(path,"\\+","/")
+ path=gsub(path,"/+","/")
+ local list={}
+ local count=0
+ globpattern(path,"",true,function(name,size,time)
+ count=count+1
+ list[count]={ name,time }
+ end)
+ sort(list,function(a,b)
+ return a[1]<b[1]
+ end)
+ local zipf=openzip(zipname,level,comment,verbose)
+ if zipf then
+ local p=#path+2
+ for i=1,count do
+ local li=list[i]
+ local name=li[1]
+ local time=li[2]
+ local data=loaddata(name)
+ local name=sub(name,p,#name)
+ writezip(zipf,name,data,level,time,verbose)
+ end
+ closezip(zipf)
+ end
+ end
+ local function unzipdir(zipname,path,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ local z=openzipfile(zipname)
+ if z then
+ local list=getziplist(z)
+ if list then
+ local total=0
+ local count=#list
+ local step=number.idiv(count,10)
+ local done=0
+ for i=1,count do
+ local l=list[i]
+ local n=l.filename
+ local d=unzipfile(z,n)
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if verbose=="steps" then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes",i,count,total))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ end
+ end
+ if verbose=="steps" then
+ logwriter(format("%4i files of %4i done, %10i bytes",count,count,total))
+ end
+ closezipfile(z)
+ return true
+ else
+ closezipfile(z)
+ end
+ end
+ end
+ zipfiles.zipdir=zipdir
+ zipfiles.unzipdir=unzipdir
+end end
+if flate then
+ local streams=utilities.streams
+ local openfile=streams.open
+ local closestream=streams.close
+ local setposition=streams.setposition
+ local getsize=streams.size
+ local readcardinal4=streams.readcardinal4le
+ local getstring=streams.getstring
+ local decompress=flate.gz_decompress
+ function zipfiles.gunzipfile(filename)
+ local strm=openfile(filename)
+ if strm then
+ setposition(strm,getsize(strm)-4+1)
+ local size=readcardinal4(strm)
+ local data=decompress(getstring(strm),size)
+ closestream(strm)
+ return data
+ end
+ end
+elseif gzip then
+ local openfile=gzip.open
+ function zipfiles.gunzipfile(filename)
+ local g=openfile(filename,"rb")
+ if g then
+ local d=g:read("*a")
+ d:close()
+ return d
+ end
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true
-- original size: 60383, stripped down to: 35698
@@ -16892,7 +17646,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54551, stripped down to: 30745
+-- original size: 55145, stripped down to: 30992
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -16972,7 +17726,8 @@ apply_axis['self']=function(list)
return list
end
apply_axis['child']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local dt=ll.dt
@@ -17044,7 +17799,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
c=collect(list[l],collected,c)
end
@@ -17085,7 +17841,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
if ll.special~=true then
@@ -17097,7 +17854,8 @@ apply_axis['descendant-or-self']=function(list)
return collected
end
apply_axis['ancestor']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
while ll do
@@ -17111,7 +17869,8 @@ apply_axis['ancestor']=function(list)
return collected
end
apply_axis['ancestor-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
c=c+1
@@ -17127,7 +17886,8 @@ apply_axis['ancestor-or-self']=function(list)
return collected
end
apply_axis['parent']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local pl=list[l].__p__
if pl then
@@ -17150,7 +17910,8 @@ apply_axis['preceding']=function(list)
return {}
end
apply_axis['following-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17166,7 +17927,8 @@ apply_axis['following-sibling']=function(list)
return collected
end
apply_axis['preceding-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17182,7 +17944,8 @@ apply_axis['preceding-sibling']=function(list)
return collected
end
apply_axis['reverse-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17205,7 +17968,8 @@ apply_axis['initial-child']=apply_axis['child']
local function apply_nodes(list,directive,nodes)
local maxn=#nodes
if maxn==3 then
- local nns,ntg=nodes[2],nodes[3]
+ local nns=nodes[2]
+ local ntg=nodes[3]
if not nns and not ntg then
if directive then
return list
@@ -17213,7 +17977,10 @@ local function apply_nodes(list,directive,nodes)
return {}
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
if not nns then
for l=1,#list do
local ll=list[l]
@@ -17221,14 +17988,16 @@ local function apply_nodes(list,directive,nodes)
if ltg then
if directive then
if ntg==ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif ntg~=ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17239,14 +18008,16 @@ local function apply_nodes(list,directive,nodes)
if lns then
if directive then
if lns==nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif lns~=nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17259,14 +18030,16 @@ local function apply_nodes(list,directive,nodes)
local ok=ltg==ntg and lns==nns
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17274,7 +18047,10 @@ local function apply_nodes(list,directive,nodes)
return collected
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
for l=1,#list do
local ll=list[l]
local ltg=ll.tg
@@ -17282,7 +18058,8 @@ local function apply_nodes(list,directive,nodes)
local lns=ll.rn or ll.ns
local ok=false
for n=1,maxn,3 do
- local nns,ntg=nodes[n+1],nodes[n+2]
+ local nns=nodes[n+1]
+ local ntg=nodes[n+2]
ok=(not ntg or ltg==ntg) and (not nns or lns==nns)
if ok then
break
@@ -17290,14 +18067,16 @@ local function apply_nodes(list,directive,nodes)
end
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17306,7 +18085,8 @@ local function apply_nodes(list,directive,nodes)
end
local quit_expression=false
local function apply_expression(list,expression,order)
- local collected,c={},0
+ local collected={}
+ local c=0
quit_expression=false
for l=1,#list do
local ll=list[l]
@@ -17560,7 +18340,8 @@ local function tagstostring(list)
local t={}
for i=1,#list do
local li=list[i]
- local ns,tg=li.ns,li.tg
+ local ns=li.ns
+ local tg=li.tg
if not ns or ns=="" then ns="*" end
if not tg or tg=="" then tg="*" end
t[i]=(tg=="@rt@" and "[root]") or format("%s:%s",ns,tg)
@@ -17924,7 +18705,8 @@ expressions.name=function(e,n)
if n==0 then
found=type(e)=="table" and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17937,7 +18719,8 @@ expressions.name=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -17951,7 +18734,8 @@ expressions.name=function(e,n)
end
end
if found then
- local ns,tg=found.rn or found.ns or "",found.tg
+ local ns=found.rn or found.ns or ""
+ local tg=found.tg
if ns~="" then
return ns..":"..tg
else
@@ -17970,7 +18754,8 @@ expressions.tag=function(e,n)
if n==0 then
found=(type(e)=="table") and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17983,7 +18768,8 @@ expressions.tag=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -18163,7 +18949,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true
--- original size: 30650, stripped down to: 19621
+-- original size: 30771, stripped down to: 19680
if not modules then modules={} end modules ['lxml-aux']={
version=1.001,
@@ -18278,10 +19064,12 @@ end
function xml.collect_tags(root,pattern,nonamespace)
local collected=xmlapplylpath(root,pattern)
if collected then
- local t,n={},0
+ local t={}
+ local n=0
for c=1,#collected do
local e=collected[c]
- local ns,tg=e.ns,e.tg
+ local ns=e.ns
+ local tg=e.tg
n=n+1
if nonamespace then
t[n]=tg
@@ -18436,7 +19224,9 @@ local function inject_element(root,pattern,whatever,prepend)
local collected=element and xmlapplylpath(root,pattern)
local function inject_e(e)
local r=e.__p__
- local d,k,rri=r.dt,e.ni,r.ri
+ local d=r.dt
+ local k=e.ni
+ local rri=r.ri
local edt=(rri and d[rri].dt) or (d and d[k] and d[k].dt)
if edt then
local be,af
@@ -18473,7 +19263,8 @@ local function insert_element(root,pattern,whatever,before)
local collected=element and xmlapplylpath(root,pattern)
local function insert_e(e)
local r=e.__p__
- local d,k=r.dt,e.ni
+ local d=r.dt
+ local k=e.ni
if not before then
k=k+1
end
@@ -18903,8 +19694,10 @@ function xml.separate(x,pattern)
report_xml("warning: xml.separate changes root")
x=d
end
- local t,n={ "\n" },1
- local i,nd=1,#d
+ local t={ "\n" }
+ local n=1
+ local i=1
+ local nd=#d
while i<=nd do
while i<=nd do
local di=d[i]
@@ -19885,7 +20678,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-exp"] = package.loaded["data-exp"] or true
--- original size: 18105, stripped down to: 10389
+-- original size: 18154, stripped down to: 10416
if not modules then modules={} end modules ['data-exp']={
version=1.001,
@@ -20092,9 +20885,11 @@ local function scan(files,remap,spec,path,n,m,r,onlyone,tolerant)
local pattern=tolerant and lessweird or weird
local filelist={}
local noffiles=0
- for name in directory(full) do
+ for name,mode in directory(full) do
if not lpegmatch(pattern,name) then
- local mode=attributes(full..name,"mode")
+ if not mode then
+ mode=attributes(full..name,"mode")
+ end
if mode=="file" then
n=n+1
noffiles=noffiles+1
@@ -20575,7 +21370,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16116, stripped down to: 10782
+-- original size: 16284, stripped down to: 10938
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -20615,6 +21410,7 @@ caches.force=true
caches.ask=false
caches.relocate=false
caches.defaults={ "TMPDIR","TEMPDIR","TMP","TEMP","HOME","HOMEPATH" }
+directives.register("system.caches.fast",function(v) caches.fast=true end)
local writable,readables,usedreadables=nil,{},{}
local function identify()
local texmfcaches=resolvers.cleanpathlist("TEXMFCACHE")
@@ -20848,7 +21644,9 @@ local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
data.cache_uuid=os.uuid()
- if caches.direct then
+ if caches.fast then
+ file.savedata(tmaname,table.fastserialize(data,true))
+ elseif caches.direct then
file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
table.tofile(tmaname,data,true,saveoptions)
@@ -23182,7 +23980,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8700, stripped down to: 6313
+-- original size: 10263, stripped down to: 7556
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23201,6 +23999,65 @@ local archives=zip.archives or {}
zip.archives=archives
local registeredfiles=zip.registeredfiles or {}
zip.registeredfiles=registeredfiles
+local zipfiles=utilities.zipfiles
+local openzip,closezip,validfile,wholefile,filehandle,traversezip
+if zipfiles then
+ local ipairs=ipairs
+ openzip=zipfiles.open
+ closezip=zipfiles.close
+ validfile=zipfiles.found
+ wholefile=zipfiles.unzip
+ traversezip=function(zfile)
+ return ipairs(zipfiles.list(zfile))
+ end
+ local streams=utilities.streams
+ local openstream=streams.open
+ local readstring=streams.readstring
+ local streamsize=streams.size
+ local metatable={
+ close=streams.close,
+ read=function(stream,n)
+ readstring(stream,n=="*a" and streamsize(stream) or n)
+ end
+ }
+ filehandle=function(zfile,queryname)
+ local data=wholefile(zfile,queryname)
+ if data then
+ local stream=openstream(data)
+ if stream then
+ return setmetatableindex(stream,metatable)
+ end
+ end
+ end
+else
+ openzip=zip.open
+ closezip=zip.close
+ validfile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ dfile:close()
+ return true
+ end
+ return false
+ end
+ traversezip=function(zfile)
+ return z:files()
+ end
+ wholefile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ local s=dfile:read("*all")
+ dfile:close()
+ return s
+ end
+ end
+ filehandle=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ return dfile
+ end
+ end
+end
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23215,7 +24072,7 @@ function zip.openarchive(name)
local arch=archives[name]
if not arch then
local full=resolvers.findfile(name) or ""
- arch=full~="" and zip.open(full) or false
+ arch=full~="" and openzip(full) or false
archives[name]=arch
end
return arch
@@ -23223,7 +24080,7 @@ function zip.openarchive(name)
end
function zip.closearchive(name)
if not name or (name=="" and archives[name]) then
- zip.close(archives[name])
+ closezip(archives[name])
archives[name]=nil
end
end
@@ -23264,9 +24121,7 @@ function resolvers.finders.zip(specification)
if trace_locating then
report_zip("finder: archive %a found",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
- dfile:close()
+ if validfile(zfile,queryname) then
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -23296,12 +24151,12 @@ function resolvers.openers.zip(specification)
if trace_locating then
report_zip("opener; archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local handle=filehandle(zfile,queryname)
+ if handle then
if trace_locating then
report_zip("opener: file %a found",queryname)
end
- return resolvers.openers.helpers.textopener('zip',original,dfile)
+ return resolvers.openers.helpers.textopener('zip',original,handle)
elseif trace_locating then
report_zip("opener: file %a not found",queryname)
end
@@ -23327,15 +24182,13 @@ function resolvers.loaders.zip(specification)
if trace_locating then
report_zip("loader: archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local data=wholefile(zfile,queryname)
+ if data then
logs.show_load(original)
if trace_locating then
report_zip("loader; file %a loaded",original)
end
- local s=dfile:read("*all")
- dfile:close()
- return true,s,#s
+ return true,data,#data
elseif trace_locating then
report_zip("loader: file %a not found",queryname)
end
@@ -23382,7 +24235,7 @@ function resolvers.registerzipfile(z,tree)
if trace_locating then
report_zip("registering: using filter %a",filter)
end
- for i in z:files() do
+ for i in traversezip(z) do
local filename=i.filename
local path,name=match(filename,filter)
if not path then
@@ -23911,7 +24764,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-aux"] = package.loaded["data-aux"] or true
--- original size: 2438, stripped down to: 1863
+-- original size: 2452, stripped down to: 1877
if not modules then modules={} end modules ['data-aux']={
version=1.001,
@@ -23959,7 +24812,7 @@ function resolvers.updatescript(oldname,newname)
local newdata=io.loaddata(newscript)
if newdata then
if trace_locating then
- report_scripts("old script content replaced by new content")
+ report_scripts("old script content replaced by new content: %s",oldscript)
end
io.savedata(oldscript,newdata)
break
@@ -24516,7 +25369,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true
--- original size: 9346, stripped down to: 7085
+-- original size: 9637, stripped down to: 7253
if not modules then modules={} end modules ['luat-fmt']={
version=1.001,
@@ -24536,9 +25389,6 @@ local function primaryflags()
if arguments.silent then
flags[#flags+1]="--interaction=batchmode"
end
- if arguments.jit then
- flags[#flags+1]="--jiton"
- end
return concat(flags," ")
end
local function secondaryflags()
@@ -24567,6 +25417,9 @@ local function secondaryflags()
if arguments.strip then
flags[#flags+1]="--c:strip"
end
+ if arguments.lmtx then
+ flags[#flags+1]="--c:lmtx"
+ end
return concat(flags," ")
end
local template=[[--ini %primaryflags% --lua=%luafile% %texfile% %secondaryflags% %dump% %redirect%]]
@@ -24586,6 +25439,13 @@ local runners={
checkers=checkers,
reporter=report_format,
},
+ luametatex=sandbox.registerrunner {
+ name="make luametatex format",
+ program="luametatex",
+ template=template,
+ checkers=checkers,
+ reporter=report_format,
+ },
luajittex=sandbox.registerrunner {
name="make luajittex format",
program="luajittex",
@@ -24753,10 +25613,10 @@ end
end -- of closure
--- used libraries : 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 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 util-lib.lua luat-sta.lua luat-fmt.lua
+-- 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 util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 989477
--- stripped bytes : 393339
+-- original bytes : 1020503
+-- stripped bytes : 404014
-- end library merge
@@ -24779,6 +25639,7 @@ local owntree = environment and environment.ownpath or ownpath
local ownlibs = { -- order can be made better
+ 'l-bit32.lua',
'l-lua.lua',
'l-macro.lua',
'l-sandbox.lua',
@@ -24836,6 +25697,8 @@ local ownlibs = { -- order can be made better
'util-env.lua',
'luat-env.lua', -- can come before inf (as in mkiv)
+ 'util-zip.lua',
+
'lxml-tab.lua',
'lxml-lpt.lua',
-- 'lxml-ent.lua',
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 611f7c8dd..a79ffc029 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -61,9 +61,140 @@ if not modules then modules = { } end modules ['mtxrun'] = {
do -- create closure to overcome 200 locals limit
+package.loaded["l-bit32"] = package.loaded["l-bit32"] or true
+
+-- original size: 3607, stripped down to: 3009
+
+if not modules then modules={} end modules ['l-bit32']={
+ version=1.001,
+ license="the same as regular Lua",
+ source="bitwise.lua, v 1.24 2014/12/26 17:20:53 roberto",
+ comment="drop-in for bit32, adapted a bit by Hans Hagen",
+}
+if bit32 then
+elseif utf8 then
+ load ([[
+local select = select -- instead of: arg = { ... }
+bit32 = {
+ bnot = function (a)
+ return ~a & 0xFFFFFFFF
+ end,
+ band = function (x, y, z, ...)
+ if not z then
+ return ((x or -1) & (y or -1)) & 0xFFFFFFFF
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) | (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x | y | z
+ for i=1,select("#",...) do
+ res = res | select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bxor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x ~ y ~ z
+ for i=1,select("#",...) do
+ res = res ~ select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ btest = function (x, y, z, ...)
+ if not z then
+ return (((x or -1) & (y or -1)) & 0xFFFFFFFF) ~= 0
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return (res & 0xFFFFFFFF) ~= 0
+ end
+ end,
+ lshift = function (a, b)
+ return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF
+ end,
+ rshift = function (a, b)
+ return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF
+ end,
+ arshift = function (a, b)
+ a = a & 0xFFFFFFFF
+ if b <= 0 or (a & 0x80000000) == 0 then
+ return (a >> b) & 0xFFFFFFFF
+ else
+ return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF
+ end
+ end,
+ lrotate = function (a ,b)
+ b = b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ rrotate = function (a, b)
+ b = -b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ extract = function (a, f, w)
+ return (a >> f) & ~(-1 << (w or 1))
+ end,
+ replace = function (a, v, f, w)
+ local mask = ~(-1 << (w or 1))
+ return ((a & ~(mask << f)) | ((v & mask) << f)) & 0xFFFFFFFF
+ end,
+}
+ ]] ) ()
+elseif bit then
+ load ([[
+local band, bnot, rshift, lshift = bit.band, bit.bnot, bit.rshift, bit.lshift
+bit32 = {
+ arshift = bit.arshift,
+ band = band,
+ bnot = bnot,
+ bor = bit.bor,
+ bxor = bit.bxor,
+ btest = function(...)
+ return band(...) ~= 0
+ end,
+ extract = function(a,f,w)
+ return band(rshift(a,f),2^(w or 1)-1)
+ end,
+ lrotate = bit.rol,
+ lshift = lshift,
+ replace = function(a,v,f,w)
+ local mask = 2^(w or 1)-1
+ return band(a,bnot(lshift(mask,f)))+lshift(band(v,mask),f)
+ end,
+ rrotate = bit.ror,
+ rshift = rshift,
+}
+ ]] ) ()
+else
+ xpcall(function() local _,t=require("bit32") if t then bit32=t end return end,function() end)
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 6204, stripped down to: 2852
+-- original size: 6330, stripped down to: 2831
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -180,8 +311,7 @@ if not FFISUPPORTED then
elseif not ffi.number then
ffi.number=tonumber
end
-if not bit32 then
- bit32=require("l-bit32")
+if LUAVERSION>5.3 then
end
@@ -1962,7 +2092,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40960, stripped down to: 21348
+-- original size: 41332, stripped down to: 21508
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1973,7 +2103,7 @@ if not modules then modules={} end modules ['l-table']={
}
local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select
local table,string=table,string
-local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
+local concat,sort=table.concat,table.sort
local format,lower,dump=string.format,string.lower,string.dump
local getmetatable,setmetatable=getmetatable,setmetatable
local lpegmatch,patterns=lpeg.match,lpeg.patterns
@@ -1983,7 +2113,8 @@ function table.getn(t)
return t and #t
end
function table.strip(tab)
- local lst,l={},0
+ local lst={}
+ local l=0
for i=1,#tab do
local s=lpegmatch(stripper,tab[i]) or ""
if s=="" then
@@ -1996,7 +2127,8 @@ function table.strip(tab)
end
function table.keys(t)
if t then
- local keys,k={},0
+ local keys={}
+ local k=0
for key in next,t do
k=k+1
keys[k]=key
@@ -2027,27 +2159,30 @@ local function compare(a,b)
end
local function sortedkeys(tab)
if tab then
- local srt,category,s={},0,0
+ local srt={}
+ local category=0
+ local s=0
for key in next,tab do
s=s+1
srt[s]=key
- if category==3 then
- elseif category==1 then
- if type(key)~="string" then
- category=3
- end
- elseif category==2 then
- if type(key)~="number" then
- category=3
- end
- else
+ if category~=3 then
local tkey=type(key)
- if tkey=="string" then
- category=1
- elseif tkey=="number" then
- category=2
+ if category==1 then
+ if tkey~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if tkey~="number" then
+ category=3
+ end
else
- category=3
+ if tkey=="string" then
+ category=1
+ elseif tkey=="number" then
+ category=2
+ else
+ category=3
+ end
end
end
end
@@ -2064,7 +2199,8 @@ local function sortedkeys(tab)
end
local function sortedhashonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="string" then
s=s+1
@@ -2081,7 +2217,8 @@ local function sortedhashonly(tab)
end
local function sortedindexonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="number" then
s=s+1
@@ -2098,7 +2235,8 @@ local function sortedindexonly(tab)
end
local function sortedhashkeys(tab,cmp)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if key then
s=s+1
@@ -2174,7 +2312,9 @@ function table.prepend(t,list)
return t
end
function table.merge(t,...)
- t=t or {}
+ if not t then
+ t={}
+ end
for i=1,select("#",...) do
for k,v in next,(select(i,...)) do
t[k]=v
@@ -2203,7 +2343,8 @@ function table.imerge(t,...)
return t
end
function table.imerged(...)
- local tmp,ntmp={},0
+ local tmp={}
+ local ntmp=0
for i=1,select("#",...) do
local nst=select(i,...)
for j=1,#nst do
@@ -2235,7 +2376,9 @@ local function fastcopy(old,metatabletoo)
end
end
local function copy(t,tables)
- tables=tables or {}
+ if not tables then
+ tables={}
+ end
local tcopy={}
if not tables[t] then
tables[t]=tcopy
@@ -2282,7 +2425,8 @@ function table.tohash(t,value)
return h
end
function table.fromhash(t)
- local hsh,h={},0
+ local hsh={}
+ local h=0
for k,v in next,t do
if v then
h=h+1
@@ -2383,7 +2527,8 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
if root and next(root)~=nil then
- local first,last=nil,0
+ local first=nil
+ local last=0
if compact then
last=#root
for k=1,last do
@@ -2642,7 +2787,8 @@ local function serialize(_handle,root,name,specification)
handle("}")
end
function table.serialize(root,name,specification)
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
@@ -2656,13 +2802,15 @@ function table.tofile(filename,root,name,specification)
local f=io.open(filename,'w')
if f then
if maxtab>1 then
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
if n>maxtab then
f:write(concat(t,"\n"),"\n")
- t,n={},0
+ t={}
+ n=0
end
end
serialize(flush,root,name,specification)
@@ -2764,8 +2912,12 @@ local function are_equal(a,b,n,m)
if a==b then
return true
elseif a and b and #a==#b then
- n=n or 1
- m=m or #a
+ if not n then
+ n=1
+ end
+ if not m then
+ m=#a
+ end
for i=n,m do
local ai,bi=a[i],b[i]
if ai==bi then
@@ -2865,7 +3017,8 @@ function table.mirrored(t)
end
function table.reversed(t)
if t then
- local tt,tn={},#t
+ local tt={}
+ local tn=#t
if tn>0 then
local ttn=0
for i=tn,1,-1 do
@@ -2978,7 +3131,9 @@ function table.sorted(t,...)
end
function table.values(t,s)
if t then
- local values,keys,v={},{},0
+ local values={}
+ local keys={}
+ local v=0
for key,value in next,t do
if not keys[value] then
v=v+1
@@ -3610,7 +3765,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 19347, stripped down to: 10258
+-- original size: 18985, stripped down to: 10149
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -3775,17 +3930,8 @@ local launchers={
unix="xdg-open %s &> /dev/null &",
}
function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
-end
-if not os.times then
- function os.times()
- return {
- utime=os.gettimeofday(),
- stime=0,
- cutime=0,
- cstime=0,
- }
- end
+ local command=format(launchers[os.name] or launchers.unix,str)
+ execute(command)
end
local gettimeofday=os.gettimeofday or os.clock
os.gettimeofday=gettimeofday
@@ -4062,7 +4208,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-file"] = package.loaded["l-file"] or true
--- original size: 21804, stripped down to: 9980
+-- original size: 21984, stripped down to: 10148
if not modules then modules={} end modules ['l-file']={
version=1.001,
@@ -4242,40 +4388,45 @@ local reslasher=lpeg.replacer(P("\\"),"/")
function file.reslash(str)
return str and lpegmatch(reslasher,str)
end
-function file.is_writable(name)
- if not name then
- elseif lfs.isdir(name) then
- name=name.."/m_t_x_t_e_s_t.tmp"
- local f=io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f=io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f=io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+ file.is_readable=lfs.isreadablefile
+ file.is_writable=lfs.iswritablefile
+else
+ function file.is_writable(name)
+ if not name then
+ elseif lfs.isdir(name) then
+ name=name.."/m_t_x_t_e_s_t.tmp"
+ local f=io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
- end
- return false
-end
-local readable=P("r")*Cc(true)
-function file.is_readable(name)
- if name then
- local a=attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
return false
end
+ local readable=P("r")*Cc(true)
+ function file.is_readable(name)
+ if name then
+ local a=attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
+ end
end
file.isreadable=file.is_readable
file.iswritable=file.is_writable
@@ -4906,7 +5057,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 18002, stripped down to: 10681
+-- original size: 18253, stripped down to: 10816
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -4971,13 +5122,15 @@ local function glob_pattern_function(path,patt,recurse,action)
end
local dirs
local nofdirs=0
- for name in walkdir(usedpath) do
+ for name,mode,size,time in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
- action(full)
+ action(full,size,time)
end
elseif recurse and mode=="directory" then
if dirs then
@@ -5013,10 +5166,12 @@ local function glob_pattern_table(path,patt,recurse,result)
local dirs
local nofdirs=0
local noffiles=#result
- for name,a in walkdir(usedpath) do
+ for name,mode in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
noffiles=noffiles+1
@@ -5067,7 +5222,7 @@ local function collectpattern(path,patt,recurse,result)
if not find(path,"/$") then
path=path..'/'
end
- for name in scanner,first do
+ for name in scanner,first do
if name=="." then
elseif name==".." then
else
@@ -5158,10 +5313,12 @@ local function globfiles(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if recurse then
globfiles(path.."/"..name,recurse,func,files)
@@ -5184,10 +5341,12 @@ local function globdirs(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if not func or func(name) then
noffiles=noffiles+1
@@ -5368,8 +5527,7 @@ local stack={}
function dir.push(newdir)
local curdir=currentdir()
insert(stack,curdir)
- if newdir and newdir~="" then
- chdir(newdir)
+ if newdir and newdir~="" and chdir(newdir) then
return newdir
else
return curdir
@@ -6310,7 +6468,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 43539, stripped down to: 21641
+-- original size: 44146, stripped down to: 22098
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6326,7 +6484,6 @@ local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,s
local load,dump=load,string.dump
local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
local unpack,concat=table.unpack,table.concat
-local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
@@ -6665,8 +6822,8 @@ local environment={
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
formattedfloat=number.formattedfloat,
- stripzero=lpeg.patterns.stripzero,
- stripzeros=lpeg.patterns.stripzeros,
+ stripzero=patterns.stripzero,
+ stripzeros=patterns.stripzeros,
FORMAT=string.f9,
}
local arguments={ "a1" }
@@ -6753,7 +6910,7 @@ local format_F=function(f)
end
local format_k=function(b,a)
n=n+1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0,a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g=function(f)
n=n+1
@@ -7109,9 +7266,9 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+anything)^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=patterns.luaescape })
local dquote=patterns.dquote
local equote=patterns.escaped+dquote/'\\"'+1
local cquote=Cc('"')
@@ -7143,6 +7300,27 @@ local f_16_16=formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+if not string.explode then
+ local tsplitat=lpeg.tsplitat
+ local p_utf=patterns.utf8character
+ local p_check=C(p_utf)*(P("+")*Cc(true))^0
+ local p_split=Ct(C(p_utf)^0)
+ local p_space=Ct((C(1-P(" ")^1)+P(" ")^1)^0)
+ function string.explode(str,symbol)
+ if symbol=="" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a,b=lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+end
end -- of closure
@@ -7151,7 +7329,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 28756, stripped down to: 16104
+-- original size: 28866, stripped down to: 16134
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7173,7 +7351,8 @@ local formatters=string.formatters
local utftoeight=utf.toeight
local splitter=lpeg.tsplitat(".")
function utilities.tables.definetable(target,nofirst,nolast)
- local composed,t=nil,{}
+ local composed=nil
+ local t={}
local snippets=lpegmatch(splitter,target)
for i=1,#snippets-(nolast and 1 or 0) do
local name=snippets[i]
@@ -7614,18 +7793,19 @@ local function serialize(root,name,specification)
end
if root and next(root)~=nil then
local first=nil
- local last=0
- last=#root
- for k=1,last do
- if rawget(root,k)==nil then
- last=k-1
- break
- end
- end
+ local last=#root
if last>0 then
- first=1
+ for k=1,last do
+ if rawget(root,k)==nil then
+ last=k-1
+ break
+ end
+ end
+ if last>0 then
+ first=1
+ end
end
- local sk=sortedkeys(root)
+ local sk=sortedkeys(root)
for i=1,#sk do
local k=sk[i]
local v=root[k]
@@ -7813,7 +7993,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fil"] = package.loaded["util-fil"] or true
--- original size: 8607, stripped down to: 6727
+-- original size: 11530, stripped down to: 9007
if not modules then modules={} end modules ['util-fil']={
version=1.001,
@@ -8022,6 +8202,32 @@ if bit32 then
local b=char(n%256)
f:write(b,a)
end
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
else
local floor=math.floor
function files.writecardinal2(f,n)
@@ -8030,16 +8236,32 @@ else
local b=char(n%256)
f:write(b,a)
end
-end
-function files.writecardinal4(f,n)
- local a=char(n%256)
- n=rshift(n,8)
- local b=char(n%256)
- n=rshift(n,8)
- local c=char(n%256)
- n=rshift(n,8)
- local d=char(n%256)
- f:write(d,c,b,a)
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
end
function files.writestring(f,s)
f:write(char(byte(s,1,#s)))
@@ -8052,10 +8274,18 @@ if fio and fio.readcardinal1 then
files.readcardinal2=fio.readcardinal2
files.readcardinal3=fio.readcardinal3
files.readcardinal4=fio.readcardinal4
+ files.readcardinal1le=fio.readcardinal1le or files.readcardinal1le
+ files.readcardinal2le=fio.readcardinal2le or files.readcardinal2le
+ files.readcardinal3le=fio.readcardinal3le or files.readcardinal3le
+ files.readcardinal4le=fio.readcardinal4le or files.readcardinal4le
files.readinteger1=fio.readinteger1
files.readinteger2=fio.readinteger2
files.readinteger3=fio.readinteger3
files.readinteger4=fio.readinteger4
+ files.readinteger1le=fio.readinteger1le or files.readinteger1le
+ files.readinteger2le=fio.readinteger2le or files.readinteger2le
+ files.readinteger3le=fio.readinteger3le or files.readinteger3le
+ files.readinteger4le=fio.readinteger4le or files.readinteger4le
files.readfixed2=fio.readfixed2
files.readfixed4=fio.readfixed4
files.read2dot14=fio.read2dot14
@@ -8076,6 +8306,24 @@ if fio and fio.readcardinal1 then
skipposition(f,4*(n or 1))
end
end
+if fio and fio.writecardinal1 then
+ files.writecardinal1=fio.writecardinal1
+ files.writecardinal2=fio.writecardinal2
+ files.writecardinal3=fio.writecardinal3
+ files.writecardinal4=fio.writecardinal4
+ files.writecardinal1le=fio.writecardinal1le
+ files.writecardinal2le=fio.writecardinal2le
+ files.writecardinal3le=fio.writecardinal3le
+ files.writecardinal4le=fio.writecardinal4le
+ files.writeinteger1=fio.writeinteger1 or fio.writecardinal1
+ files.writeinteger2=fio.writeinteger2 or fio.writecardinal2
+ files.writeinteger3=fio.writeinteger3 or fio.writecardinal3
+ files.writeinteger4=fio.writeinteger4 or fio.writecardinal4
+ files.writeinteger1le=files.writeinteger1le or fio.writecardinal1le
+ files.writeinteger2le=files.writeinteger2le or fio.writecardinal2le
+ files.writeinteger3le=files.writeinteger3le or fio.writecardinal3le
+ files.writeinteger4le=files.writeinteger4le or fio.writecardinal4le
+end
if fio and fio.readcardinaltable then
files.readcardinaltable=fio.readcardinaltable
files.readintegertable=fio.readintegertable
@@ -8113,7 +8361,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 11065, stripped down to: 8209
+-- original size: 11332, stripped down to: 8420
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -8138,6 +8386,11 @@ function streams.openstring(f,zerobased)
return { f,1,#f,zerobased or false }
end
end
+function streams.getstring(f)
+ if f then
+ return f[1]
+ end
+end
function streams.close()
end
function streams.size(f)
@@ -8228,7 +8481,7 @@ function streams.readcardinal2(f)
local a,b=byte(f[1],i,j)
return 0x100*a+b
end
-function streams.readcardinal2LE(f)
+function streams.readcardinal2le(f)
local i=f[2]
local j=i+1
f[2]=j+1
@@ -8300,6 +8553,13 @@ function streams.readcardinal4(f)
local a,b,c,d=byte(f[1],i,j)
return 0x1000000*a+0x10000*b+0x100*c+d
end
+function streams.readcardinal4le(f)
+ local i=f[2]
+ local j=i+3
+ f[2]=j+1
+ local d,c,b,a=byte(f[1],i,j)
+ return 0x1000000*a+0x10000*b+0x100*c+d
+end
function streams.readinteger4(f)
local i=f[2]
local j=i+3
@@ -8699,7 +8959,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 23400, stripped down to: 15802
+-- original size: 24132, stripped down to: 16210
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -8724,7 +8984,7 @@ local sortedhash=table.sortedhash
local sortedkeys=table.sortedkeys
local tohash=table.tohash
local hashes={}
-utilities.parsers.hashes=hashes
+parsers.hashes=hashes
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -8944,7 +9204,9 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,sortedkeys(h)
+ local t={}
+ local tn=0
+ local s=sortedkeys(h)
omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
@@ -8982,7 +9244,7 @@ function parsers.array_to_string(a,separator)
end
end
local pattern=Cf(Ct("")*Cg(C((1-S(", "))^1)*S(", ")^0*Cc(true))^1,rawset)
-function utilities.parsers.settings_to_set(str)
+function parsers.settings_to_set(str)
return str and lpegmatch(pattern,str) or {}
end
hashes.settings_to_set=table.setmetatableindex(function(t,k)
@@ -8992,7 +9254,8 @@ hashes.settings_to_set=table.setmetatableindex(function(t,k)
end)
getmetatable(hashes.settings_to_set).__mode="kv"
function parsers.simple_hash_to_string(h,separator)
- local t,tn={},0
+ local t={}
+ local tn=0
for k,v in sortedhash(h) do
if v then
tn=tn+1
@@ -9004,11 +9267,11 @@ end
local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1)
local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
local splitter=setting^1
-function utilities.parsers.options_to_hash(str,target)
+function parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or {}) or {}
end
local splitter=lpeg.tsplitat(" ")
-function utilities.parsers.options_to_array(str)
+function parsers.options_to_array(str)
return str and lpegmatch(splitter,str) or {}
end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
@@ -9021,7 +9284,8 @@ local function repeater(n,str)
if n==1 then
return unpack(s)
else
- local t,tn={},0
+ local t={}
+ local tn=0
for i=1,n do
for j=1,#s do
tn=tn+1
@@ -9192,7 +9456,7 @@ setmetatableindex(cache,function(t,k)
return pattern
end)
local commalistiterator=cache[","]
-function utilities.parsers.iterator(str,separator)
+function parsers.iterator(str,separator)
local n=#str
if n==0 then
return dummy
@@ -9234,10 +9498,10 @@ end
local name=C((1-S(", "))^1)
local parser=(Carg(1)*name/initialize)*(S(", ")^1*(Carg(1)*name/fetch))^0
local merge=Cf(parser,process)
-function utilities.parsers.mergehashes(hash,list)
+function parsers.mergehashes(hash,list)
return lpegmatch(merge,list,1,hash)
end
-function utilities.parsers.runtime(time)
+function parsers.runtime(time)
if not time then
time=os.runtime()
end
@@ -9254,13 +9518,24 @@ local apply=P("->")
local method=C((1-apply)^1)
local token=lbrace*C((1-rbrace)^1)*rbrace+C(anything^1)
local pattern=spacing*(method*spacing*apply+Carg(1))*spacing*token
-function utilities.parsers.splitmethod(str,default)
+function parsers.splitmethod(str,default)
if str then
return lpegmatch(pattern,str,1,default or false)
else
return default or false,""
end
end
+local p_year=lpegpatterns.digit^4/tonumber
+local pattern=Cf(Ct("")*(
+ (Cg(Cc("year")*p_year)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("day")*cardinal)
+ )+(Cg(Cc("day")*cardinal)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("year")*p_year)
+ )
+ )*P(" ")*Cg(Cc("hour")*cardinal)*P(":")*Cg(Cc("min")*cardinal)*(P(":")*Cg(Cc("sec")*cardinal))^-1
+,rawset)
+lpegpatterns.splittime=pattern
+function parsers.totime(str)
+ return lpegmatch(pattern,str)
+end
end -- of closure
@@ -9269,7 +9544,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fmt"] = package.loaded["util-fmt"] or true
--- original size: 2274, stripped down to: 1607
+-- original size: 2541, stripped down to: 1624
if not modules then modules={} end modules ['util-fmt']={
version=1.001,
@@ -9305,8 +9580,8 @@ function formatters.formatcolumns(result,between)
local tj=type(rj)
if tj=="number" then
numbers[j]=true
- end
- if tj~="string" then
+ rj=tostring(rj)
+ elseif tj~="string" then
rj=tostring(rj)
r[j]=rj
end
@@ -9372,13 +9647,13 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-socket"] = package.loaded["util-soc-imp-socket"] or true
--- original size: 4870, stripped down to: 3527
+-- original size: 4905, stripped down to: 3562
local type,tostring,setmetatable=type,tostring,setmetatable
local min=math.min
local format=string.format
-local socket=require("socket.core")
+local socket=socket or package.loaded.socket or require("socket.core")
local connect=socket.connect
local tcp4=socket.tcp4
local tcp6=socket.tcp6
@@ -9548,7 +9823,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-copas"] = package.loaded["util-soc-imp-copas"] or true
--- original size: 25844, stripped down to: 14821
+-- original size: 25959, stripped down to: 14893
local socket=socket or require("socket")
@@ -9585,6 +9860,7 @@ local copas={
autoclose=true,
running=false,
report=report,
+ trace=false,
}
local function statushandler(status,...)
if status then
@@ -9594,7 +9870,9 @@ local function statushandler(status,...)
if type(err)=="table" then
err=err[1]
end
- report("error: %s",tostring(err))
+ if copas.trace then
+ report("error: %s",tostring(err))
+ end
return nil,err
end
function socket.protect(func)
@@ -9608,7 +9886,9 @@ function socket.newtry(finalizer)
if not status then
local detail=select(2,...)
pcall(finalizer,detail)
- report("error: %s",tostring(detail))
+ if copas.trace then
+ report("error: %s",tostring(detail))
+ end
return
end
return...
@@ -10561,12 +10841,12 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-mime"] = package.loaded["util-soc-imp-mime"] or true
--- original size: 2328, stripped down to: 1874
+-- original size: 2373, stripped down to: 1931
local type,tostring=type,tostring
-local mime=require("mime.core")
-local ltn12=ltn12 or require("ltn12")
+local mime=mime or package.loaded.mime or require("mime.core")
+local ltn12=ltn12 or package.loaded.ltn12 or require("ltn12")
local filtercycle=ltn12.filter.cycle
local function report(fmt,first,...)
if logs then
@@ -12518,7 +12798,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32608, stripped down to: 20925
+-- original size: 32618, stripped down to: 20935
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -12563,7 +12843,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if runningtex then
+if runningtex and texio then
if texio.setescape then
texio.setescape(0)
end
@@ -13399,7 +13679,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 9072, stripped down to: 6055
+-- original size: 8966, stripped down to: 5972
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -13546,13 +13826,11 @@ function statistics.show()
end
register("lua properties",function()
local hashchar=tonumber(status.luatex_hashchars)
- local hashtype=status.luatex_hashtype
local mask=lua.mask or "ascii"
- return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
+ return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
jit and "luajit" or "lua",
LUAVERSION,
statistics.memused(),
- hashtype or "default",
hashchar and 2^hashchar or "unknown",
mask,
mask=="utf" and "τεχ" or "tex")
@@ -13935,7 +14213,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-deb"] = package.loaded["util-deb"] or true
--- original size: 9955, stripped down to: 6693
+-- original size: 10136, stripped down to: 6832
if not modules then modules={} end modules ['util-deb']={
version=1.001,
@@ -13959,7 +14237,13 @@ local dummycalls=10*1000
local nesting=0
local names={}
local initialize=false
-if not (FFISUPPORTED and ffi) then
+if lua.getpreciseticks then
+ initialize=function()
+ ticks=lua.getpreciseticks
+ seconds=lua.getpreciseseconds
+ initialize=false
+ end
+elseif not (FFISUPPORTED and ffi) then
elseif os.type=="windows" then
initialize=function()
local kernel=ffilib("kernel32","system")
@@ -15062,7 +15346,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-env"] = package.loaded["util-env"] or true
--- original size: 9517, stripped down to: 5360
+-- original size: 9738, stripped down to: 5531
if not modules then modules={} end modules ['util-env']={
version=1.001,
@@ -15136,8 +15420,11 @@ environment.arguments=allocate()
environment.files=allocate()
environment.sortedflags=nil
function environment.initializearguments(arg)
- local arguments,files={},{}
- environment.arguments,environment.files,environment.sortedflags=arguments,files,nil
+ local arguments={}
+ local files={}
+ environment.arguments=arguments
+ environment.files=files
+ environment.sortedflags=nil
for index=1,#arg do
local argument=arg[index]
if index>0 then
@@ -15156,6 +15443,11 @@ function environment.initializearguments(arg)
end
end
end
+ if not environment.ownname then
+ if os.selfpath and os.selfname then
+ environment.ownname=file.addsuffix(file.join(os.selfpath,os.selfname),"lua")
+ end
+ end
environment.ownname=file.reslash(environment.ownname or arg[0] or 'unknown.lua')
end
function environment.setargument(name,value)
@@ -15434,6 +15726,468 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-zip"] = package.loaded["util-zip"] or true
+
+-- original size: 18645, stripped down to: 11291
+
+if not modules then modules={} end modules ['util-zip']={
+ version=1.001,
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tostring,tonumber=type,tostring,tonumber
+local sort=table.sort
+local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub
+local osdate,ostime=os.date,os.time
+local ioopen=io.open
+local loaddata,savedata=io.loaddata,io.savedata
+local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs
+local files=utilities.files
+local openfile=files.open
+local closefile=files.close
+local readstring=files.readstring
+local readcardinal2=files.readcardinal2le
+local readcardinal4=files.readcardinal4le
+local setposition=files.setposition
+local getposition=files.getposition
+local band=bit32.band
+local rshift=bit32.rshift
+local lshift=bit32.lshift
+local decompress,calculatecrc
+if flate then
+ decompress=flate.flate_decompress
+ calculatecrc=flate.update_crc32
+else
+ local zlibdecompress=zlib.decompress
+ local zlibchecksum=zlib.crc32
+ decompress=function(source,targetsize)
+ local target=zlibdecompress(source,-15)
+ if target then
+ return target
+ else
+ return false,1
+ end
+ end
+ calculatecrc=function(buffer,initial)
+ return zlibchecksum(initial or 0,buffer)
+ end
+end
+local zipfiles={}
+utilities.zipfiles=zipfiles
+local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
+ function openzipfile(name)
+ return {
+ name=name,
+ handle=openfile(name,0),
+ }
+ end
+ local function collect(z)
+ if not z.list then
+ local list={}
+ local hash={}
+ local position=0
+ local index=0
+ local handle=z.handle
+ while true do
+ setposition(handle,position)
+ local signature=readstring(handle,4)
+ if signature=="PK\3\4" then
+ local version=readcardinal2(handle)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ local filetime=readcardinal2(handle)
+ local filedate=readcardinal2(handle)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local filename=readstring(handle,namelength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ local skipped=0
+ local size=0
+ if encrypted then
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ end
+ position=position+30+namelength+extralength+skipped
+ if descriptor then
+ setposition(handle,position+compressed)
+ crc32=readcardinal4(handle)
+ compressed=readcardinal4(handle)
+ uncompressed=readcardinal4(handle)
+ end
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=position,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ }
+ hash[filename]=data
+ list[index]=data
+ else
+ end
+ position=position+compressed
+ else
+ break
+ end
+ z.list=list
+ z.hash=hash
+ end
+ end
+ end
+ function getziplist(z)
+ local list=z.list
+ if not list then
+ collect(z)
+ end
+ return z.list
+ end
+ function getziphash(z)
+ local hash=z.hash
+ if not hash then
+ collect(z)
+ end
+ return z.hash
+ end
+ function foundzipfile(z,name)
+ return getziphash(z)[name]
+ end
+ function closezipfile(z)
+ local f=z.handle
+ if f then
+ closefile(f)
+ z.handle=nil
+ end
+ end
+ function unzipfile(z,filename,check)
+ local hash=z.hash
+ if not hash then
+ hash=zipfiles.hash(z)
+ end
+ local data=hash[filename]
+ if not data then
+ end
+ if data then
+ local handle=z.handle
+ local position=data.position
+ local compressed=data.compressed
+ if compressed>0 then
+ setposition(handle,position)
+ local result=readstring(handle,compressed)
+ if data.method==8 then
+ result=decompress(result,data.uncompressed)
+ end
+ if check and data.crc32~=calculatecrc(result) then
+ print("checksum mismatch")
+ return ""
+ end
+ return result
+ else
+ return ""
+ end
+ end
+ end
+ zipfiles.open=openzipfile
+ zipfiles.close=closezipfile
+ zipfiles.unzip=unzipfile
+ zipfiles.hash=getziphash
+ zipfiles.list=getziplist
+ zipfiles.found=foundzipfile
+end
+if flate then do
+ local writecardinal1=files.writebyte
+ local writecardinal2=files.writecardinal2le
+ local writecardinal4=files.writecardinal4le
+ local logwriter=logs.writer
+ local globpattern=dir.globpattern
+ local compress=flate.flate_compress
+ local checksum=flate.update_crc32
+ local function fromdostime(dostime,dosdate)
+ return ostime {
+ year=rshift(dosdate,9)+1980,
+ month=band(rshift(dosdate,5),0x0F),
+ day=band((dosdate ),0x1F),
+ hour=band(rshift(dostime,11) ),
+ min=band(rshift(dostime,5),0x3F),
+ sec=band((dostime ),0x1F),
+ }
+ end
+ local function todostime(time)
+ local t=osdate("*t",time)
+ return
+ lshift(t.year-1980,9)+lshift(t.month,5)+t.day,
+ lshift(t.hour,11)+lshift(t.min,5)+rshift(t.sec,1)
+ end
+ local function openzip(filename,level,comment,verbose)
+ local f=ioopen(filename,"wb")
+ if f then
+ return {
+ filename=filename,
+ handle=f,
+ list={},
+ level=tonumber(level) or 3,
+ comment=tostring(comment),
+ verbose=verbose,
+ uncompressed=0,
+ compressed=0,
+ }
+ end
+ end
+ local function writezip(z,name,data,level,time)
+ local f=z.handle
+ local list=z.list
+ local level=tonumber(level) or z.level or 3
+ local method=8
+ local zipped=compress(data,level)
+ local checksum=checksum(data)
+ local verbose=z.verbose
+ if not zipped then
+ method=0
+ zipped=data
+ end
+ local start=f:seek()
+ local compressed=#zipped
+ local uncompressed=#data
+ z.compressed=z.compressed+compressed
+ z.uncompressed=z.uncompressed+uncompressed
+ if verbose then
+ local pct=100*compressed/uncompressed
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,name))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,name))
+ end
+ end
+ f:write("\x50\x4b\x03\x04")
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,method)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ f:write(name)
+ f:write(zipped)
+ list[#list+1]={ #zipped,#data,name,checksum,start,time or 0 }
+ end
+ local function closezip(z)
+ local f=z.handle
+ local list=z.list
+ local comment=z.comment
+ local verbose=z.verbose
+ local count=#list
+ local start=f:seek()
+ for i=1,count do
+ local l=list[i]
+ local compressed=l[1]
+ local uncompressed=l[2]
+ local name=l[3]
+ local checksum=l[4]
+ local start=l[5]
+ local time=l[6]
+ local date,time=todostime(time)
+ f:write('\x50\x4b\x01\x02')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,8)
+ writecardinal2(f,time)
+ writecardinal2(f,date)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,0)
+ writecardinal4(f,start)
+ f:write(name)
+ end
+ local stop=f:seek()
+ local size=stop-start
+ f:write('\x50\x4b\x05\x06')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,count)
+ writecardinal2(f,count)
+ writecardinal4(f,size)
+ writecardinal4(f,start)
+ if type(comment)=="string" and comment~="" then
+ writecardinal2(f,#comment)
+ f:write(comment)
+ else
+ writecardinal2(f,0)
+ end
+ if verbose then
+ local compressed=z.compressed
+ local uncompressed=z.uncompressed
+ local filename=z.filename
+ local pct=100*compressed/uncompressed
+ logwriter("")
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,filename))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,filename))
+ end
+ end
+ f:close()
+ end
+ local function zipdir(zipname,path,level,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ level=zipname.level
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ if not isdir(path) then
+ return
+ end
+ path=gsub(path,"\\+","/")
+ path=gsub(path,"/+","/")
+ local list={}
+ local count=0
+ globpattern(path,"",true,function(name,size,time)
+ count=count+1
+ list[count]={ name,time }
+ end)
+ sort(list,function(a,b)
+ return a[1]<b[1]
+ end)
+ local zipf=openzip(zipname,level,comment,verbose)
+ if zipf then
+ local p=#path+2
+ for i=1,count do
+ local li=list[i]
+ local name=li[1]
+ local time=li[2]
+ local data=loaddata(name)
+ local name=sub(name,p,#name)
+ writezip(zipf,name,data,level,time,verbose)
+ end
+ closezip(zipf)
+ end
+ end
+ local function unzipdir(zipname,path,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ local z=openzipfile(zipname)
+ if z then
+ local list=getziplist(z)
+ if list then
+ local total=0
+ local count=#list
+ local step=number.idiv(count,10)
+ local done=0
+ for i=1,count do
+ local l=list[i]
+ local n=l.filename
+ local d=unzipfile(z,n)
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if verbose=="steps" then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes",i,count,total))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ end
+ end
+ if verbose=="steps" then
+ logwriter(format("%4i files of %4i done, %10i bytes",count,count,total))
+ end
+ closezipfile(z)
+ return true
+ else
+ closezipfile(z)
+ end
+ end
+ end
+ zipfiles.zipdir=zipdir
+ zipfiles.unzipdir=unzipdir
+end end
+if flate then
+ local streams=utilities.streams
+ local openfile=streams.open
+ local closestream=streams.close
+ local setposition=streams.setposition
+ local getsize=streams.size
+ local readcardinal4=streams.readcardinal4le
+ local getstring=streams.getstring
+ local decompress=flate.gz_decompress
+ function zipfiles.gunzipfile(filename)
+ local strm=openfile(filename)
+ if strm then
+ setposition(strm,getsize(strm)-4+1)
+ local size=readcardinal4(strm)
+ local data=decompress(getstring(strm),size)
+ closestream(strm)
+ return data
+ end
+ end
+elseif gzip then
+ local openfile=gzip.open
+ function zipfiles.gunzipfile(filename)
+ local g=openfile(filename,"rb")
+ if g then
+ local d=g:read("*a")
+ d:close()
+ return d
+ end
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true
-- original size: 60383, stripped down to: 35698
@@ -16892,7 +17646,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54551, stripped down to: 30745
+-- original size: 55145, stripped down to: 30992
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -16972,7 +17726,8 @@ apply_axis['self']=function(list)
return list
end
apply_axis['child']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local dt=ll.dt
@@ -17044,7 +17799,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
c=collect(list[l],collected,c)
end
@@ -17085,7 +17841,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
if ll.special~=true then
@@ -17097,7 +17854,8 @@ apply_axis['descendant-or-self']=function(list)
return collected
end
apply_axis['ancestor']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
while ll do
@@ -17111,7 +17869,8 @@ apply_axis['ancestor']=function(list)
return collected
end
apply_axis['ancestor-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
c=c+1
@@ -17127,7 +17886,8 @@ apply_axis['ancestor-or-self']=function(list)
return collected
end
apply_axis['parent']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local pl=list[l].__p__
if pl then
@@ -17150,7 +17910,8 @@ apply_axis['preceding']=function(list)
return {}
end
apply_axis['following-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17166,7 +17927,8 @@ apply_axis['following-sibling']=function(list)
return collected
end
apply_axis['preceding-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17182,7 +17944,8 @@ apply_axis['preceding-sibling']=function(list)
return collected
end
apply_axis['reverse-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17205,7 +17968,8 @@ apply_axis['initial-child']=apply_axis['child']
local function apply_nodes(list,directive,nodes)
local maxn=#nodes
if maxn==3 then
- local nns,ntg=nodes[2],nodes[3]
+ local nns=nodes[2]
+ local ntg=nodes[3]
if not nns and not ntg then
if directive then
return list
@@ -17213,7 +17977,10 @@ local function apply_nodes(list,directive,nodes)
return {}
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
if not nns then
for l=1,#list do
local ll=list[l]
@@ -17221,14 +17988,16 @@ local function apply_nodes(list,directive,nodes)
if ltg then
if directive then
if ntg==ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif ntg~=ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17239,14 +18008,16 @@ local function apply_nodes(list,directive,nodes)
if lns then
if directive then
if lns==nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif lns~=nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17259,14 +18030,16 @@ local function apply_nodes(list,directive,nodes)
local ok=ltg==ntg and lns==nns
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17274,7 +18047,10 @@ local function apply_nodes(list,directive,nodes)
return collected
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
for l=1,#list do
local ll=list[l]
local ltg=ll.tg
@@ -17282,7 +18058,8 @@ local function apply_nodes(list,directive,nodes)
local lns=ll.rn or ll.ns
local ok=false
for n=1,maxn,3 do
- local nns,ntg=nodes[n+1],nodes[n+2]
+ local nns=nodes[n+1]
+ local ntg=nodes[n+2]
ok=(not ntg or ltg==ntg) and (not nns or lns==nns)
if ok then
break
@@ -17290,14 +18067,16 @@ local function apply_nodes(list,directive,nodes)
end
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17306,7 +18085,8 @@ local function apply_nodes(list,directive,nodes)
end
local quit_expression=false
local function apply_expression(list,expression,order)
- local collected,c={},0
+ local collected={}
+ local c=0
quit_expression=false
for l=1,#list do
local ll=list[l]
@@ -17560,7 +18340,8 @@ local function tagstostring(list)
local t={}
for i=1,#list do
local li=list[i]
- local ns,tg=li.ns,li.tg
+ local ns=li.ns
+ local tg=li.tg
if not ns or ns=="" then ns="*" end
if not tg or tg=="" then tg="*" end
t[i]=(tg=="@rt@" and "[root]") or format("%s:%s",ns,tg)
@@ -17924,7 +18705,8 @@ expressions.name=function(e,n)
if n==0 then
found=type(e)=="table" and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17937,7 +18719,8 @@ expressions.name=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -17951,7 +18734,8 @@ expressions.name=function(e,n)
end
end
if found then
- local ns,tg=found.rn or found.ns or "",found.tg
+ local ns=found.rn or found.ns or ""
+ local tg=found.tg
if ns~="" then
return ns..":"..tg
else
@@ -17970,7 +18754,8 @@ expressions.tag=function(e,n)
if n==0 then
found=(type(e)=="table") and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17983,7 +18768,8 @@ expressions.tag=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -18163,7 +18949,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true
--- original size: 30650, stripped down to: 19621
+-- original size: 30771, stripped down to: 19680
if not modules then modules={} end modules ['lxml-aux']={
version=1.001,
@@ -18278,10 +19064,12 @@ end
function xml.collect_tags(root,pattern,nonamespace)
local collected=xmlapplylpath(root,pattern)
if collected then
- local t,n={},0
+ local t={}
+ local n=0
for c=1,#collected do
local e=collected[c]
- local ns,tg=e.ns,e.tg
+ local ns=e.ns
+ local tg=e.tg
n=n+1
if nonamespace then
t[n]=tg
@@ -18436,7 +19224,9 @@ local function inject_element(root,pattern,whatever,prepend)
local collected=element and xmlapplylpath(root,pattern)
local function inject_e(e)
local r=e.__p__
- local d,k,rri=r.dt,e.ni,r.ri
+ local d=r.dt
+ local k=e.ni
+ local rri=r.ri
local edt=(rri and d[rri].dt) or (d and d[k] and d[k].dt)
if edt then
local be,af
@@ -18473,7 +19263,8 @@ local function insert_element(root,pattern,whatever,before)
local collected=element and xmlapplylpath(root,pattern)
local function insert_e(e)
local r=e.__p__
- local d,k=r.dt,e.ni
+ local d=r.dt
+ local k=e.ni
if not before then
k=k+1
end
@@ -18903,8 +19694,10 @@ function xml.separate(x,pattern)
report_xml("warning: xml.separate changes root")
x=d
end
- local t,n={ "\n" },1
- local i,nd=1,#d
+ local t={ "\n" }
+ local n=1
+ local i=1
+ local nd=#d
while i<=nd do
while i<=nd do
local di=d[i]
@@ -19885,7 +20678,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-exp"] = package.loaded["data-exp"] or true
--- original size: 18105, stripped down to: 10389
+-- original size: 18154, stripped down to: 10416
if not modules then modules={} end modules ['data-exp']={
version=1.001,
@@ -20092,9 +20885,11 @@ local function scan(files,remap,spec,path,n,m,r,onlyone,tolerant)
local pattern=tolerant and lessweird or weird
local filelist={}
local noffiles=0
- for name in directory(full) do
+ for name,mode in directory(full) do
if not lpegmatch(pattern,name) then
- local mode=attributes(full..name,"mode")
+ if not mode then
+ mode=attributes(full..name,"mode")
+ end
if mode=="file" then
n=n+1
noffiles=noffiles+1
@@ -20575,7 +21370,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16116, stripped down to: 10782
+-- original size: 16284, stripped down to: 10938
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -20615,6 +21410,7 @@ caches.force=true
caches.ask=false
caches.relocate=false
caches.defaults={ "TMPDIR","TEMPDIR","TMP","TEMP","HOME","HOMEPATH" }
+directives.register("system.caches.fast",function(v) caches.fast=true end)
local writable,readables,usedreadables=nil,{},{}
local function identify()
local texmfcaches=resolvers.cleanpathlist("TEXMFCACHE")
@@ -20848,7 +21644,9 @@ local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
data.cache_uuid=os.uuid()
- if caches.direct then
+ if caches.fast then
+ file.savedata(tmaname,table.fastserialize(data,true))
+ elseif caches.direct then
file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
table.tofile(tmaname,data,true,saveoptions)
@@ -23182,7 +23980,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8700, stripped down to: 6313
+-- original size: 10263, stripped down to: 7556
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23201,6 +23999,65 @@ local archives=zip.archives or {}
zip.archives=archives
local registeredfiles=zip.registeredfiles or {}
zip.registeredfiles=registeredfiles
+local zipfiles=utilities.zipfiles
+local openzip,closezip,validfile,wholefile,filehandle,traversezip
+if zipfiles then
+ local ipairs=ipairs
+ openzip=zipfiles.open
+ closezip=zipfiles.close
+ validfile=zipfiles.found
+ wholefile=zipfiles.unzip
+ traversezip=function(zfile)
+ return ipairs(zipfiles.list(zfile))
+ end
+ local streams=utilities.streams
+ local openstream=streams.open
+ local readstring=streams.readstring
+ local streamsize=streams.size
+ local metatable={
+ close=streams.close,
+ read=function(stream,n)
+ readstring(stream,n=="*a" and streamsize(stream) or n)
+ end
+ }
+ filehandle=function(zfile,queryname)
+ local data=wholefile(zfile,queryname)
+ if data then
+ local stream=openstream(data)
+ if stream then
+ return setmetatableindex(stream,metatable)
+ end
+ end
+ end
+else
+ openzip=zip.open
+ closezip=zip.close
+ validfile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ dfile:close()
+ return true
+ end
+ return false
+ end
+ traversezip=function(zfile)
+ return z:files()
+ end
+ wholefile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ local s=dfile:read("*all")
+ dfile:close()
+ return s
+ end
+ end
+ filehandle=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ return dfile
+ end
+ end
+end
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23215,7 +24072,7 @@ function zip.openarchive(name)
local arch=archives[name]
if not arch then
local full=resolvers.findfile(name) or ""
- arch=full~="" and zip.open(full) or false
+ arch=full~="" and openzip(full) or false
archives[name]=arch
end
return arch
@@ -23223,7 +24080,7 @@ function zip.openarchive(name)
end
function zip.closearchive(name)
if not name or (name=="" and archives[name]) then
- zip.close(archives[name])
+ closezip(archives[name])
archives[name]=nil
end
end
@@ -23264,9 +24121,7 @@ function resolvers.finders.zip(specification)
if trace_locating then
report_zip("finder: archive %a found",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
- dfile:close()
+ if validfile(zfile,queryname) then
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -23296,12 +24151,12 @@ function resolvers.openers.zip(specification)
if trace_locating then
report_zip("opener; archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local handle=filehandle(zfile,queryname)
+ if handle then
if trace_locating then
report_zip("opener: file %a found",queryname)
end
- return resolvers.openers.helpers.textopener('zip',original,dfile)
+ return resolvers.openers.helpers.textopener('zip',original,handle)
elseif trace_locating then
report_zip("opener: file %a not found",queryname)
end
@@ -23327,15 +24182,13 @@ function resolvers.loaders.zip(specification)
if trace_locating then
report_zip("loader: archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local data=wholefile(zfile,queryname)
+ if data then
logs.show_load(original)
if trace_locating then
report_zip("loader; file %a loaded",original)
end
- local s=dfile:read("*all")
- dfile:close()
- return true,s,#s
+ return true,data,#data
elseif trace_locating then
report_zip("loader: file %a not found",queryname)
end
@@ -23382,7 +24235,7 @@ function resolvers.registerzipfile(z,tree)
if trace_locating then
report_zip("registering: using filter %a",filter)
end
- for i in z:files() do
+ for i in traversezip(z) do
local filename=i.filename
local path,name=match(filename,filter)
if not path then
@@ -23911,7 +24764,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-aux"] = package.loaded["data-aux"] or true
--- original size: 2438, stripped down to: 1863
+-- original size: 2452, stripped down to: 1877
if not modules then modules={} end modules ['data-aux']={
version=1.001,
@@ -23959,7 +24812,7 @@ function resolvers.updatescript(oldname,newname)
local newdata=io.loaddata(newscript)
if newdata then
if trace_locating then
- report_scripts("old script content replaced by new content")
+ report_scripts("old script content replaced by new content: %s",oldscript)
end
io.savedata(oldscript,newdata)
break
@@ -24516,7 +25369,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true
--- original size: 9346, stripped down to: 7085
+-- original size: 9637, stripped down to: 7253
if not modules then modules={} end modules ['luat-fmt']={
version=1.001,
@@ -24536,9 +25389,6 @@ local function primaryflags()
if arguments.silent then
flags[#flags+1]="--interaction=batchmode"
end
- if arguments.jit then
- flags[#flags+1]="--jiton"
- end
return concat(flags," ")
end
local function secondaryflags()
@@ -24567,6 +25417,9 @@ local function secondaryflags()
if arguments.strip then
flags[#flags+1]="--c:strip"
end
+ if arguments.lmtx then
+ flags[#flags+1]="--c:lmtx"
+ end
return concat(flags," ")
end
local template=[[--ini %primaryflags% --lua=%luafile% %texfile% %secondaryflags% %dump% %redirect%]]
@@ -24586,6 +25439,13 @@ local runners={
checkers=checkers,
reporter=report_format,
},
+ luametatex=sandbox.registerrunner {
+ name="make luametatex format",
+ program="luametatex",
+ template=template,
+ checkers=checkers,
+ reporter=report_format,
+ },
luajittex=sandbox.registerrunner {
name="make luajittex format",
program="luajittex",
@@ -24753,10 +25613,10 @@ end
end -- of closure
--- used libraries : 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 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 util-lib.lua luat-sta.lua luat-fmt.lua
+-- 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 util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 989477
--- stripped bytes : 393339
+-- original bytes : 1020503
+-- stripped bytes : 404014
-- end library merge
@@ -24779,6 +25639,7 @@ local owntree = environment and environment.ownpath or ownpath
local ownlibs = { -- order can be made better
+ 'l-bit32.lua',
'l-lua.lua',
'l-macro.lua',
'l-sandbox.lua',
@@ -24836,6 +25697,8 @@ local ownlibs = { -- order can be made better
'util-env.lua',
'luat-env.lua', -- can come before inf (as in mkiv)
+ 'util-zip.lua',
+
'lxml-tab.lua',
'lxml-lpt.lua',
-- 'lxml-ent.lua',
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 611f7c8dd..a79ffc029 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -61,9 +61,140 @@ if not modules then modules = { } end modules ['mtxrun'] = {
do -- create closure to overcome 200 locals limit
+package.loaded["l-bit32"] = package.loaded["l-bit32"] or true
+
+-- original size: 3607, stripped down to: 3009
+
+if not modules then modules={} end modules ['l-bit32']={
+ version=1.001,
+ license="the same as regular Lua",
+ source="bitwise.lua, v 1.24 2014/12/26 17:20:53 roberto",
+ comment="drop-in for bit32, adapted a bit by Hans Hagen",
+}
+if bit32 then
+elseif utf8 then
+ load ([[
+local select = select -- instead of: arg = { ... }
+bit32 = {
+ bnot = function (a)
+ return ~a & 0xFFFFFFFF
+ end,
+ band = function (x, y, z, ...)
+ if not z then
+ return ((x or -1) & (y or -1)) & 0xFFFFFFFF
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) | (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x | y | z
+ for i=1,select("#",...) do
+ res = res | select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bxor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x ~ y ~ z
+ for i=1,select("#",...) do
+ res = res ~ select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ btest = function (x, y, z, ...)
+ if not z then
+ return (((x or -1) & (y or -1)) & 0xFFFFFFFF) ~= 0
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return (res & 0xFFFFFFFF) ~= 0
+ end
+ end,
+ lshift = function (a, b)
+ return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF
+ end,
+ rshift = function (a, b)
+ return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF
+ end,
+ arshift = function (a, b)
+ a = a & 0xFFFFFFFF
+ if b <= 0 or (a & 0x80000000) == 0 then
+ return (a >> b) & 0xFFFFFFFF
+ else
+ return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF
+ end
+ end,
+ lrotate = function (a ,b)
+ b = b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ rrotate = function (a, b)
+ b = -b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ extract = function (a, f, w)
+ return (a >> f) & ~(-1 << (w or 1))
+ end,
+ replace = function (a, v, f, w)
+ local mask = ~(-1 << (w or 1))
+ return ((a & ~(mask << f)) | ((v & mask) << f)) & 0xFFFFFFFF
+ end,
+}
+ ]] ) ()
+elseif bit then
+ load ([[
+local band, bnot, rshift, lshift = bit.band, bit.bnot, bit.rshift, bit.lshift
+bit32 = {
+ arshift = bit.arshift,
+ band = band,
+ bnot = bnot,
+ bor = bit.bor,
+ bxor = bit.bxor,
+ btest = function(...)
+ return band(...) ~= 0
+ end,
+ extract = function(a,f,w)
+ return band(rshift(a,f),2^(w or 1)-1)
+ end,
+ lrotate = bit.rol,
+ lshift = lshift,
+ replace = function(a,v,f,w)
+ local mask = 2^(w or 1)-1
+ return band(a,bnot(lshift(mask,f)))+lshift(band(v,mask),f)
+ end,
+ rrotate = bit.ror,
+ rshift = rshift,
+}
+ ]] ) ()
+else
+ xpcall(function() local _,t=require("bit32") if t then bit32=t end return end,function() end)
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 6204, stripped down to: 2852
+-- original size: 6330, stripped down to: 2831
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -180,8 +311,7 @@ if not FFISUPPORTED then
elseif not ffi.number then
ffi.number=tonumber
end
-if not bit32 then
- bit32=require("l-bit32")
+if LUAVERSION>5.3 then
end
@@ -1962,7 +2092,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40960, stripped down to: 21348
+-- original size: 41332, stripped down to: 21508
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1973,7 +2103,7 @@ if not modules then modules={} end modules ['l-table']={
}
local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select
local table,string=table,string
-local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
+local concat,sort=table.concat,table.sort
local format,lower,dump=string.format,string.lower,string.dump
local getmetatable,setmetatable=getmetatable,setmetatable
local lpegmatch,patterns=lpeg.match,lpeg.patterns
@@ -1983,7 +2113,8 @@ function table.getn(t)
return t and #t
end
function table.strip(tab)
- local lst,l={},0
+ local lst={}
+ local l=0
for i=1,#tab do
local s=lpegmatch(stripper,tab[i]) or ""
if s=="" then
@@ -1996,7 +2127,8 @@ function table.strip(tab)
end
function table.keys(t)
if t then
- local keys,k={},0
+ local keys={}
+ local k=0
for key in next,t do
k=k+1
keys[k]=key
@@ -2027,27 +2159,30 @@ local function compare(a,b)
end
local function sortedkeys(tab)
if tab then
- local srt,category,s={},0,0
+ local srt={}
+ local category=0
+ local s=0
for key in next,tab do
s=s+1
srt[s]=key
- if category==3 then
- elseif category==1 then
- if type(key)~="string" then
- category=3
- end
- elseif category==2 then
- if type(key)~="number" then
- category=3
- end
- else
+ if category~=3 then
local tkey=type(key)
- if tkey=="string" then
- category=1
- elseif tkey=="number" then
- category=2
+ if category==1 then
+ if tkey~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if tkey~="number" then
+ category=3
+ end
else
- category=3
+ if tkey=="string" then
+ category=1
+ elseif tkey=="number" then
+ category=2
+ else
+ category=3
+ end
end
end
end
@@ -2064,7 +2199,8 @@ local function sortedkeys(tab)
end
local function sortedhashonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="string" then
s=s+1
@@ -2081,7 +2217,8 @@ local function sortedhashonly(tab)
end
local function sortedindexonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="number" then
s=s+1
@@ -2098,7 +2235,8 @@ local function sortedindexonly(tab)
end
local function sortedhashkeys(tab,cmp)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if key then
s=s+1
@@ -2174,7 +2312,9 @@ function table.prepend(t,list)
return t
end
function table.merge(t,...)
- t=t or {}
+ if not t then
+ t={}
+ end
for i=1,select("#",...) do
for k,v in next,(select(i,...)) do
t[k]=v
@@ -2203,7 +2343,8 @@ function table.imerge(t,...)
return t
end
function table.imerged(...)
- local tmp,ntmp={},0
+ local tmp={}
+ local ntmp=0
for i=1,select("#",...) do
local nst=select(i,...)
for j=1,#nst do
@@ -2235,7 +2376,9 @@ local function fastcopy(old,metatabletoo)
end
end
local function copy(t,tables)
- tables=tables or {}
+ if not tables then
+ tables={}
+ end
local tcopy={}
if not tables[t] then
tables[t]=tcopy
@@ -2282,7 +2425,8 @@ function table.tohash(t,value)
return h
end
function table.fromhash(t)
- local hsh,h={},0
+ local hsh={}
+ local h=0
for k,v in next,t do
if v then
h=h+1
@@ -2383,7 +2527,8 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
if root and next(root)~=nil then
- local first,last=nil,0
+ local first=nil
+ local last=0
if compact then
last=#root
for k=1,last do
@@ -2642,7 +2787,8 @@ local function serialize(_handle,root,name,specification)
handle("}")
end
function table.serialize(root,name,specification)
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
@@ -2656,13 +2802,15 @@ function table.tofile(filename,root,name,specification)
local f=io.open(filename,'w')
if f then
if maxtab>1 then
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
if n>maxtab then
f:write(concat(t,"\n"),"\n")
- t,n={},0
+ t={}
+ n=0
end
end
serialize(flush,root,name,specification)
@@ -2764,8 +2912,12 @@ local function are_equal(a,b,n,m)
if a==b then
return true
elseif a and b and #a==#b then
- n=n or 1
- m=m or #a
+ if not n then
+ n=1
+ end
+ if not m then
+ m=#a
+ end
for i=n,m do
local ai,bi=a[i],b[i]
if ai==bi then
@@ -2865,7 +3017,8 @@ function table.mirrored(t)
end
function table.reversed(t)
if t then
- local tt,tn={},#t
+ local tt={}
+ local tn=#t
if tn>0 then
local ttn=0
for i=tn,1,-1 do
@@ -2978,7 +3131,9 @@ function table.sorted(t,...)
end
function table.values(t,s)
if t then
- local values,keys,v={},{},0
+ local values={}
+ local keys={}
+ local v=0
for key,value in next,t do
if not keys[value] then
v=v+1
@@ -3610,7 +3765,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 19347, stripped down to: 10258
+-- original size: 18985, stripped down to: 10149
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -3775,17 +3930,8 @@ local launchers={
unix="xdg-open %s &> /dev/null &",
}
function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
-end
-if not os.times then
- function os.times()
- return {
- utime=os.gettimeofday(),
- stime=0,
- cutime=0,
- cstime=0,
- }
- end
+ local command=format(launchers[os.name] or launchers.unix,str)
+ execute(command)
end
local gettimeofday=os.gettimeofday or os.clock
os.gettimeofday=gettimeofday
@@ -4062,7 +4208,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-file"] = package.loaded["l-file"] or true
--- original size: 21804, stripped down to: 9980
+-- original size: 21984, stripped down to: 10148
if not modules then modules={} end modules ['l-file']={
version=1.001,
@@ -4242,40 +4388,45 @@ local reslasher=lpeg.replacer(P("\\"),"/")
function file.reslash(str)
return str and lpegmatch(reslasher,str)
end
-function file.is_writable(name)
- if not name then
- elseif lfs.isdir(name) then
- name=name.."/m_t_x_t_e_s_t.tmp"
- local f=io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f=io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f=io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+ file.is_readable=lfs.isreadablefile
+ file.is_writable=lfs.iswritablefile
+else
+ function file.is_writable(name)
+ if not name then
+ elseif lfs.isdir(name) then
+ name=name.."/m_t_x_t_e_s_t.tmp"
+ local f=io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
- end
- return false
-end
-local readable=P("r")*Cc(true)
-function file.is_readable(name)
- if name then
- local a=attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
return false
end
+ local readable=P("r")*Cc(true)
+ function file.is_readable(name)
+ if name then
+ local a=attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
+ end
end
file.isreadable=file.is_readable
file.iswritable=file.is_writable
@@ -4906,7 +5057,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 18002, stripped down to: 10681
+-- original size: 18253, stripped down to: 10816
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -4971,13 +5122,15 @@ local function glob_pattern_function(path,patt,recurse,action)
end
local dirs
local nofdirs=0
- for name in walkdir(usedpath) do
+ for name,mode,size,time in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
- action(full)
+ action(full,size,time)
end
elseif recurse and mode=="directory" then
if dirs then
@@ -5013,10 +5166,12 @@ local function glob_pattern_table(path,patt,recurse,result)
local dirs
local nofdirs=0
local noffiles=#result
- for name,a in walkdir(usedpath) do
+ for name,mode in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
noffiles=noffiles+1
@@ -5067,7 +5222,7 @@ local function collectpattern(path,patt,recurse,result)
if not find(path,"/$") then
path=path..'/'
end
- for name in scanner,first do
+ for name in scanner,first do
if name=="." then
elseif name==".." then
else
@@ -5158,10 +5313,12 @@ local function globfiles(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if recurse then
globfiles(path.."/"..name,recurse,func,files)
@@ -5184,10 +5341,12 @@ local function globdirs(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if not func or func(name) then
noffiles=noffiles+1
@@ -5368,8 +5527,7 @@ local stack={}
function dir.push(newdir)
local curdir=currentdir()
insert(stack,curdir)
- if newdir and newdir~="" then
- chdir(newdir)
+ if newdir and newdir~="" and chdir(newdir) then
return newdir
else
return curdir
@@ -6310,7 +6468,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 43539, stripped down to: 21641
+-- original size: 44146, stripped down to: 22098
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6326,7 +6484,6 @@ local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,s
local load,dump=load,string.dump
local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
local unpack,concat=table.unpack,table.concat
-local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
@@ -6665,8 +6822,8 @@ local environment={
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
formattedfloat=number.formattedfloat,
- stripzero=lpeg.patterns.stripzero,
- stripzeros=lpeg.patterns.stripzeros,
+ stripzero=patterns.stripzero,
+ stripzeros=patterns.stripzeros,
FORMAT=string.f9,
}
local arguments={ "a1" }
@@ -6753,7 +6910,7 @@ local format_F=function(f)
end
local format_k=function(b,a)
n=n+1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0,a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g=function(f)
n=n+1
@@ -7109,9 +7266,9 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+anything)^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=patterns.luaescape })
local dquote=patterns.dquote
local equote=patterns.escaped+dquote/'\\"'+1
local cquote=Cc('"')
@@ -7143,6 +7300,27 @@ local f_16_16=formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+if not string.explode then
+ local tsplitat=lpeg.tsplitat
+ local p_utf=patterns.utf8character
+ local p_check=C(p_utf)*(P("+")*Cc(true))^0
+ local p_split=Ct(C(p_utf)^0)
+ local p_space=Ct((C(1-P(" ")^1)+P(" ")^1)^0)
+ function string.explode(str,symbol)
+ if symbol=="" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a,b=lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+end
end -- of closure
@@ -7151,7 +7329,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 28756, stripped down to: 16104
+-- original size: 28866, stripped down to: 16134
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7173,7 +7351,8 @@ local formatters=string.formatters
local utftoeight=utf.toeight
local splitter=lpeg.tsplitat(".")
function utilities.tables.definetable(target,nofirst,nolast)
- local composed,t=nil,{}
+ local composed=nil
+ local t={}
local snippets=lpegmatch(splitter,target)
for i=1,#snippets-(nolast and 1 or 0) do
local name=snippets[i]
@@ -7614,18 +7793,19 @@ local function serialize(root,name,specification)
end
if root and next(root)~=nil then
local first=nil
- local last=0
- last=#root
- for k=1,last do
- if rawget(root,k)==nil then
- last=k-1
- break
- end
- end
+ local last=#root
if last>0 then
- first=1
+ for k=1,last do
+ if rawget(root,k)==nil then
+ last=k-1
+ break
+ end
+ end
+ if last>0 then
+ first=1
+ end
end
- local sk=sortedkeys(root)
+ local sk=sortedkeys(root)
for i=1,#sk do
local k=sk[i]
local v=root[k]
@@ -7813,7 +7993,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fil"] = package.loaded["util-fil"] or true
--- original size: 8607, stripped down to: 6727
+-- original size: 11530, stripped down to: 9007
if not modules then modules={} end modules ['util-fil']={
version=1.001,
@@ -8022,6 +8202,32 @@ if bit32 then
local b=char(n%256)
f:write(b,a)
end
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
else
local floor=math.floor
function files.writecardinal2(f,n)
@@ -8030,16 +8236,32 @@ else
local b=char(n%256)
f:write(b,a)
end
-end
-function files.writecardinal4(f,n)
- local a=char(n%256)
- n=rshift(n,8)
- local b=char(n%256)
- n=rshift(n,8)
- local c=char(n%256)
- n=rshift(n,8)
- local d=char(n%256)
- f:write(d,c,b,a)
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
end
function files.writestring(f,s)
f:write(char(byte(s,1,#s)))
@@ -8052,10 +8274,18 @@ if fio and fio.readcardinal1 then
files.readcardinal2=fio.readcardinal2
files.readcardinal3=fio.readcardinal3
files.readcardinal4=fio.readcardinal4
+ files.readcardinal1le=fio.readcardinal1le or files.readcardinal1le
+ files.readcardinal2le=fio.readcardinal2le or files.readcardinal2le
+ files.readcardinal3le=fio.readcardinal3le or files.readcardinal3le
+ files.readcardinal4le=fio.readcardinal4le or files.readcardinal4le
files.readinteger1=fio.readinteger1
files.readinteger2=fio.readinteger2
files.readinteger3=fio.readinteger3
files.readinteger4=fio.readinteger4
+ files.readinteger1le=fio.readinteger1le or files.readinteger1le
+ files.readinteger2le=fio.readinteger2le or files.readinteger2le
+ files.readinteger3le=fio.readinteger3le or files.readinteger3le
+ files.readinteger4le=fio.readinteger4le or files.readinteger4le
files.readfixed2=fio.readfixed2
files.readfixed4=fio.readfixed4
files.read2dot14=fio.read2dot14
@@ -8076,6 +8306,24 @@ if fio and fio.readcardinal1 then
skipposition(f,4*(n or 1))
end
end
+if fio and fio.writecardinal1 then
+ files.writecardinal1=fio.writecardinal1
+ files.writecardinal2=fio.writecardinal2
+ files.writecardinal3=fio.writecardinal3
+ files.writecardinal4=fio.writecardinal4
+ files.writecardinal1le=fio.writecardinal1le
+ files.writecardinal2le=fio.writecardinal2le
+ files.writecardinal3le=fio.writecardinal3le
+ files.writecardinal4le=fio.writecardinal4le
+ files.writeinteger1=fio.writeinteger1 or fio.writecardinal1
+ files.writeinteger2=fio.writeinteger2 or fio.writecardinal2
+ files.writeinteger3=fio.writeinteger3 or fio.writecardinal3
+ files.writeinteger4=fio.writeinteger4 or fio.writecardinal4
+ files.writeinteger1le=files.writeinteger1le or fio.writecardinal1le
+ files.writeinteger2le=files.writeinteger2le or fio.writecardinal2le
+ files.writeinteger3le=files.writeinteger3le or fio.writecardinal3le
+ files.writeinteger4le=files.writeinteger4le or fio.writecardinal4le
+end
if fio and fio.readcardinaltable then
files.readcardinaltable=fio.readcardinaltable
files.readintegertable=fio.readintegertable
@@ -8113,7 +8361,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 11065, stripped down to: 8209
+-- original size: 11332, stripped down to: 8420
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -8138,6 +8386,11 @@ function streams.openstring(f,zerobased)
return { f,1,#f,zerobased or false }
end
end
+function streams.getstring(f)
+ if f then
+ return f[1]
+ end
+end
function streams.close()
end
function streams.size(f)
@@ -8228,7 +8481,7 @@ function streams.readcardinal2(f)
local a,b=byte(f[1],i,j)
return 0x100*a+b
end
-function streams.readcardinal2LE(f)
+function streams.readcardinal2le(f)
local i=f[2]
local j=i+1
f[2]=j+1
@@ -8300,6 +8553,13 @@ function streams.readcardinal4(f)
local a,b,c,d=byte(f[1],i,j)
return 0x1000000*a+0x10000*b+0x100*c+d
end
+function streams.readcardinal4le(f)
+ local i=f[2]
+ local j=i+3
+ f[2]=j+1
+ local d,c,b,a=byte(f[1],i,j)
+ return 0x1000000*a+0x10000*b+0x100*c+d
+end
function streams.readinteger4(f)
local i=f[2]
local j=i+3
@@ -8699,7 +8959,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 23400, stripped down to: 15802
+-- original size: 24132, stripped down to: 16210
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -8724,7 +8984,7 @@ local sortedhash=table.sortedhash
local sortedkeys=table.sortedkeys
local tohash=table.tohash
local hashes={}
-utilities.parsers.hashes=hashes
+parsers.hashes=hashes
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -8944,7 +9204,9 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,sortedkeys(h)
+ local t={}
+ local tn=0
+ local s=sortedkeys(h)
omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
@@ -8982,7 +9244,7 @@ function parsers.array_to_string(a,separator)
end
end
local pattern=Cf(Ct("")*Cg(C((1-S(", "))^1)*S(", ")^0*Cc(true))^1,rawset)
-function utilities.parsers.settings_to_set(str)
+function parsers.settings_to_set(str)
return str and lpegmatch(pattern,str) or {}
end
hashes.settings_to_set=table.setmetatableindex(function(t,k)
@@ -8992,7 +9254,8 @@ hashes.settings_to_set=table.setmetatableindex(function(t,k)
end)
getmetatable(hashes.settings_to_set).__mode="kv"
function parsers.simple_hash_to_string(h,separator)
- local t,tn={},0
+ local t={}
+ local tn=0
for k,v in sortedhash(h) do
if v then
tn=tn+1
@@ -9004,11 +9267,11 @@ end
local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1)
local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
local splitter=setting^1
-function utilities.parsers.options_to_hash(str,target)
+function parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or {}) or {}
end
local splitter=lpeg.tsplitat(" ")
-function utilities.parsers.options_to_array(str)
+function parsers.options_to_array(str)
return str and lpegmatch(splitter,str) or {}
end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
@@ -9021,7 +9284,8 @@ local function repeater(n,str)
if n==1 then
return unpack(s)
else
- local t,tn={},0
+ local t={}
+ local tn=0
for i=1,n do
for j=1,#s do
tn=tn+1
@@ -9192,7 +9456,7 @@ setmetatableindex(cache,function(t,k)
return pattern
end)
local commalistiterator=cache[","]
-function utilities.parsers.iterator(str,separator)
+function parsers.iterator(str,separator)
local n=#str
if n==0 then
return dummy
@@ -9234,10 +9498,10 @@ end
local name=C((1-S(", "))^1)
local parser=(Carg(1)*name/initialize)*(S(", ")^1*(Carg(1)*name/fetch))^0
local merge=Cf(parser,process)
-function utilities.parsers.mergehashes(hash,list)
+function parsers.mergehashes(hash,list)
return lpegmatch(merge,list,1,hash)
end
-function utilities.parsers.runtime(time)
+function parsers.runtime(time)
if not time then
time=os.runtime()
end
@@ -9254,13 +9518,24 @@ local apply=P("->")
local method=C((1-apply)^1)
local token=lbrace*C((1-rbrace)^1)*rbrace+C(anything^1)
local pattern=spacing*(method*spacing*apply+Carg(1))*spacing*token
-function utilities.parsers.splitmethod(str,default)
+function parsers.splitmethod(str,default)
if str then
return lpegmatch(pattern,str,1,default or false)
else
return default or false,""
end
end
+local p_year=lpegpatterns.digit^4/tonumber
+local pattern=Cf(Ct("")*(
+ (Cg(Cc("year")*p_year)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("day")*cardinal)
+ )+(Cg(Cc("day")*cardinal)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("year")*p_year)
+ )
+ )*P(" ")*Cg(Cc("hour")*cardinal)*P(":")*Cg(Cc("min")*cardinal)*(P(":")*Cg(Cc("sec")*cardinal))^-1
+,rawset)
+lpegpatterns.splittime=pattern
+function parsers.totime(str)
+ return lpegmatch(pattern,str)
+end
end -- of closure
@@ -9269,7 +9544,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fmt"] = package.loaded["util-fmt"] or true
--- original size: 2274, stripped down to: 1607
+-- original size: 2541, stripped down to: 1624
if not modules then modules={} end modules ['util-fmt']={
version=1.001,
@@ -9305,8 +9580,8 @@ function formatters.formatcolumns(result,between)
local tj=type(rj)
if tj=="number" then
numbers[j]=true
- end
- if tj~="string" then
+ rj=tostring(rj)
+ elseif tj~="string" then
rj=tostring(rj)
r[j]=rj
end
@@ -9372,13 +9647,13 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-socket"] = package.loaded["util-soc-imp-socket"] or true
--- original size: 4870, stripped down to: 3527
+-- original size: 4905, stripped down to: 3562
local type,tostring,setmetatable=type,tostring,setmetatable
local min=math.min
local format=string.format
-local socket=require("socket.core")
+local socket=socket or package.loaded.socket or require("socket.core")
local connect=socket.connect
local tcp4=socket.tcp4
local tcp6=socket.tcp6
@@ -9548,7 +9823,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-copas"] = package.loaded["util-soc-imp-copas"] or true
--- original size: 25844, stripped down to: 14821
+-- original size: 25959, stripped down to: 14893
local socket=socket or require("socket")
@@ -9585,6 +9860,7 @@ local copas={
autoclose=true,
running=false,
report=report,
+ trace=false,
}
local function statushandler(status,...)
if status then
@@ -9594,7 +9870,9 @@ local function statushandler(status,...)
if type(err)=="table" then
err=err[1]
end
- report("error: %s",tostring(err))
+ if copas.trace then
+ report("error: %s",tostring(err))
+ end
return nil,err
end
function socket.protect(func)
@@ -9608,7 +9886,9 @@ function socket.newtry(finalizer)
if not status then
local detail=select(2,...)
pcall(finalizer,detail)
- report("error: %s",tostring(detail))
+ if copas.trace then
+ report("error: %s",tostring(detail))
+ end
return
end
return...
@@ -10561,12 +10841,12 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-mime"] = package.loaded["util-soc-imp-mime"] or true
--- original size: 2328, stripped down to: 1874
+-- original size: 2373, stripped down to: 1931
local type,tostring=type,tostring
-local mime=require("mime.core")
-local ltn12=ltn12 or require("ltn12")
+local mime=mime or package.loaded.mime or require("mime.core")
+local ltn12=ltn12 or package.loaded.ltn12 or require("ltn12")
local filtercycle=ltn12.filter.cycle
local function report(fmt,first,...)
if logs then
@@ -12518,7 +12798,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32608, stripped down to: 20925
+-- original size: 32618, stripped down to: 20935
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -12563,7 +12843,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if runningtex then
+if runningtex and texio then
if texio.setescape then
texio.setescape(0)
end
@@ -13399,7 +13679,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 9072, stripped down to: 6055
+-- original size: 8966, stripped down to: 5972
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -13546,13 +13826,11 @@ function statistics.show()
end
register("lua properties",function()
local hashchar=tonumber(status.luatex_hashchars)
- local hashtype=status.luatex_hashtype
local mask=lua.mask or "ascii"
- return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
+ return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
jit and "luajit" or "lua",
LUAVERSION,
statistics.memused(),
- hashtype or "default",
hashchar and 2^hashchar or "unknown",
mask,
mask=="utf" and "τεχ" or "tex")
@@ -13935,7 +14213,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-deb"] = package.loaded["util-deb"] or true
--- original size: 9955, stripped down to: 6693
+-- original size: 10136, stripped down to: 6832
if not modules then modules={} end modules ['util-deb']={
version=1.001,
@@ -13959,7 +14237,13 @@ local dummycalls=10*1000
local nesting=0
local names={}
local initialize=false
-if not (FFISUPPORTED and ffi) then
+if lua.getpreciseticks then
+ initialize=function()
+ ticks=lua.getpreciseticks
+ seconds=lua.getpreciseseconds
+ initialize=false
+ end
+elseif not (FFISUPPORTED and ffi) then
elseif os.type=="windows" then
initialize=function()
local kernel=ffilib("kernel32","system")
@@ -15062,7 +15346,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-env"] = package.loaded["util-env"] or true
--- original size: 9517, stripped down to: 5360
+-- original size: 9738, stripped down to: 5531
if not modules then modules={} end modules ['util-env']={
version=1.001,
@@ -15136,8 +15420,11 @@ environment.arguments=allocate()
environment.files=allocate()
environment.sortedflags=nil
function environment.initializearguments(arg)
- local arguments,files={},{}
- environment.arguments,environment.files,environment.sortedflags=arguments,files,nil
+ local arguments={}
+ local files={}
+ environment.arguments=arguments
+ environment.files=files
+ environment.sortedflags=nil
for index=1,#arg do
local argument=arg[index]
if index>0 then
@@ -15156,6 +15443,11 @@ function environment.initializearguments(arg)
end
end
end
+ if not environment.ownname then
+ if os.selfpath and os.selfname then
+ environment.ownname=file.addsuffix(file.join(os.selfpath,os.selfname),"lua")
+ end
+ end
environment.ownname=file.reslash(environment.ownname or arg[0] or 'unknown.lua')
end
function environment.setargument(name,value)
@@ -15434,6 +15726,468 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-zip"] = package.loaded["util-zip"] or true
+
+-- original size: 18645, stripped down to: 11291
+
+if not modules then modules={} end modules ['util-zip']={
+ version=1.001,
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tostring,tonumber=type,tostring,tonumber
+local sort=table.sort
+local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub
+local osdate,ostime=os.date,os.time
+local ioopen=io.open
+local loaddata,savedata=io.loaddata,io.savedata
+local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs
+local files=utilities.files
+local openfile=files.open
+local closefile=files.close
+local readstring=files.readstring
+local readcardinal2=files.readcardinal2le
+local readcardinal4=files.readcardinal4le
+local setposition=files.setposition
+local getposition=files.getposition
+local band=bit32.band
+local rshift=bit32.rshift
+local lshift=bit32.lshift
+local decompress,calculatecrc
+if flate then
+ decompress=flate.flate_decompress
+ calculatecrc=flate.update_crc32
+else
+ local zlibdecompress=zlib.decompress
+ local zlibchecksum=zlib.crc32
+ decompress=function(source,targetsize)
+ local target=zlibdecompress(source,-15)
+ if target then
+ return target
+ else
+ return false,1
+ end
+ end
+ calculatecrc=function(buffer,initial)
+ return zlibchecksum(initial or 0,buffer)
+ end
+end
+local zipfiles={}
+utilities.zipfiles=zipfiles
+local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
+ function openzipfile(name)
+ return {
+ name=name,
+ handle=openfile(name,0),
+ }
+ end
+ local function collect(z)
+ if not z.list then
+ local list={}
+ local hash={}
+ local position=0
+ local index=0
+ local handle=z.handle
+ while true do
+ setposition(handle,position)
+ local signature=readstring(handle,4)
+ if signature=="PK\3\4" then
+ local version=readcardinal2(handle)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ local filetime=readcardinal2(handle)
+ local filedate=readcardinal2(handle)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local filename=readstring(handle,namelength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ local skipped=0
+ local size=0
+ if encrypted then
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ end
+ position=position+30+namelength+extralength+skipped
+ if descriptor then
+ setposition(handle,position+compressed)
+ crc32=readcardinal4(handle)
+ compressed=readcardinal4(handle)
+ uncompressed=readcardinal4(handle)
+ end
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=position,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ }
+ hash[filename]=data
+ list[index]=data
+ else
+ end
+ position=position+compressed
+ else
+ break
+ end
+ z.list=list
+ z.hash=hash
+ end
+ end
+ end
+ function getziplist(z)
+ local list=z.list
+ if not list then
+ collect(z)
+ end
+ return z.list
+ end
+ function getziphash(z)
+ local hash=z.hash
+ if not hash then
+ collect(z)
+ end
+ return z.hash
+ end
+ function foundzipfile(z,name)
+ return getziphash(z)[name]
+ end
+ function closezipfile(z)
+ local f=z.handle
+ if f then
+ closefile(f)
+ z.handle=nil
+ end
+ end
+ function unzipfile(z,filename,check)
+ local hash=z.hash
+ if not hash then
+ hash=zipfiles.hash(z)
+ end
+ local data=hash[filename]
+ if not data then
+ end
+ if data then
+ local handle=z.handle
+ local position=data.position
+ local compressed=data.compressed
+ if compressed>0 then
+ setposition(handle,position)
+ local result=readstring(handle,compressed)
+ if data.method==8 then
+ result=decompress(result,data.uncompressed)
+ end
+ if check and data.crc32~=calculatecrc(result) then
+ print("checksum mismatch")
+ return ""
+ end
+ return result
+ else
+ return ""
+ end
+ end
+ end
+ zipfiles.open=openzipfile
+ zipfiles.close=closezipfile
+ zipfiles.unzip=unzipfile
+ zipfiles.hash=getziphash
+ zipfiles.list=getziplist
+ zipfiles.found=foundzipfile
+end
+if flate then do
+ local writecardinal1=files.writebyte
+ local writecardinal2=files.writecardinal2le
+ local writecardinal4=files.writecardinal4le
+ local logwriter=logs.writer
+ local globpattern=dir.globpattern
+ local compress=flate.flate_compress
+ local checksum=flate.update_crc32
+ local function fromdostime(dostime,dosdate)
+ return ostime {
+ year=rshift(dosdate,9)+1980,
+ month=band(rshift(dosdate,5),0x0F),
+ day=band((dosdate ),0x1F),
+ hour=band(rshift(dostime,11) ),
+ min=band(rshift(dostime,5),0x3F),
+ sec=band((dostime ),0x1F),
+ }
+ end
+ local function todostime(time)
+ local t=osdate("*t",time)
+ return
+ lshift(t.year-1980,9)+lshift(t.month,5)+t.day,
+ lshift(t.hour,11)+lshift(t.min,5)+rshift(t.sec,1)
+ end
+ local function openzip(filename,level,comment,verbose)
+ local f=ioopen(filename,"wb")
+ if f then
+ return {
+ filename=filename,
+ handle=f,
+ list={},
+ level=tonumber(level) or 3,
+ comment=tostring(comment),
+ verbose=verbose,
+ uncompressed=0,
+ compressed=0,
+ }
+ end
+ end
+ local function writezip(z,name,data,level,time)
+ local f=z.handle
+ local list=z.list
+ local level=tonumber(level) or z.level or 3
+ local method=8
+ local zipped=compress(data,level)
+ local checksum=checksum(data)
+ local verbose=z.verbose
+ if not zipped then
+ method=0
+ zipped=data
+ end
+ local start=f:seek()
+ local compressed=#zipped
+ local uncompressed=#data
+ z.compressed=z.compressed+compressed
+ z.uncompressed=z.uncompressed+uncompressed
+ if verbose then
+ local pct=100*compressed/uncompressed
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,name))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,name))
+ end
+ end
+ f:write("\x50\x4b\x03\x04")
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,method)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ f:write(name)
+ f:write(zipped)
+ list[#list+1]={ #zipped,#data,name,checksum,start,time or 0 }
+ end
+ local function closezip(z)
+ local f=z.handle
+ local list=z.list
+ local comment=z.comment
+ local verbose=z.verbose
+ local count=#list
+ local start=f:seek()
+ for i=1,count do
+ local l=list[i]
+ local compressed=l[1]
+ local uncompressed=l[2]
+ local name=l[3]
+ local checksum=l[4]
+ local start=l[5]
+ local time=l[6]
+ local date,time=todostime(time)
+ f:write('\x50\x4b\x01\x02')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,8)
+ writecardinal2(f,time)
+ writecardinal2(f,date)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,0)
+ writecardinal4(f,start)
+ f:write(name)
+ end
+ local stop=f:seek()
+ local size=stop-start
+ f:write('\x50\x4b\x05\x06')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,count)
+ writecardinal2(f,count)
+ writecardinal4(f,size)
+ writecardinal4(f,start)
+ if type(comment)=="string" and comment~="" then
+ writecardinal2(f,#comment)
+ f:write(comment)
+ else
+ writecardinal2(f,0)
+ end
+ if verbose then
+ local compressed=z.compressed
+ local uncompressed=z.uncompressed
+ local filename=z.filename
+ local pct=100*compressed/uncompressed
+ logwriter("")
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,filename))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,filename))
+ end
+ end
+ f:close()
+ end
+ local function zipdir(zipname,path,level,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ level=zipname.level
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ if not isdir(path) then
+ return
+ end
+ path=gsub(path,"\\+","/")
+ path=gsub(path,"/+","/")
+ local list={}
+ local count=0
+ globpattern(path,"",true,function(name,size,time)
+ count=count+1
+ list[count]={ name,time }
+ end)
+ sort(list,function(a,b)
+ return a[1]<b[1]
+ end)
+ local zipf=openzip(zipname,level,comment,verbose)
+ if zipf then
+ local p=#path+2
+ for i=1,count do
+ local li=list[i]
+ local name=li[1]
+ local time=li[2]
+ local data=loaddata(name)
+ local name=sub(name,p,#name)
+ writezip(zipf,name,data,level,time,verbose)
+ end
+ closezip(zipf)
+ end
+ end
+ local function unzipdir(zipname,path,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ local z=openzipfile(zipname)
+ if z then
+ local list=getziplist(z)
+ if list then
+ local total=0
+ local count=#list
+ local step=number.idiv(count,10)
+ local done=0
+ for i=1,count do
+ local l=list[i]
+ local n=l.filename
+ local d=unzipfile(z,n)
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if verbose=="steps" then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes",i,count,total))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ end
+ end
+ if verbose=="steps" then
+ logwriter(format("%4i files of %4i done, %10i bytes",count,count,total))
+ end
+ closezipfile(z)
+ return true
+ else
+ closezipfile(z)
+ end
+ end
+ end
+ zipfiles.zipdir=zipdir
+ zipfiles.unzipdir=unzipdir
+end end
+if flate then
+ local streams=utilities.streams
+ local openfile=streams.open
+ local closestream=streams.close
+ local setposition=streams.setposition
+ local getsize=streams.size
+ local readcardinal4=streams.readcardinal4le
+ local getstring=streams.getstring
+ local decompress=flate.gz_decompress
+ function zipfiles.gunzipfile(filename)
+ local strm=openfile(filename)
+ if strm then
+ setposition(strm,getsize(strm)-4+1)
+ local size=readcardinal4(strm)
+ local data=decompress(getstring(strm),size)
+ closestream(strm)
+ return data
+ end
+ end
+elseif gzip then
+ local openfile=gzip.open
+ function zipfiles.gunzipfile(filename)
+ local g=openfile(filename,"rb")
+ if g then
+ local d=g:read("*a")
+ d:close()
+ return d
+ end
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true
-- original size: 60383, stripped down to: 35698
@@ -16892,7 +17646,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54551, stripped down to: 30745
+-- original size: 55145, stripped down to: 30992
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -16972,7 +17726,8 @@ apply_axis['self']=function(list)
return list
end
apply_axis['child']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local dt=ll.dt
@@ -17044,7 +17799,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
c=collect(list[l],collected,c)
end
@@ -17085,7 +17841,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
if ll.special~=true then
@@ -17097,7 +17854,8 @@ apply_axis['descendant-or-self']=function(list)
return collected
end
apply_axis['ancestor']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
while ll do
@@ -17111,7 +17869,8 @@ apply_axis['ancestor']=function(list)
return collected
end
apply_axis['ancestor-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
c=c+1
@@ -17127,7 +17886,8 @@ apply_axis['ancestor-or-self']=function(list)
return collected
end
apply_axis['parent']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local pl=list[l].__p__
if pl then
@@ -17150,7 +17910,8 @@ apply_axis['preceding']=function(list)
return {}
end
apply_axis['following-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17166,7 +17927,8 @@ apply_axis['following-sibling']=function(list)
return collected
end
apply_axis['preceding-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17182,7 +17944,8 @@ apply_axis['preceding-sibling']=function(list)
return collected
end
apply_axis['reverse-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17205,7 +17968,8 @@ apply_axis['initial-child']=apply_axis['child']
local function apply_nodes(list,directive,nodes)
local maxn=#nodes
if maxn==3 then
- local nns,ntg=nodes[2],nodes[3]
+ local nns=nodes[2]
+ local ntg=nodes[3]
if not nns and not ntg then
if directive then
return list
@@ -17213,7 +17977,10 @@ local function apply_nodes(list,directive,nodes)
return {}
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
if not nns then
for l=1,#list do
local ll=list[l]
@@ -17221,14 +17988,16 @@ local function apply_nodes(list,directive,nodes)
if ltg then
if directive then
if ntg==ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif ntg~=ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17239,14 +18008,16 @@ local function apply_nodes(list,directive,nodes)
if lns then
if directive then
if lns==nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif lns~=nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17259,14 +18030,16 @@ local function apply_nodes(list,directive,nodes)
local ok=ltg==ntg and lns==nns
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17274,7 +18047,10 @@ local function apply_nodes(list,directive,nodes)
return collected
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
for l=1,#list do
local ll=list[l]
local ltg=ll.tg
@@ -17282,7 +18058,8 @@ local function apply_nodes(list,directive,nodes)
local lns=ll.rn or ll.ns
local ok=false
for n=1,maxn,3 do
- local nns,ntg=nodes[n+1],nodes[n+2]
+ local nns=nodes[n+1]
+ local ntg=nodes[n+2]
ok=(not ntg or ltg==ntg) and (not nns or lns==nns)
if ok then
break
@@ -17290,14 +18067,16 @@ local function apply_nodes(list,directive,nodes)
end
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17306,7 +18085,8 @@ local function apply_nodes(list,directive,nodes)
end
local quit_expression=false
local function apply_expression(list,expression,order)
- local collected,c={},0
+ local collected={}
+ local c=0
quit_expression=false
for l=1,#list do
local ll=list[l]
@@ -17560,7 +18340,8 @@ local function tagstostring(list)
local t={}
for i=1,#list do
local li=list[i]
- local ns,tg=li.ns,li.tg
+ local ns=li.ns
+ local tg=li.tg
if not ns or ns=="" then ns="*" end
if not tg or tg=="" then tg="*" end
t[i]=(tg=="@rt@" and "[root]") or format("%s:%s",ns,tg)
@@ -17924,7 +18705,8 @@ expressions.name=function(e,n)
if n==0 then
found=type(e)=="table" and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17937,7 +18719,8 @@ expressions.name=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -17951,7 +18734,8 @@ expressions.name=function(e,n)
end
end
if found then
- local ns,tg=found.rn or found.ns or "",found.tg
+ local ns=found.rn or found.ns or ""
+ local tg=found.tg
if ns~="" then
return ns..":"..tg
else
@@ -17970,7 +18754,8 @@ expressions.tag=function(e,n)
if n==0 then
found=(type(e)=="table") and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17983,7 +18768,8 @@ expressions.tag=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -18163,7 +18949,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true
--- original size: 30650, stripped down to: 19621
+-- original size: 30771, stripped down to: 19680
if not modules then modules={} end modules ['lxml-aux']={
version=1.001,
@@ -18278,10 +19064,12 @@ end
function xml.collect_tags(root,pattern,nonamespace)
local collected=xmlapplylpath(root,pattern)
if collected then
- local t,n={},0
+ local t={}
+ local n=0
for c=1,#collected do
local e=collected[c]
- local ns,tg=e.ns,e.tg
+ local ns=e.ns
+ local tg=e.tg
n=n+1
if nonamespace then
t[n]=tg
@@ -18436,7 +19224,9 @@ local function inject_element(root,pattern,whatever,prepend)
local collected=element and xmlapplylpath(root,pattern)
local function inject_e(e)
local r=e.__p__
- local d,k,rri=r.dt,e.ni,r.ri
+ local d=r.dt
+ local k=e.ni
+ local rri=r.ri
local edt=(rri and d[rri].dt) or (d and d[k] and d[k].dt)
if edt then
local be,af
@@ -18473,7 +19263,8 @@ local function insert_element(root,pattern,whatever,before)
local collected=element and xmlapplylpath(root,pattern)
local function insert_e(e)
local r=e.__p__
- local d,k=r.dt,e.ni
+ local d=r.dt
+ local k=e.ni
if not before then
k=k+1
end
@@ -18903,8 +19694,10 @@ function xml.separate(x,pattern)
report_xml("warning: xml.separate changes root")
x=d
end
- local t,n={ "\n" },1
- local i,nd=1,#d
+ local t={ "\n" }
+ local n=1
+ local i=1
+ local nd=#d
while i<=nd do
while i<=nd do
local di=d[i]
@@ -19885,7 +20678,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-exp"] = package.loaded["data-exp"] or true
--- original size: 18105, stripped down to: 10389
+-- original size: 18154, stripped down to: 10416
if not modules then modules={} end modules ['data-exp']={
version=1.001,
@@ -20092,9 +20885,11 @@ local function scan(files,remap,spec,path,n,m,r,onlyone,tolerant)
local pattern=tolerant and lessweird or weird
local filelist={}
local noffiles=0
- for name in directory(full) do
+ for name,mode in directory(full) do
if not lpegmatch(pattern,name) then
- local mode=attributes(full..name,"mode")
+ if not mode then
+ mode=attributes(full..name,"mode")
+ end
if mode=="file" then
n=n+1
noffiles=noffiles+1
@@ -20575,7 +21370,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16116, stripped down to: 10782
+-- original size: 16284, stripped down to: 10938
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -20615,6 +21410,7 @@ caches.force=true
caches.ask=false
caches.relocate=false
caches.defaults={ "TMPDIR","TEMPDIR","TMP","TEMP","HOME","HOMEPATH" }
+directives.register("system.caches.fast",function(v) caches.fast=true end)
local writable,readables,usedreadables=nil,{},{}
local function identify()
local texmfcaches=resolvers.cleanpathlist("TEXMFCACHE")
@@ -20848,7 +21644,9 @@ local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
data.cache_uuid=os.uuid()
- if caches.direct then
+ if caches.fast then
+ file.savedata(tmaname,table.fastserialize(data,true))
+ elseif caches.direct then
file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
table.tofile(tmaname,data,true,saveoptions)
@@ -23182,7 +23980,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8700, stripped down to: 6313
+-- original size: 10263, stripped down to: 7556
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23201,6 +23999,65 @@ local archives=zip.archives or {}
zip.archives=archives
local registeredfiles=zip.registeredfiles or {}
zip.registeredfiles=registeredfiles
+local zipfiles=utilities.zipfiles
+local openzip,closezip,validfile,wholefile,filehandle,traversezip
+if zipfiles then
+ local ipairs=ipairs
+ openzip=zipfiles.open
+ closezip=zipfiles.close
+ validfile=zipfiles.found
+ wholefile=zipfiles.unzip
+ traversezip=function(zfile)
+ return ipairs(zipfiles.list(zfile))
+ end
+ local streams=utilities.streams
+ local openstream=streams.open
+ local readstring=streams.readstring
+ local streamsize=streams.size
+ local metatable={
+ close=streams.close,
+ read=function(stream,n)
+ readstring(stream,n=="*a" and streamsize(stream) or n)
+ end
+ }
+ filehandle=function(zfile,queryname)
+ local data=wholefile(zfile,queryname)
+ if data then
+ local stream=openstream(data)
+ if stream then
+ return setmetatableindex(stream,metatable)
+ end
+ end
+ end
+else
+ openzip=zip.open
+ closezip=zip.close
+ validfile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ dfile:close()
+ return true
+ end
+ return false
+ end
+ traversezip=function(zfile)
+ return z:files()
+ end
+ wholefile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ local s=dfile:read("*all")
+ dfile:close()
+ return s
+ end
+ end
+ filehandle=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ return dfile
+ end
+ end
+end
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23215,7 +24072,7 @@ function zip.openarchive(name)
local arch=archives[name]
if not arch then
local full=resolvers.findfile(name) or ""
- arch=full~="" and zip.open(full) or false
+ arch=full~="" and openzip(full) or false
archives[name]=arch
end
return arch
@@ -23223,7 +24080,7 @@ function zip.openarchive(name)
end
function zip.closearchive(name)
if not name or (name=="" and archives[name]) then
- zip.close(archives[name])
+ closezip(archives[name])
archives[name]=nil
end
end
@@ -23264,9 +24121,7 @@ function resolvers.finders.zip(specification)
if trace_locating then
report_zip("finder: archive %a found",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
- dfile:close()
+ if validfile(zfile,queryname) then
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -23296,12 +24151,12 @@ function resolvers.openers.zip(specification)
if trace_locating then
report_zip("opener; archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local handle=filehandle(zfile,queryname)
+ if handle then
if trace_locating then
report_zip("opener: file %a found",queryname)
end
- return resolvers.openers.helpers.textopener('zip',original,dfile)
+ return resolvers.openers.helpers.textopener('zip',original,handle)
elseif trace_locating then
report_zip("opener: file %a not found",queryname)
end
@@ -23327,15 +24182,13 @@ function resolvers.loaders.zip(specification)
if trace_locating then
report_zip("loader: archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local data=wholefile(zfile,queryname)
+ if data then
logs.show_load(original)
if trace_locating then
report_zip("loader; file %a loaded",original)
end
- local s=dfile:read("*all")
- dfile:close()
- return true,s,#s
+ return true,data,#data
elseif trace_locating then
report_zip("loader: file %a not found",queryname)
end
@@ -23382,7 +24235,7 @@ function resolvers.registerzipfile(z,tree)
if trace_locating then
report_zip("registering: using filter %a",filter)
end
- for i in z:files() do
+ for i in traversezip(z) do
local filename=i.filename
local path,name=match(filename,filter)
if not path then
@@ -23911,7 +24764,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-aux"] = package.loaded["data-aux"] or true
--- original size: 2438, stripped down to: 1863
+-- original size: 2452, stripped down to: 1877
if not modules then modules={} end modules ['data-aux']={
version=1.001,
@@ -23959,7 +24812,7 @@ function resolvers.updatescript(oldname,newname)
local newdata=io.loaddata(newscript)
if newdata then
if trace_locating then
- report_scripts("old script content replaced by new content")
+ report_scripts("old script content replaced by new content: %s",oldscript)
end
io.savedata(oldscript,newdata)
break
@@ -24516,7 +25369,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true
--- original size: 9346, stripped down to: 7085
+-- original size: 9637, stripped down to: 7253
if not modules then modules={} end modules ['luat-fmt']={
version=1.001,
@@ -24536,9 +25389,6 @@ local function primaryflags()
if arguments.silent then
flags[#flags+1]="--interaction=batchmode"
end
- if arguments.jit then
- flags[#flags+1]="--jiton"
- end
return concat(flags," ")
end
local function secondaryflags()
@@ -24567,6 +25417,9 @@ local function secondaryflags()
if arguments.strip then
flags[#flags+1]="--c:strip"
end
+ if arguments.lmtx then
+ flags[#flags+1]="--c:lmtx"
+ end
return concat(flags," ")
end
local template=[[--ini %primaryflags% --lua=%luafile% %texfile% %secondaryflags% %dump% %redirect%]]
@@ -24586,6 +25439,13 @@ local runners={
checkers=checkers,
reporter=report_format,
},
+ luametatex=sandbox.registerrunner {
+ name="make luametatex format",
+ program="luametatex",
+ template=template,
+ checkers=checkers,
+ reporter=report_format,
+ },
luajittex=sandbox.registerrunner {
name="make luajittex format",
program="luajittex",
@@ -24753,10 +25613,10 @@ end
end -- of closure
--- used libraries : 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 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 util-lib.lua luat-sta.lua luat-fmt.lua
+-- 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 util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 989477
--- stripped bytes : 393339
+-- original bytes : 1020503
+-- stripped bytes : 404014
-- end library merge
@@ -24779,6 +25639,7 @@ local owntree = environment and environment.ownpath or ownpath
local ownlibs = { -- order can be made better
+ 'l-bit32.lua',
'l-lua.lua',
'l-macro.lua',
'l-sandbox.lua',
@@ -24836,6 +25697,8 @@ local ownlibs = { -- order can be made better
'util-env.lua',
'luat-env.lua', -- can come before inf (as in mkiv)
+ 'util-zip.lua',
+
'lxml-tab.lua',
'lxml-lpt.lua',
-- 'lxml-ent.lua',
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index 611f7c8dd..a79ffc029 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -61,9 +61,140 @@ if not modules then modules = { } end modules ['mtxrun'] = {
do -- create closure to overcome 200 locals limit
+package.loaded["l-bit32"] = package.loaded["l-bit32"] or true
+
+-- original size: 3607, stripped down to: 3009
+
+if not modules then modules={} end modules ['l-bit32']={
+ version=1.001,
+ license="the same as regular Lua",
+ source="bitwise.lua, v 1.24 2014/12/26 17:20:53 roberto",
+ comment="drop-in for bit32, adapted a bit by Hans Hagen",
+}
+if bit32 then
+elseif utf8 then
+ load ([[
+local select = select -- instead of: arg = { ... }
+bit32 = {
+ bnot = function (a)
+ return ~a & 0xFFFFFFFF
+ end,
+ band = function (x, y, z, ...)
+ if not z then
+ return ((x or -1) & (y or -1)) & 0xFFFFFFFF
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) | (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x | y | z
+ for i=1,select("#",...) do
+ res = res | select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bxor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x ~ y ~ z
+ for i=1,select("#",...) do
+ res = res ~ select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ btest = function (x, y, z, ...)
+ if not z then
+ return (((x or -1) & (y or -1)) & 0xFFFFFFFF) ~= 0
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return (res & 0xFFFFFFFF) ~= 0
+ end
+ end,
+ lshift = function (a, b)
+ return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF
+ end,
+ rshift = function (a, b)
+ return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF
+ end,
+ arshift = function (a, b)
+ a = a & 0xFFFFFFFF
+ if b <= 0 or (a & 0x80000000) == 0 then
+ return (a >> b) & 0xFFFFFFFF
+ else
+ return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF
+ end
+ end,
+ lrotate = function (a ,b)
+ b = b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ rrotate = function (a, b)
+ b = -b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ extract = function (a, f, w)
+ return (a >> f) & ~(-1 << (w or 1))
+ end,
+ replace = function (a, v, f, w)
+ local mask = ~(-1 << (w or 1))
+ return ((a & ~(mask << f)) | ((v & mask) << f)) & 0xFFFFFFFF
+ end,
+}
+ ]] ) ()
+elseif bit then
+ load ([[
+local band, bnot, rshift, lshift = bit.band, bit.bnot, bit.rshift, bit.lshift
+bit32 = {
+ arshift = bit.arshift,
+ band = band,
+ bnot = bnot,
+ bor = bit.bor,
+ bxor = bit.bxor,
+ btest = function(...)
+ return band(...) ~= 0
+ end,
+ extract = function(a,f,w)
+ return band(rshift(a,f),2^(w or 1)-1)
+ end,
+ lrotate = bit.rol,
+ lshift = lshift,
+ replace = function(a,v,f,w)
+ local mask = 2^(w or 1)-1
+ return band(a,bnot(lshift(mask,f)))+lshift(band(v,mask),f)
+ end,
+ rrotate = bit.ror,
+ rshift = rshift,
+}
+ ]] ) ()
+else
+ xpcall(function() local _,t=require("bit32") if t then bit32=t end return end,function() end)
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["l-lua"] = package.loaded["l-lua"] or true
--- original size: 6204, stripped down to: 2852
+-- original size: 6330, stripped down to: 2831
if not modules then modules={} end modules ['l-lua']={
version=1.001,
@@ -180,8 +311,7 @@ if not FFISUPPORTED then
elseif not ffi.number then
ffi.number=tonumber
end
-if not bit32 then
- bit32=require("l-bit32")
+if LUAVERSION>5.3 then
end
@@ -1962,7 +2092,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-table"] = package.loaded["l-table"] or true
--- original size: 40960, stripped down to: 21348
+-- original size: 41332, stripped down to: 21508
if not modules then modules={} end modules ['l-table']={
version=1.001,
@@ -1973,7 +2103,7 @@ if not modules then modules={} end modules ['l-table']={
}
local type,next,tostring,tonumber,select=type,next,tostring,tonumber,select
local table,string=table,string
-local concat,sort,insert,remove=table.concat,table.sort,table.insert,table.remove
+local concat,sort=table.concat,table.sort
local format,lower,dump=string.format,string.lower,string.dump
local getmetatable,setmetatable=getmetatable,setmetatable
local lpegmatch,patterns=lpeg.match,lpeg.patterns
@@ -1983,7 +2113,8 @@ function table.getn(t)
return t and #t
end
function table.strip(tab)
- local lst,l={},0
+ local lst={}
+ local l=0
for i=1,#tab do
local s=lpegmatch(stripper,tab[i]) or ""
if s=="" then
@@ -1996,7 +2127,8 @@ function table.strip(tab)
end
function table.keys(t)
if t then
- local keys,k={},0
+ local keys={}
+ local k=0
for key in next,t do
k=k+1
keys[k]=key
@@ -2027,27 +2159,30 @@ local function compare(a,b)
end
local function sortedkeys(tab)
if tab then
- local srt,category,s={},0,0
+ local srt={}
+ local category=0
+ local s=0
for key in next,tab do
s=s+1
srt[s]=key
- if category==3 then
- elseif category==1 then
- if type(key)~="string" then
- category=3
- end
- elseif category==2 then
- if type(key)~="number" then
- category=3
- end
- else
+ if category~=3 then
local tkey=type(key)
- if tkey=="string" then
- category=1
- elseif tkey=="number" then
- category=2
+ if category==1 then
+ if tkey~="string" then
+ category=3
+ end
+ elseif category==2 then
+ if tkey~="number" then
+ category=3
+ end
else
- category=3
+ if tkey=="string" then
+ category=1
+ elseif tkey=="number" then
+ category=2
+ else
+ category=3
+ end
end
end
end
@@ -2064,7 +2199,8 @@ local function sortedkeys(tab)
end
local function sortedhashonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="string" then
s=s+1
@@ -2081,7 +2217,8 @@ local function sortedhashonly(tab)
end
local function sortedindexonly(tab)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if type(key)=="number" then
s=s+1
@@ -2098,7 +2235,8 @@ local function sortedindexonly(tab)
end
local function sortedhashkeys(tab,cmp)
if tab then
- local srt,s={},0
+ local srt={}
+ local s=0
for key in next,tab do
if key then
s=s+1
@@ -2174,7 +2312,9 @@ function table.prepend(t,list)
return t
end
function table.merge(t,...)
- t=t or {}
+ if not t then
+ t={}
+ end
for i=1,select("#",...) do
for k,v in next,(select(i,...)) do
t[k]=v
@@ -2203,7 +2343,8 @@ function table.imerge(t,...)
return t
end
function table.imerged(...)
- local tmp,ntmp={},0
+ local tmp={}
+ local ntmp=0
for i=1,select("#",...) do
local nst=select(i,...)
for j=1,#nst do
@@ -2235,7 +2376,9 @@ local function fastcopy(old,metatabletoo)
end
end
local function copy(t,tables)
- tables=tables or {}
+ if not tables then
+ tables={}
+ end
local tcopy={}
if not tables[t] then
tables[t]=tcopy
@@ -2282,7 +2425,8 @@ function table.tohash(t,value)
return h
end
function table.fromhash(t)
- local hsh,h={},0
+ local hsh={}
+ local h=0
for k,v in next,t do
if v then
h=h+1
@@ -2383,7 +2527,8 @@ local function do_serialize(root,name,depth,level,indexed)
end
end
if root and next(root)~=nil then
- local first,last=nil,0
+ local first=nil
+ local last=0
if compact then
last=#root
for k=1,last do
@@ -2642,7 +2787,8 @@ local function serialize(_handle,root,name,specification)
handle("}")
end
function table.serialize(root,name,specification)
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
@@ -2656,13 +2802,15 @@ function table.tofile(filename,root,name,specification)
local f=io.open(filename,'w')
if f then
if maxtab>1 then
- local t,n={},0
+ local t={}
+ local n=0
local function flush(s)
n=n+1
t[n]=s
if n>maxtab then
f:write(concat(t,"\n"),"\n")
- t,n={},0
+ t={}
+ n=0
end
end
serialize(flush,root,name,specification)
@@ -2764,8 +2912,12 @@ local function are_equal(a,b,n,m)
if a==b then
return true
elseif a and b and #a==#b then
- n=n or 1
- m=m or #a
+ if not n then
+ n=1
+ end
+ if not m then
+ m=#a
+ end
for i=n,m do
local ai,bi=a[i],b[i]
if ai==bi then
@@ -2865,7 +3017,8 @@ function table.mirrored(t)
end
function table.reversed(t)
if t then
- local tt,tn={},#t
+ local tt={}
+ local tn=#t
if tn>0 then
local ttn=0
for i=tn,1,-1 do
@@ -2978,7 +3131,9 @@ function table.sorted(t,...)
end
function table.values(t,s)
if t then
- local values,keys,v={},{},0
+ local values={}
+ local keys={}
+ local v=0
for key,value in next,t do
if not keys[value] then
v=v+1
@@ -3610,7 +3765,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-os"] = package.loaded["l-os"] or true
--- original size: 19347, stripped down to: 10258
+-- original size: 18985, stripped down to: 10149
if not modules then modules={} end modules ['l-os']={
version=1.001,
@@ -3775,17 +3930,8 @@ local launchers={
unix="xdg-open %s &> /dev/null &",
}
function os.launch(str)
- execute(format(launchers[os.name] or launchers.unix,str))
-end
-if not os.times then
- function os.times()
- return {
- utime=os.gettimeofday(),
- stime=0,
- cutime=0,
- cstime=0,
- }
- end
+ local command=format(launchers[os.name] or launchers.unix,str)
+ execute(command)
end
local gettimeofday=os.gettimeofday or os.clock
os.gettimeofday=gettimeofday
@@ -4062,7 +4208,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-file"] = package.loaded["l-file"] or true
--- original size: 21804, stripped down to: 9980
+-- original size: 21984, stripped down to: 10148
if not modules then modules={} end modules ['l-file']={
version=1.001,
@@ -4242,40 +4388,45 @@ local reslasher=lpeg.replacer(P("\\"),"/")
function file.reslash(str)
return str and lpegmatch(reslasher,str)
end
-function file.is_writable(name)
- if not name then
- elseif lfs.isdir(name) then
- name=name.."/m_t_x_t_e_s_t.tmp"
- local f=io.open(name,"wb")
- if f then
- f:close()
- os.remove(name)
- return true
- end
- elseif lfs.isfile(name) then
- local f=io.open(name,"ab")
- if f then
- f:close()
- return true
- end
- else
- local f=io.open(name,"ab")
- if f then
- f:close()
- os.remove(name)
- return true
+if lfs.isreadablefile and lfs.iswritablefile then
+ file.is_readable=lfs.isreadablefile
+ file.is_writable=lfs.iswritablefile
+else
+ function file.is_writable(name)
+ if not name then
+ elseif lfs.isdir(name) then
+ name=name.."/m_t_x_t_e_s_t.tmp"
+ local f=io.open(name,"wb")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
+ elseif lfs.isfile(name) then
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ return true
+ end
+ else
+ local f=io.open(name,"ab")
+ if f then
+ f:close()
+ os.remove(name)
+ return true
+ end
end
- end
- return false
-end
-local readable=P("r")*Cc(true)
-function file.is_readable(name)
- if name then
- local a=attributes(name)
- return a and lpegmatch(readable,a.permissions) or false
- else
return false
end
+ local readable=P("r")*Cc(true)
+ function file.is_readable(name)
+ if name then
+ local a=attributes(name)
+ return a and lpegmatch(readable,a.permissions) or false
+ else
+ return false
+ end
+ end
end
file.isreadable=file.is_readable
file.iswritable=file.is_writable
@@ -4906,7 +5057,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["l-dir"] = package.loaded["l-dir"] or true
--- original size: 18002, stripped down to: 10681
+-- original size: 18253, stripped down to: 10816
if not modules then modules={} end modules ['l-dir']={
version=1.001,
@@ -4971,13 +5122,15 @@ local function glob_pattern_function(path,patt,recurse,action)
end
local dirs
local nofdirs=0
- for name in walkdir(usedpath) do
+ for name,mode,size,time in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
- action(full)
+ action(full,size,time)
end
elseif recurse and mode=="directory" then
if dirs then
@@ -5013,10 +5166,12 @@ local function glob_pattern_table(path,patt,recurse,result)
local dirs
local nofdirs=0
local noffiles=#result
- for name,a in walkdir(usedpath) do
+ for name,mode in walkdir(usedpath) do
if name~="." and name~=".." then
local full=path..name
- local mode=attributes(full,'mode')
+ if mode==nil then
+ mode=attributes(full,'mode')
+ end
if mode=='file' then
if not patt or find(full,patt) then
noffiles=noffiles+1
@@ -5067,7 +5222,7 @@ local function collectpattern(path,patt,recurse,result)
if not find(path,"/$") then
path=path..'/'
end
- for name in scanner,first do
+ for name in scanner,first do
if name=="." then
elseif name==".." then
else
@@ -5158,10 +5313,12 @@ local function globfiles(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if recurse then
globfiles(path.."/"..name,recurse,func,files)
@@ -5184,10 +5341,12 @@ local function globdirs(path,recurse,func,files)
end
files=files or {}
local noffiles=#files
- for name in walkdir(path) do
+ for name,mode in walkdir(path) do
if find(name,"^%.") then
else
- local mode=attributes(name,'mode')
+ if mode==nil then
+ mode=attributes(name,'mode')
+ end
if mode=="directory" then
if not func or func(name) then
noffiles=noffiles+1
@@ -5368,8 +5527,7 @@ local stack={}
function dir.push(newdir)
local curdir=currentdir()
insert(stack,curdir)
- if newdir and newdir~="" then
- chdir(newdir)
+ if newdir and newdir~="" and chdir(newdir) then
return newdir
else
return curdir
@@ -6310,7 +6468,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-str"] = package.loaded["util-str"] or true
--- original size: 43539, stripped down to: 21641
+-- original size: 44146, stripped down to: 22098
if not modules then modules={} end modules ['util-str']={
version=1.001,
@@ -6326,7 +6484,6 @@ local format,gsub,rep,sub,find=string.format,string.gsub,string.rep,string.sub,s
local load,dump=load,string.dump
local tonumber,type,tostring,next,setmetatable=tonumber,type,tostring,next,setmetatable
local unpack,concat=table.unpack,table.concat
-local unpack,concat=table.unpack,table.concat
local P,V,C,S,R,Ct,Cs,Cp,Carg,Cc=lpeg.P,lpeg.V,lpeg.C,lpeg.S,lpeg.R,lpeg.Ct,lpeg.Cs,lpeg.Cp,lpeg.Carg,lpeg.Cc
local patterns,lpegmatch=lpeg.patterns,lpeg.match
local utfchar,utfbyte,utflen=utf.char,utf.byte,utf.len
@@ -6665,8 +6822,8 @@ local environment={
formattednumber=number.formatted,
sparseexponent=number.sparseexponent,
formattedfloat=number.formattedfloat,
- stripzero=lpeg.patterns.stripzero,
- stripzeros=lpeg.patterns.stripzeros,
+ stripzero=patterns.stripzero,
+ stripzeros=patterns.stripzeros,
FORMAT=string.f9,
}
local arguments={ "a1" }
@@ -6753,7 +6910,7 @@ local format_F=function(f)
end
local format_k=function(b,a)
n=n+1
- return format("formattedfloat(a%s,%i,%i)",n,b or 0,a or 0)
+ return format("formattedfloat(a%s,%s,%s)",n,b or 0,a or 0)
end
local format_g=function(f)
n=n+1
@@ -7109,9 +7266,9 @@ patterns.xmlescape=Cs((P("<")/"&lt;"+P(">")/"&gt;"+P("&")/"&amp;"+P('"')/"&quot;
patterns.texescape=Cs((C(S("#$%\\{}"))/"\\%1"+anything)^0)
patterns.luaescape=Cs(((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0)
patterns.luaquoted=Cs(Cc('"')*((1-S('"\n'))^1+P('"')/'\\"'+P('\n')/'\\n"')^0*Cc('"'))
-add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=lpeg.patterns.xmlescape })
-add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=lpeg.patterns.texescape })
-add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=lpeg.patterns.luaescape })
+add(formatters,"xml",[[lpegmatch(xmlescape,%s)]],{ xmlescape=patterns.xmlescape })
+add(formatters,"tex",[[lpegmatch(texescape,%s)]],{ texescape=patterns.texescape })
+add(formatters,"lua",[[lpegmatch(luaescape,%s)]],{ luaescape=patterns.luaescape })
local dquote=patterns.dquote
local equote=patterns.escaped+dquote/'\\"'+1
local cquote=Cc('"')
@@ -7143,6 +7300,27 @@ local f_16_16=formatters["%0.5N"]
function number.to16dot16(n)
return f_16_16(n/65536.0)
end
+if not string.explode then
+ local tsplitat=lpeg.tsplitat
+ local p_utf=patterns.utf8character
+ local p_check=C(p_utf)*(P("+")*Cc(true))^0
+ local p_split=Ct(C(p_utf)^0)
+ local p_space=Ct((C(1-P(" ")^1)+P(" ")^1)^0)
+ function string.explode(str,symbol)
+ if symbol=="" then
+ return lpegmatch(p_split,str)
+ elseif symbol then
+ local a,b=lpegmatch(p_check,symbol)
+ if b then
+ return lpegmatch(tsplitat(P(a)^1),str)
+ else
+ return lpegmatch(tsplitat(a),str)
+ end
+ else
+ return lpegmatch(p_space,str)
+ end
+ end
+end
end -- of closure
@@ -7151,7 +7329,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-tab"] = package.loaded["util-tab"] or true
--- original size: 28756, stripped down to: 16104
+-- original size: 28866, stripped down to: 16134
if not modules then modules={} end modules ['util-tab']={
version=1.001,
@@ -7173,7 +7351,8 @@ local formatters=string.formatters
local utftoeight=utf.toeight
local splitter=lpeg.tsplitat(".")
function utilities.tables.definetable(target,nofirst,nolast)
- local composed,t=nil,{}
+ local composed=nil
+ local t={}
local snippets=lpegmatch(splitter,target)
for i=1,#snippets-(nolast and 1 or 0) do
local name=snippets[i]
@@ -7614,18 +7793,19 @@ local function serialize(root,name,specification)
end
if root and next(root)~=nil then
local first=nil
- local last=0
- last=#root
- for k=1,last do
- if rawget(root,k)==nil then
- last=k-1
- break
- end
- end
+ local last=#root
if last>0 then
- first=1
+ for k=1,last do
+ if rawget(root,k)==nil then
+ last=k-1
+ break
+ end
+ end
+ if last>0 then
+ first=1
+ end
end
- local sk=sortedkeys(root)
+ local sk=sortedkeys(root)
for i=1,#sk do
local k=sk[i]
local v=root[k]
@@ -7813,7 +7993,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fil"] = package.loaded["util-fil"] or true
--- original size: 8607, stripped down to: 6727
+-- original size: 11530, stripped down to: 9007
if not modules then modules={} end modules ['util-fil']={
version=1.001,
@@ -8022,6 +8202,32 @@ if bit32 then
local b=char(n%256)
f:write(b,a)
end
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=rshift(n,8)
+ local b=char(n%256)
+ n=rshift(n,8)
+ local c=char(n%256)
+ n=rshift(n,8)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
else
local floor=math.floor
function files.writecardinal2(f,n)
@@ -8030,16 +8236,32 @@ else
local b=char(n%256)
f:write(b,a)
end
-end
-function files.writecardinal4(f,n)
- local a=char(n%256)
- n=rshift(n,8)
- local b=char(n%256)
- n=rshift(n,8)
- local c=char(n%256)
- n=rshift(n,8)
- local d=char(n%256)
- f:write(d,c,b,a)
+ function files.writecardinal4(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(d,c,b,a)
+ end
+ function files.writecardinal2le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ f:write(a,b)
+ end
+ function files.writecardinal4le(f,n)
+ local a=char(n%256)
+ n=floor(n/256)
+ local b=char(n%256)
+ n=floor(n/256)
+ local c=char(n%256)
+ n=floor(n/256)
+ local d=char(n%256)
+ f:write(a,b,c,d)
+ end
end
function files.writestring(f,s)
f:write(char(byte(s,1,#s)))
@@ -8052,10 +8274,18 @@ if fio and fio.readcardinal1 then
files.readcardinal2=fio.readcardinal2
files.readcardinal3=fio.readcardinal3
files.readcardinal4=fio.readcardinal4
+ files.readcardinal1le=fio.readcardinal1le or files.readcardinal1le
+ files.readcardinal2le=fio.readcardinal2le or files.readcardinal2le
+ files.readcardinal3le=fio.readcardinal3le or files.readcardinal3le
+ files.readcardinal4le=fio.readcardinal4le or files.readcardinal4le
files.readinteger1=fio.readinteger1
files.readinteger2=fio.readinteger2
files.readinteger3=fio.readinteger3
files.readinteger4=fio.readinteger4
+ files.readinteger1le=fio.readinteger1le or files.readinteger1le
+ files.readinteger2le=fio.readinteger2le or files.readinteger2le
+ files.readinteger3le=fio.readinteger3le or files.readinteger3le
+ files.readinteger4le=fio.readinteger4le or files.readinteger4le
files.readfixed2=fio.readfixed2
files.readfixed4=fio.readfixed4
files.read2dot14=fio.read2dot14
@@ -8076,6 +8306,24 @@ if fio and fio.readcardinal1 then
skipposition(f,4*(n or 1))
end
end
+if fio and fio.writecardinal1 then
+ files.writecardinal1=fio.writecardinal1
+ files.writecardinal2=fio.writecardinal2
+ files.writecardinal3=fio.writecardinal3
+ files.writecardinal4=fio.writecardinal4
+ files.writecardinal1le=fio.writecardinal1le
+ files.writecardinal2le=fio.writecardinal2le
+ files.writecardinal3le=fio.writecardinal3le
+ files.writecardinal4le=fio.writecardinal4le
+ files.writeinteger1=fio.writeinteger1 or fio.writecardinal1
+ files.writeinteger2=fio.writeinteger2 or fio.writecardinal2
+ files.writeinteger3=fio.writeinteger3 or fio.writecardinal3
+ files.writeinteger4=fio.writeinteger4 or fio.writecardinal4
+ files.writeinteger1le=files.writeinteger1le or fio.writecardinal1le
+ files.writeinteger2le=files.writeinteger2le or fio.writecardinal2le
+ files.writeinteger3le=files.writeinteger3le or fio.writecardinal3le
+ files.writeinteger4le=files.writeinteger4le or fio.writecardinal4le
+end
if fio and fio.readcardinaltable then
files.readcardinaltable=fio.readcardinaltable
files.readintegertable=fio.readintegertable
@@ -8113,7 +8361,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 11065, stripped down to: 8209
+-- original size: 11332, stripped down to: 8420
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -8138,6 +8386,11 @@ function streams.openstring(f,zerobased)
return { f,1,#f,zerobased or false }
end
end
+function streams.getstring(f)
+ if f then
+ return f[1]
+ end
+end
function streams.close()
end
function streams.size(f)
@@ -8228,7 +8481,7 @@ function streams.readcardinal2(f)
local a,b=byte(f[1],i,j)
return 0x100*a+b
end
-function streams.readcardinal2LE(f)
+function streams.readcardinal2le(f)
local i=f[2]
local j=i+1
f[2]=j+1
@@ -8300,6 +8553,13 @@ function streams.readcardinal4(f)
local a,b,c,d=byte(f[1],i,j)
return 0x1000000*a+0x10000*b+0x100*c+d
end
+function streams.readcardinal4le(f)
+ local i=f[2]
+ local j=i+3
+ f[2]=j+1
+ local d,c,b,a=byte(f[1],i,j)
+ return 0x1000000*a+0x10000*b+0x100*c+d
+end
function streams.readinteger4(f)
local i=f[2]
local j=i+3
@@ -8699,7 +8959,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-prs"] = package.loaded["util-prs"] or true
--- original size: 23400, stripped down to: 15802
+-- original size: 24132, stripped down to: 16210
if not modules then modules={} end modules ['util-prs']={
version=1.001,
@@ -8724,7 +8984,7 @@ local sortedhash=table.sortedhash
local sortedkeys=table.sortedkeys
local tohash=table.tohash
local hashes={}
-utilities.parsers.hashes=hashes
+parsers.hashes=hashes
local digit=R("09")
local space=P(' ')
local equal=P("=")
@@ -8944,7 +9204,9 @@ function parsers.add_settings_to_array(t,str)
end
function parsers.hash_to_string(h,separator,yes,no,strict,omit)
if h then
- local t,tn,s={},0,sortedkeys(h)
+ local t={}
+ local tn=0
+ local s=sortedkeys(h)
omit=omit and tohash(omit)
for i=1,#s do
local key=s[i]
@@ -8982,7 +9244,7 @@ function parsers.array_to_string(a,separator)
end
end
local pattern=Cf(Ct("")*Cg(C((1-S(", "))^1)*S(", ")^0*Cc(true))^1,rawset)
-function utilities.parsers.settings_to_set(str)
+function parsers.settings_to_set(str)
return str and lpegmatch(pattern,str) or {}
end
hashes.settings_to_set=table.setmetatableindex(function(t,k)
@@ -8992,7 +9254,8 @@ hashes.settings_to_set=table.setmetatableindex(function(t,k)
end)
getmetatable(hashes.settings_to_set).__mode="kv"
function parsers.simple_hash_to_string(h,separator)
- local t,tn={},0
+ local t={}
+ local tn=0
for k,v in sortedhash(h) do
if v then
tn=tn+1
@@ -9004,11 +9267,11 @@ end
local str=Cs(lpegpatterns.unquoted)+C((1-whitespace-equal)^1)
local setting=Cf(Carg(1)*(whitespace^0*Cg(str*whitespace^0*(equal*whitespace^0*str+Cc(""))))^1,rawset)
local splitter=setting^1
-function utilities.parsers.options_to_hash(str,target)
+function parsers.options_to_hash(str,target)
return str and lpegmatch(splitter,str,1,target or {}) or {}
end
local splitter=lpeg.tsplitat(" ")
-function utilities.parsers.options_to_array(str)
+function parsers.options_to_array(str)
return str and lpegmatch(splitter,str) or {}
end
local value=P(lbrace*C((nobrace+nestedbraces)^0)*rbrace)+C(digit^1*lparent*(noparent+nestedparents)^1*rparent)+C((nestedbraces+(1-comma))^1)
@@ -9021,7 +9284,8 @@ local function repeater(n,str)
if n==1 then
return unpack(s)
else
- local t,tn={},0
+ local t={}
+ local tn=0
for i=1,n do
for j=1,#s do
tn=tn+1
@@ -9192,7 +9456,7 @@ setmetatableindex(cache,function(t,k)
return pattern
end)
local commalistiterator=cache[","]
-function utilities.parsers.iterator(str,separator)
+function parsers.iterator(str,separator)
local n=#str
if n==0 then
return dummy
@@ -9234,10 +9498,10 @@ end
local name=C((1-S(", "))^1)
local parser=(Carg(1)*name/initialize)*(S(", ")^1*(Carg(1)*name/fetch))^0
local merge=Cf(parser,process)
-function utilities.parsers.mergehashes(hash,list)
+function parsers.mergehashes(hash,list)
return lpegmatch(merge,list,1,hash)
end
-function utilities.parsers.runtime(time)
+function parsers.runtime(time)
if not time then
time=os.runtime()
end
@@ -9254,13 +9518,24 @@ local apply=P("->")
local method=C((1-apply)^1)
local token=lbrace*C((1-rbrace)^1)*rbrace+C(anything^1)
local pattern=spacing*(method*spacing*apply+Carg(1))*spacing*token
-function utilities.parsers.splitmethod(str,default)
+function parsers.splitmethod(str,default)
if str then
return lpegmatch(pattern,str,1,default or false)
else
return default or false,""
end
end
+local p_year=lpegpatterns.digit^4/tonumber
+local pattern=Cf(Ct("")*(
+ (Cg(Cc("year")*p_year)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("day")*cardinal)
+ )+(Cg(Cc("day")*cardinal)*S("-/")*Cg(Cc("month")*cardinal)*S("-/")*Cg(Cc("year")*p_year)
+ )
+ )*P(" ")*Cg(Cc("hour")*cardinal)*P(":")*Cg(Cc("min")*cardinal)*(P(":")*Cg(Cc("sec")*cardinal))^-1
+,rawset)
+lpegpatterns.splittime=pattern
+function parsers.totime(str)
+ return lpegmatch(pattern,str)
+end
end -- of closure
@@ -9269,7 +9544,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-fmt"] = package.loaded["util-fmt"] or true
--- original size: 2274, stripped down to: 1607
+-- original size: 2541, stripped down to: 1624
if not modules then modules={} end modules ['util-fmt']={
version=1.001,
@@ -9305,8 +9580,8 @@ function formatters.formatcolumns(result,between)
local tj=type(rj)
if tj=="number" then
numbers[j]=true
- end
- if tj~="string" then
+ rj=tostring(rj)
+ elseif tj~="string" then
rj=tostring(rj)
r[j]=rj
end
@@ -9372,13 +9647,13 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-socket"] = package.loaded["util-soc-imp-socket"] or true
--- original size: 4870, stripped down to: 3527
+-- original size: 4905, stripped down to: 3562
local type,tostring,setmetatable=type,tostring,setmetatable
local min=math.min
local format=string.format
-local socket=require("socket.core")
+local socket=socket or package.loaded.socket or require("socket.core")
local connect=socket.connect
local tcp4=socket.tcp4
local tcp6=socket.tcp6
@@ -9548,7 +9823,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-copas"] = package.loaded["util-soc-imp-copas"] or true
--- original size: 25844, stripped down to: 14821
+-- original size: 25959, stripped down to: 14893
local socket=socket or require("socket")
@@ -9585,6 +9860,7 @@ local copas={
autoclose=true,
running=false,
report=report,
+ trace=false,
}
local function statushandler(status,...)
if status then
@@ -9594,7 +9870,9 @@ local function statushandler(status,...)
if type(err)=="table" then
err=err[1]
end
- report("error: %s",tostring(err))
+ if copas.trace then
+ report("error: %s",tostring(err))
+ end
return nil,err
end
function socket.protect(func)
@@ -9608,7 +9886,9 @@ function socket.newtry(finalizer)
if not status then
local detail=select(2,...)
pcall(finalizer,detail)
- report("error: %s",tostring(detail))
+ if copas.trace then
+ report("error: %s",tostring(detail))
+ end
return
end
return...
@@ -10561,12 +10841,12 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-soc-imp-mime"] = package.loaded["util-soc-imp-mime"] or true
--- original size: 2328, stripped down to: 1874
+-- original size: 2373, stripped down to: 1931
local type,tostring=type,tostring
-local mime=require("mime.core")
-local ltn12=ltn12 or require("ltn12")
+local mime=mime or package.loaded.mime or require("mime.core")
+local ltn12=ltn12 or package.loaded.ltn12 or require("ltn12")
local filtercycle=ltn12.filter.cycle
local function report(fmt,first,...)
if logs then
@@ -12518,7 +12798,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-log"] = package.loaded["trac-log"] or true
--- original size: 32608, stripped down to: 20925
+-- original size: 32618, stripped down to: 20935
if not modules then modules={} end modules ['trac-log']={
version=1.001,
@@ -12563,7 +12843,7 @@ local function ignore() end
setmetatableindex(logs,function(t,k) t[k]=ignore;return ignore end)
local report,subreport,status,settarget,setformats,settranslations
local direct,subdirect,writer,pushtarget,poptarget,setlogfile,settimedlog,setprocessor,setformatters,newline
-if runningtex then
+if runningtex and texio then
if texio.setescape then
texio.setescape(0)
end
@@ -13399,7 +13679,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 9072, stripped down to: 6055
+-- original size: 8966, stripped down to: 5972
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -13546,13 +13826,11 @@ function statistics.show()
end
register("lua properties",function()
local hashchar=tonumber(status.luatex_hashchars)
- local hashtype=status.luatex_hashtype
local mask=lua.mask or "ascii"
- return format("engine: %s %s, used memory: %s, hash type: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
+ return format("engine: %s %s, used memory: %s, hash chars: min(%i,40), symbol mask: %s (%s)",
jit and "luajit" or "lua",
LUAVERSION,
statistics.memused(),
- hashtype or "default",
hashchar and 2^hashchar or "unknown",
mask,
mask=="utf" and "τεχ" or "tex")
@@ -13935,7 +14213,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-deb"] = package.loaded["util-deb"] or true
--- original size: 9955, stripped down to: 6693
+-- original size: 10136, stripped down to: 6832
if not modules then modules={} end modules ['util-deb']={
version=1.001,
@@ -13959,7 +14237,13 @@ local dummycalls=10*1000
local nesting=0
local names={}
local initialize=false
-if not (FFISUPPORTED and ffi) then
+if lua.getpreciseticks then
+ initialize=function()
+ ticks=lua.getpreciseticks
+ seconds=lua.getpreciseseconds
+ initialize=false
+ end
+elseif not (FFISUPPORTED and ffi) then
elseif os.type=="windows" then
initialize=function()
local kernel=ffilib("kernel32","system")
@@ -15062,7 +15346,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-env"] = package.loaded["util-env"] or true
--- original size: 9517, stripped down to: 5360
+-- original size: 9738, stripped down to: 5531
if not modules then modules={} end modules ['util-env']={
version=1.001,
@@ -15136,8 +15420,11 @@ environment.arguments=allocate()
environment.files=allocate()
environment.sortedflags=nil
function environment.initializearguments(arg)
- local arguments,files={},{}
- environment.arguments,environment.files,environment.sortedflags=arguments,files,nil
+ local arguments={}
+ local files={}
+ environment.arguments=arguments
+ environment.files=files
+ environment.sortedflags=nil
for index=1,#arg do
local argument=arg[index]
if index>0 then
@@ -15156,6 +15443,11 @@ function environment.initializearguments(arg)
end
end
end
+ if not environment.ownname then
+ if os.selfpath and os.selfname then
+ environment.ownname=file.addsuffix(file.join(os.selfpath,os.selfname),"lua")
+ end
+ end
environment.ownname=file.reslash(environment.ownname or arg[0] or 'unknown.lua')
end
function environment.setargument(name,value)
@@ -15434,6 +15726,468 @@ end -- of closure
do -- create closure to overcome 200 locals limit
+package.loaded["util-zip"] = package.loaded["util-zip"] or true
+
+-- original size: 18645, stripped down to: 11291
+
+if not modules then modules={} end modules ['util-zip']={
+ version=1.001,
+ author="Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright="PRAGMA ADE / ConTeXt Development Team",
+ license="see context related readme files"
+}
+local type,tostring,tonumber=type,tostring,tonumber
+local sort=table.sort
+local find,format,sub,gsub=string.find,string.format,string.sub,string.gsub
+local osdate,ostime=os.date,os.time
+local ioopen=io.open
+local loaddata,savedata=io.loaddata,io.savedata
+local filejoin,isdir,dirname,mkdirs=file.join,lfs.isdir,file.dirname,dir.mkdirs
+local files=utilities.files
+local openfile=files.open
+local closefile=files.close
+local readstring=files.readstring
+local readcardinal2=files.readcardinal2le
+local readcardinal4=files.readcardinal4le
+local setposition=files.setposition
+local getposition=files.getposition
+local band=bit32.band
+local rshift=bit32.rshift
+local lshift=bit32.lshift
+local decompress,calculatecrc
+if flate then
+ decompress=flate.flate_decompress
+ calculatecrc=flate.update_crc32
+else
+ local zlibdecompress=zlib.decompress
+ local zlibchecksum=zlib.crc32
+ decompress=function(source,targetsize)
+ local target=zlibdecompress(source,-15)
+ if target then
+ return target
+ else
+ return false,1
+ end
+ end
+ calculatecrc=function(buffer,initial)
+ return zlibchecksum(initial or 0,buffer)
+ end
+end
+local zipfiles={}
+utilities.zipfiles=zipfiles
+local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
+ function openzipfile(name)
+ return {
+ name=name,
+ handle=openfile(name,0),
+ }
+ end
+ local function collect(z)
+ if not z.list then
+ local list={}
+ local hash={}
+ local position=0
+ local index=0
+ local handle=z.handle
+ while true do
+ setposition(handle,position)
+ local signature=readstring(handle,4)
+ if signature=="PK\3\4" then
+ local version=readcardinal2(handle)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ local filetime=readcardinal2(handle)
+ local filedate=readcardinal2(handle)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local filename=readstring(handle,namelength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ local skipped=0
+ local size=0
+ if encrypted then
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(size)
+ skipped=skipped+size+2
+ end
+ position=position+30+namelength+extralength+skipped
+ if descriptor then
+ setposition(handle,position+compressed)
+ crc32=readcardinal4(handle)
+ compressed=readcardinal4(handle)
+ uncompressed=readcardinal4(handle)
+ end
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=position,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ }
+ hash[filename]=data
+ list[index]=data
+ else
+ end
+ position=position+compressed
+ else
+ break
+ end
+ z.list=list
+ z.hash=hash
+ end
+ end
+ end
+ function getziplist(z)
+ local list=z.list
+ if not list then
+ collect(z)
+ end
+ return z.list
+ end
+ function getziphash(z)
+ local hash=z.hash
+ if not hash then
+ collect(z)
+ end
+ return z.hash
+ end
+ function foundzipfile(z,name)
+ return getziphash(z)[name]
+ end
+ function closezipfile(z)
+ local f=z.handle
+ if f then
+ closefile(f)
+ z.handle=nil
+ end
+ end
+ function unzipfile(z,filename,check)
+ local hash=z.hash
+ if not hash then
+ hash=zipfiles.hash(z)
+ end
+ local data=hash[filename]
+ if not data then
+ end
+ if data then
+ local handle=z.handle
+ local position=data.position
+ local compressed=data.compressed
+ if compressed>0 then
+ setposition(handle,position)
+ local result=readstring(handle,compressed)
+ if data.method==8 then
+ result=decompress(result,data.uncompressed)
+ end
+ if check and data.crc32~=calculatecrc(result) then
+ print("checksum mismatch")
+ return ""
+ end
+ return result
+ else
+ return ""
+ end
+ end
+ end
+ zipfiles.open=openzipfile
+ zipfiles.close=closezipfile
+ zipfiles.unzip=unzipfile
+ zipfiles.hash=getziphash
+ zipfiles.list=getziplist
+ zipfiles.found=foundzipfile
+end
+if flate then do
+ local writecardinal1=files.writebyte
+ local writecardinal2=files.writecardinal2le
+ local writecardinal4=files.writecardinal4le
+ local logwriter=logs.writer
+ local globpattern=dir.globpattern
+ local compress=flate.flate_compress
+ local checksum=flate.update_crc32
+ local function fromdostime(dostime,dosdate)
+ return ostime {
+ year=rshift(dosdate,9)+1980,
+ month=band(rshift(dosdate,5),0x0F),
+ day=band((dosdate ),0x1F),
+ hour=band(rshift(dostime,11) ),
+ min=band(rshift(dostime,5),0x3F),
+ sec=band((dostime ),0x1F),
+ }
+ end
+ local function todostime(time)
+ local t=osdate("*t",time)
+ return
+ lshift(t.year-1980,9)+lshift(t.month,5)+t.day,
+ lshift(t.hour,11)+lshift(t.min,5)+rshift(t.sec,1)
+ end
+ local function openzip(filename,level,comment,verbose)
+ local f=ioopen(filename,"wb")
+ if f then
+ return {
+ filename=filename,
+ handle=f,
+ list={},
+ level=tonumber(level) or 3,
+ comment=tostring(comment),
+ verbose=verbose,
+ uncompressed=0,
+ compressed=0,
+ }
+ end
+ end
+ local function writezip(z,name,data,level,time)
+ local f=z.handle
+ local list=z.list
+ local level=tonumber(level) or z.level or 3
+ local method=8
+ local zipped=compress(data,level)
+ local checksum=checksum(data)
+ local verbose=z.verbose
+ if not zipped then
+ method=0
+ zipped=data
+ end
+ local start=f:seek()
+ local compressed=#zipped
+ local uncompressed=#data
+ z.compressed=z.compressed+compressed
+ z.uncompressed=z.uncompressed+uncompressed
+ if verbose then
+ local pct=100*compressed/uncompressed
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,name))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,name))
+ end
+ end
+ f:write("\x50\x4b\x03\x04")
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,method)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ f:write(name)
+ f:write(zipped)
+ list[#list+1]={ #zipped,#data,name,checksum,start,time or 0 }
+ end
+ local function closezip(z)
+ local f=z.handle
+ local list=z.list
+ local comment=z.comment
+ local verbose=z.verbose
+ local count=#list
+ local start=f:seek()
+ for i=1,count do
+ local l=list[i]
+ local compressed=l[1]
+ local uncompressed=l[2]
+ local name=l[3]
+ local checksum=l[4]
+ local start=l[5]
+ local time=l[6]
+ local date,time=todostime(time)
+ f:write('\x50\x4b\x01\x02')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,8)
+ writecardinal2(f,time)
+ writecardinal2(f,date)
+ writecardinal4(f,checksum)
+ writecardinal4(f,compressed)
+ writecardinal4(f,uncompressed)
+ writecardinal2(f,#name)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal4(f,0)
+ writecardinal4(f,start)
+ f:write(name)
+ end
+ local stop=f:seek()
+ local size=stop-start
+ f:write('\x50\x4b\x05\x06')
+ writecardinal2(f,0)
+ writecardinal2(f,0)
+ writecardinal2(f,count)
+ writecardinal2(f,count)
+ writecardinal4(f,size)
+ writecardinal4(f,start)
+ if type(comment)=="string" and comment~="" then
+ writecardinal2(f,#comment)
+ f:write(comment)
+ else
+ writecardinal2(f,0)
+ end
+ if verbose then
+ local compressed=z.compressed
+ local uncompressed=z.uncompressed
+ local filename=z.filename
+ local pct=100*compressed/uncompressed
+ logwriter("")
+ if pct>=100 then
+ logwriter(format("%10i %s",uncompressed,filename))
+ else
+ logwriter(format("%10i %02.1f %s",uncompressed,pct,filename))
+ end
+ end
+ f:close()
+ end
+ local function zipdir(zipname,path,level,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ level=zipname.level
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ if not isdir(path) then
+ return
+ end
+ path=gsub(path,"\\+","/")
+ path=gsub(path,"/+","/")
+ local list={}
+ local count=0
+ globpattern(path,"",true,function(name,size,time)
+ count=count+1
+ list[count]={ name,time }
+ end)
+ sort(list,function(a,b)
+ return a[1]<b[1]
+ end)
+ local zipf=openzip(zipname,level,comment,verbose)
+ if zipf then
+ local p=#path+2
+ for i=1,count do
+ local li=list[i]
+ local name=li[1]
+ local time=li[2]
+ local data=loaddata(name)
+ local name=sub(name,p,#name)
+ writezip(zipf,name,data,level,time,verbose)
+ end
+ closezip(zipf)
+ end
+ end
+ local function unzipdir(zipname,path,verbose)
+ if type(zipname)=="table" then
+ verbose=zipname.verbose
+ path=zipname.path
+ zipname=zipname.zipname
+ end
+ if not zipname or zipname=="" then
+ return
+ end
+ if not path or path=="" then
+ path="."
+ end
+ local z=openzipfile(zipname)
+ if z then
+ local list=getziplist(z)
+ if list then
+ local total=0
+ local count=#list
+ local step=number.idiv(count,10)
+ local done=0
+ for i=1,count do
+ local l=list[i]
+ local n=l.filename
+ local d=unzipfile(z,n)
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if verbose=="steps" then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes",i,count,total))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ end
+ end
+ if verbose=="steps" then
+ logwriter(format("%4i files of %4i done, %10i bytes",count,count,total))
+ end
+ closezipfile(z)
+ return true
+ else
+ closezipfile(z)
+ end
+ end
+ end
+ zipfiles.zipdir=zipdir
+ zipfiles.unzipdir=unzipdir
+end end
+if flate then
+ local streams=utilities.streams
+ local openfile=streams.open
+ local closestream=streams.close
+ local setposition=streams.setposition
+ local getsize=streams.size
+ local readcardinal4=streams.readcardinal4le
+ local getstring=streams.getstring
+ local decompress=flate.gz_decompress
+ function zipfiles.gunzipfile(filename)
+ local strm=openfile(filename)
+ if strm then
+ setposition(strm,getsize(strm)-4+1)
+ local size=readcardinal4(strm)
+ local data=decompress(getstring(strm),size)
+ closestream(strm)
+ return data
+ end
+ end
+elseif gzip then
+ local openfile=gzip.open
+ function zipfiles.gunzipfile(filename)
+ local g=openfile(filename,"rb")
+ if g then
+ local d=g:read("*a")
+ d:close()
+ return d
+ end
+ end
+end
+
+
+end -- of closure
+
+do -- create closure to overcome 200 locals limit
+
package.loaded["lxml-tab"] = package.loaded["lxml-tab"] or true
-- original size: 60383, stripped down to: 35698
@@ -16892,7 +17646,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-lpt"] = package.loaded["lxml-lpt"] or true
--- original size: 54551, stripped down to: 30745
+-- original size: 55145, stripped down to: 30992
if not modules then modules={} end modules ['lxml-lpt']={
version=1.001,
@@ -16972,7 +17726,8 @@ apply_axis['self']=function(list)
return list
end
apply_axis['child']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local dt=ll.dt
@@ -17044,7 +17799,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
c=collect(list[l],collected,c)
end
@@ -17085,7 +17841,8 @@ local function collect(list,collected,c)
return c
end
apply_axis['descendant-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
if ll.special~=true then
@@ -17097,7 +17854,8 @@ apply_axis['descendant-or-self']=function(list)
return collected
end
apply_axis['ancestor']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
while ll do
@@ -17111,7 +17869,8 @@ apply_axis['ancestor']=function(list)
return collected
end
apply_axis['ancestor-or-self']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
c=c+1
@@ -17127,7 +17886,8 @@ apply_axis['ancestor-or-self']=function(list)
return collected
end
apply_axis['parent']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local pl=list[l].__p__
if pl then
@@ -17150,7 +17910,8 @@ apply_axis['preceding']=function(list)
return {}
end
apply_axis['following-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17166,7 +17927,8 @@ apply_axis['following-sibling']=function(list)
return collected
end
apply_axis['preceding-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17182,7 +17944,8 @@ apply_axis['preceding-sibling']=function(list)
return collected
end
apply_axis['reverse-sibling']=function(list)
- local collected,c={},0
+ local collected={}
+ local c=0
for l=1,#list do
local ll=list[l]
local p=ll.__p__
@@ -17205,7 +17968,8 @@ apply_axis['initial-child']=apply_axis['child']
local function apply_nodes(list,directive,nodes)
local maxn=#nodes
if maxn==3 then
- local nns,ntg=nodes[2],nodes[3]
+ local nns=nodes[2]
+ local ntg=nodes[3]
if not nns and not ntg then
if directive then
return list
@@ -17213,7 +17977,10 @@ local function apply_nodes(list,directive,nodes)
return {}
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
if not nns then
for l=1,#list do
local ll=list[l]
@@ -17221,14 +17988,16 @@ local function apply_nodes(list,directive,nodes)
if ltg then
if directive then
if ntg==ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif ntg~=ltg then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17239,14 +18008,16 @@ local function apply_nodes(list,directive,nodes)
if lns then
if directive then
if lns==nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif lns~=nns then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17259,14 +18030,16 @@ local function apply_nodes(list,directive,nodes)
local ok=ltg==ntg and lns==nns
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17274,7 +18047,10 @@ local function apply_nodes(list,directive,nodes)
return collected
end
else
- local collected,c,m,p={},0,0,nil
+ local collected={}
+ local c=0
+ local m=0
+ local p=nil
for l=1,#list do
local ll=list[l]
local ltg=ll.tg
@@ -17282,7 +18058,8 @@ local function apply_nodes(list,directive,nodes)
local lns=ll.rn or ll.ns
local ok=false
for n=1,maxn,3 do
- local nns,ntg=nodes[n+1],nodes[n+2]
+ local nns=nodes[n+1]
+ local ntg=nodes[n+2]
ok=(not ntg or ltg==ntg) and (not nns or lns==nns)
if ok then
break
@@ -17290,14 +18067,16 @@ local function apply_nodes(list,directive,nodes)
end
if directive then
if ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
elseif not ok then
- local llp=ll.__p__;if llp~=p then p,m=llp,1 else m=m+1 end
+ local llp=ll.__p__;if llp~=p then p=llp;m=1 else m=m+1 end
c=c+1
- collected[c],ll.mi=ll,m
+ collected[c]=ll
+ ll.mi=m
end
end
end
@@ -17306,7 +18085,8 @@ local function apply_nodes(list,directive,nodes)
end
local quit_expression=false
local function apply_expression(list,expression,order)
- local collected,c={},0
+ local collected={}
+ local c=0
quit_expression=false
for l=1,#list do
local ll=list[l]
@@ -17560,7 +18340,8 @@ local function tagstostring(list)
local t={}
for i=1,#list do
local li=list[i]
- local ns,tg=li.ns,li.tg
+ local ns=li.ns
+ local tg=li.tg
if not ns or ns=="" then ns="*" end
if not tg or tg=="" then tg="*" end
t[i]=(tg=="@rt@" and "[root]") or format("%s:%s",ns,tg)
@@ -17924,7 +18705,8 @@ expressions.name=function(e,n)
if n==0 then
found=type(e)=="table" and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17937,7 +18719,8 @@ expressions.name=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -17951,7 +18734,8 @@ expressions.name=function(e,n)
end
end
if found then
- local ns,tg=found.rn or found.ns or "",found.tg
+ local ns=found.rn or found.ns or ""
+ local tg=found.tg
if ns~="" then
return ns..":"..tg
else
@@ -17970,7 +18754,8 @@ expressions.tag=function(e,n)
if n==0 then
found=(type(e)=="table") and e
elseif n<0 then
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k-1,1,-1 do
local di=d[i]
if type(di)=="table" then
@@ -17983,7 +18768,8 @@ expressions.tag=function(e,n)
end
end
else
- local d,k=e.__p__.dt,e.ni
+ local d=e.__p__.dt
+ local k=e.ni
for i=k+1,#d,1 do
local di=d[i]
if type(di)=="table" then
@@ -18163,7 +18949,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["lxml-aux"] = package.loaded["lxml-aux"] or true
--- original size: 30650, stripped down to: 19621
+-- original size: 30771, stripped down to: 19680
if not modules then modules={} end modules ['lxml-aux']={
version=1.001,
@@ -18278,10 +19064,12 @@ end
function xml.collect_tags(root,pattern,nonamespace)
local collected=xmlapplylpath(root,pattern)
if collected then
- local t,n={},0
+ local t={}
+ local n=0
for c=1,#collected do
local e=collected[c]
- local ns,tg=e.ns,e.tg
+ local ns=e.ns
+ local tg=e.tg
n=n+1
if nonamespace then
t[n]=tg
@@ -18436,7 +19224,9 @@ local function inject_element(root,pattern,whatever,prepend)
local collected=element and xmlapplylpath(root,pattern)
local function inject_e(e)
local r=e.__p__
- local d,k,rri=r.dt,e.ni,r.ri
+ local d=r.dt
+ local k=e.ni
+ local rri=r.ri
local edt=(rri and d[rri].dt) or (d and d[k] and d[k].dt)
if edt then
local be,af
@@ -18473,7 +19263,8 @@ local function insert_element(root,pattern,whatever,before)
local collected=element and xmlapplylpath(root,pattern)
local function insert_e(e)
local r=e.__p__
- local d,k=r.dt,e.ni
+ local d=r.dt
+ local k=e.ni
if not before then
k=k+1
end
@@ -18903,8 +19694,10 @@ function xml.separate(x,pattern)
report_xml("warning: xml.separate changes root")
x=d
end
- local t,n={ "\n" },1
- local i,nd=1,#d
+ local t={ "\n" }
+ local n=1
+ local i=1
+ local nd=#d
while i<=nd do
while i<=nd do
local di=d[i]
@@ -19885,7 +20678,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-exp"] = package.loaded["data-exp"] or true
--- original size: 18105, stripped down to: 10389
+-- original size: 18154, stripped down to: 10416
if not modules then modules={} end modules ['data-exp']={
version=1.001,
@@ -20092,9 +20885,11 @@ local function scan(files,remap,spec,path,n,m,r,onlyone,tolerant)
local pattern=tolerant and lessweird or weird
local filelist={}
local noffiles=0
- for name in directory(full) do
+ for name,mode in directory(full) do
if not lpegmatch(pattern,name) then
- local mode=attributes(full..name,"mode")
+ if not mode then
+ mode=attributes(full..name,"mode")
+ end
if mode=="file" then
n=n+1
noffiles=noffiles+1
@@ -20575,7 +21370,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-tmp"] = package.loaded["data-tmp"] or true
--- original size: 16116, stripped down to: 10782
+-- original size: 16284, stripped down to: 10938
if not modules then modules={} end modules ['data-tmp']={
version=1.100,
@@ -20615,6 +21410,7 @@ caches.force=true
caches.ask=false
caches.relocate=false
caches.defaults={ "TMPDIR","TEMPDIR","TMP","TEMP","HOME","HOMEPATH" }
+directives.register("system.caches.fast",function(v) caches.fast=true end)
local writable,readables,usedreadables=nil,{},{}
local function identify()
local texmfcaches=resolvers.cleanpathlist("TEXMFCACHE")
@@ -20848,7 +21644,9 @@ local saveoptions={ compact=true }
function caches.savedata(filepath,filename,data,raw)
local tmaname,tmcname=caches.setluanames(filepath,filename)
data.cache_uuid=os.uuid()
- if caches.direct then
+ if caches.fast then
+ file.savedata(tmaname,table.fastserialize(data,true))
+ elseif caches.direct then
file.savedata(tmaname,table.serialize(data,true,saveoptions))
else
table.tofile(tmaname,data,true,saveoptions)
@@ -23182,7 +23980,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-zip"] = package.loaded["data-zip"] or true
--- original size: 8700, stripped down to: 6313
+-- original size: 10263, stripped down to: 7556
if not modules then modules={} end modules ['data-zip']={
version=1.001,
@@ -23201,6 +23999,65 @@ local archives=zip.archives or {}
zip.archives=archives
local registeredfiles=zip.registeredfiles or {}
zip.registeredfiles=registeredfiles
+local zipfiles=utilities.zipfiles
+local openzip,closezip,validfile,wholefile,filehandle,traversezip
+if zipfiles then
+ local ipairs=ipairs
+ openzip=zipfiles.open
+ closezip=zipfiles.close
+ validfile=zipfiles.found
+ wholefile=zipfiles.unzip
+ traversezip=function(zfile)
+ return ipairs(zipfiles.list(zfile))
+ end
+ local streams=utilities.streams
+ local openstream=streams.open
+ local readstring=streams.readstring
+ local streamsize=streams.size
+ local metatable={
+ close=streams.close,
+ read=function(stream,n)
+ readstring(stream,n=="*a" and streamsize(stream) or n)
+ end
+ }
+ filehandle=function(zfile,queryname)
+ local data=wholefile(zfile,queryname)
+ if data then
+ local stream=openstream(data)
+ if stream then
+ return setmetatableindex(stream,metatable)
+ end
+ end
+ end
+else
+ openzip=zip.open
+ closezip=zip.close
+ validfile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ dfile:close()
+ return true
+ end
+ return false
+ end
+ traversezip=function(zfile)
+ return z:files()
+ end
+ wholefile=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ local s=dfile:read("*all")
+ dfile:close()
+ return s
+ end
+ end
+ filehandle=function(zfile,queryname)
+ local dfile=zfile:open(queryname)
+ if dfile then
+ return dfile
+ end
+ end
+end
local function validzip(str)
if not find(str,"^zip://") then
return "zip:///"..str
@@ -23215,7 +24072,7 @@ function zip.openarchive(name)
local arch=archives[name]
if not arch then
local full=resolvers.findfile(name) or ""
- arch=full~="" and zip.open(full) or false
+ arch=full~="" and openzip(full) or false
archives[name]=arch
end
return arch
@@ -23223,7 +24080,7 @@ function zip.openarchive(name)
end
function zip.closearchive(name)
if not name or (name=="" and archives[name]) then
- zip.close(archives[name])
+ closezip(archives[name])
archives[name]=nil
end
end
@@ -23264,9 +24121,7 @@ function resolvers.finders.zip(specification)
if trace_locating then
report_zip("finder: archive %a found",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
- dfile:close()
+ if validfile(zfile,queryname) then
if trace_locating then
report_zip("finder: file %a found",queryname)
end
@@ -23296,12 +24151,12 @@ function resolvers.openers.zip(specification)
if trace_locating then
report_zip("opener; archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local handle=filehandle(zfile,queryname)
+ if handle then
if trace_locating then
report_zip("opener: file %a found",queryname)
end
- return resolvers.openers.helpers.textopener('zip',original,dfile)
+ return resolvers.openers.helpers.textopener('zip',original,handle)
elseif trace_locating then
report_zip("opener: file %a not found",queryname)
end
@@ -23327,15 +24182,13 @@ function resolvers.loaders.zip(specification)
if trace_locating then
report_zip("loader: archive %a opened",archive)
end
- local dfile=zfile:open(queryname)
- if dfile then
+ local data=wholefile(zfile,queryname)
+ if data then
logs.show_load(original)
if trace_locating then
report_zip("loader; file %a loaded",original)
end
- local s=dfile:read("*all")
- dfile:close()
- return true,s,#s
+ return true,data,#data
elseif trace_locating then
report_zip("loader: file %a not found",queryname)
end
@@ -23382,7 +24235,7 @@ function resolvers.registerzipfile(z,tree)
if trace_locating then
report_zip("registering: using filter %a",filter)
end
- for i in z:files() do
+ for i in traversezip(z) do
local filename=i.filename
local path,name=match(filename,filter)
if not path then
@@ -23911,7 +24764,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["data-aux"] = package.loaded["data-aux"] or true
--- original size: 2438, stripped down to: 1863
+-- original size: 2452, stripped down to: 1877
if not modules then modules={} end modules ['data-aux']={
version=1.001,
@@ -23959,7 +24812,7 @@ function resolvers.updatescript(oldname,newname)
local newdata=io.loaddata(newscript)
if newdata then
if trace_locating then
- report_scripts("old script content replaced by new content")
+ report_scripts("old script content replaced by new content: %s",oldscript)
end
io.savedata(oldscript,newdata)
break
@@ -24516,7 +25369,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["luat-fmt"] = package.loaded["luat-fmt"] or true
--- original size: 9346, stripped down to: 7085
+-- original size: 9637, stripped down to: 7253
if not modules then modules={} end modules ['luat-fmt']={
version=1.001,
@@ -24536,9 +25389,6 @@ local function primaryflags()
if arguments.silent then
flags[#flags+1]="--interaction=batchmode"
end
- if arguments.jit then
- flags[#flags+1]="--jiton"
- end
return concat(flags," ")
end
local function secondaryflags()
@@ -24567,6 +25417,9 @@ local function secondaryflags()
if arguments.strip then
flags[#flags+1]="--c:strip"
end
+ if arguments.lmtx then
+ flags[#flags+1]="--c:lmtx"
+ end
return concat(flags," ")
end
local template=[[--ini %primaryflags% --lua=%luafile% %texfile% %secondaryflags% %dump% %redirect%]]
@@ -24586,6 +25439,13 @@ local runners={
checkers=checkers,
reporter=report_format,
},
+ luametatex=sandbox.registerrunner {
+ name="make luametatex format",
+ program="luametatex",
+ template=template,
+ checkers=checkers,
+ reporter=report_format,
+ },
luajittex=sandbox.registerrunner {
name="make luajittex format",
program="luajittex",
@@ -24753,10 +25613,10 @@ end
end -- of closure
--- used libraries : 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 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 util-lib.lua luat-sta.lua luat-fmt.lua
+-- 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 util-lib.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 989477
--- stripped bytes : 393339
+-- original bytes : 1020503
+-- stripped bytes : 404014
-- end library merge
@@ -24779,6 +25639,7 @@ local owntree = environment and environment.ownpath or ownpath
local ownlibs = { -- order can be made better
+ 'l-bit32.lua',
'l-lua.lua',
'l-macro.lua',
'l-sandbox.lua',
@@ -24836,6 +25697,8 @@ local ownlibs = { -- order can be made better
'util-env.lua',
'luat-env.lua', -- can come before inf (as in mkiv)
+ 'util-zip.lua',
+
'lxml-tab.lua',
'lxml-lpt.lua',
-- 'lxml-ent.lua',