summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-ctan.lua3
-rw-r--r--scripts/context/lua/mtx-install-modules.lua323
-rw-r--r--scripts/context/lua/mtx-install-tikz.lua162
-rw-r--r--scripts/context/lua/mtxrun.lua184
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua184
-rw-r--r--scripts/context/stubs/unix/mtxrun184
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua184
7 files changed, 793 insertions, 431 deletions
diff --git a/scripts/context/lua/mtx-ctan.lua b/scripts/context/lua/mtx-ctan.lua
index 6de51caa3..7603e363b 100644
--- a/scripts/context/lua/mtx-ctan.lua
+++ b/scripts/context/lua/mtx-ctan.lua
@@ -141,6 +141,7 @@ end
local function checkedpattern(pattern)
if pattern then
+ pattern = string.topattern(pattern,true)
return lower(shaped(pattern))
end
end
@@ -291,7 +292,7 @@ scripts.ctan.topics = json and
found[#found+1] = { key or name, details }
end
else
- if strfound(pattern,name) or strfound(pattern,details) then
+ if strfound(pattern,key or name) or strfound(pattern,details) then
found[#found+1] = { key or name, details }
end
end
diff --git a/scripts/context/lua/mtx-install-modules.lua b/scripts/context/lua/mtx-install-modules.lua
new file mode 100644
index 000000000..590e321fe
--- /dev/null
+++ b/scripts/context/lua/mtx-install-modules.lua
@@ -0,0 +1,323 @@
+if not modules then modules = { } end modules ['mtx-install-modules'] = {
+ version = 1.234,
+ comment = "companion to mtxrun.lua",
+ author = "Hans Hagen",
+ copyright = "ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Installing tikz is a bit tricky because there are many packages involved and it's
+-- sort of impossible to derive from the names what to include in the installation.
+-- I tried to use the ctan scrips we ship but there is no way to reliably derive a
+-- set from the topics or packages using the web api (there are also some
+-- inconsistencies between the json and xml interfaces that will not be fixed). A
+-- wildcard pull of everything tikz/pgf is likely to fail or at least gives files we
+-- don't want and/or need, the solution is to be specific.
+--
+-- After that was implemented the script changed name and now also installs the
+-- third party modules.
+--
+-- We use curl and not the built in socket library because all kind of ssl and
+-- redirection can kick in and who know how it evolves.
+--
+-- We use the context unzipper because we cannot be sure if unzip is present on the
+-- system. In many cases windows, linux and osx installations lack it by default.
+--
+-- This script should be run in the tex root where there is also a texmf-context sub
+-- directory; it will quit otherwise. The modules path will be created when absent.
+--
+-- Maybe some day we can get the modules from ctan but then we need a consistent
+-- names and such.
+
+local helpinfo = [[
+<?xml version="1.0"?>
+<application>
+ <metadata>
+ <entry name="name">mtx-install</entry>
+ <entry name="detail">ConTeXt Installer</entry>
+ <entry name="version">2.01</entry>
+ </metadata>
+ <flags>
+ <category name="basic">
+ <subcategory>
+ <flag name="list"><short>list modules</short></flag>
+ <flag name="install"><short>install modules</short></flag>
+ <flag name="module"><short>install (zip) file(s)</short></flag>
+ </subcategory>
+ </category>
+ </flags>
+ <examples>
+ <category>
+ <title>Examples</title>
+ <subcategory>
+ <example><command>mtxrun --script install-modules --list</command></example>
+ </subcategory>
+ <subcategory>
+ <example><command>mtxrun --script install-modules --install filter letter</command></example>
+ <example><command>mtxrun --script install-modules --install tikz</command></example>
+ <example><command>mtxrun --script install-modules --install --all</command></example>
+ </subcategory>
+ <subcategory>
+ <example><command>mtxrun --script install-modules --install --module t-letter.zip</command></example>
+ </subcategory>
+ </category>
+ </examples>
+</application>
+]]
+
+
+local application = logs.application {
+ name = "mtx-install-modules",
+ banner = "ConTeXt Module Installer 1.00",
+ helpinfo = helpinfo,
+}
+
+local report = application.report
+
+scripts = scripts or { }
+scripts.modules = scripts.modules or { }
+
+local okay, curl = pcall(require,"libs-imp-curl")
+
+local fetched = curl and curl.fetch and function(str)
+ local data, message = curl.fetch {
+ url = str,
+ followlocation = true,
+ sslverifyhost = false,
+ sslverifypeer = false,
+ }
+ if not data then
+ report("some error: %s",message)
+ end
+ return data
+end or function(str)
+ -- So, no redirect to http, which means that we cannot use the built in socket
+ -- library. What if the client is happy with http?
+ local data = os.resultof("curl -sSL " .. str)
+ return data
+end
+
+local urls = {
+ ctan = "https://mirrors.ctan.org/install",
+ modules = "https://modules.contextgarden.net/dl"
+}
+
+local tmpzipfile = "temp.zip"
+local checkdir = "texmf-context"
+local targetdir = "texmf-modules"
+
+local function install(list)
+ if type(list) ~= "table"then
+ report("unknown specification")
+ end
+ local zips = list.zips
+ local wipes = list.wipes
+ if type(zips) ~= "table" then
+ report("incomplete specification")
+ else
+ report("installing into %a",targetdir)
+ for i=1,#zips do
+ local where = urls[list.url] .. "/" .. zips[i]
+ local data = fetched(where)
+ if string.find(data,"^PK") then
+ io.savedata(tmpzipfile,data)
+ report("from %a",where)
+ report("into %a",targetdir)
+ utilities.zipfiles.unzipdir {
+ zipname = tmpzipfile,
+ path = ".",
+ verbose = "steps",
+ }
+ os.remove(tmpzipfile)
+ else
+ report("unknown %a",where)
+ end
+ end
+
+ local function wiper(wipes)
+ for i=1,#wipes do
+ local s = wipes[i]
+ if type(s) == "table" then
+ wiper(s)
+ elseif type(s) == "string" then
+ local t = dir.glob(s)
+ report("wiping %i files in %a",#t,s)
+ for i=1,#t do
+ os.remove(t[i])
+ end
+ end
+ end
+ end
+
+ if type(wipes) == "table" then
+ wiper(wipes)
+ end
+ end
+end
+
+local function wipers(s)
+ return {
+ "tex/context/third/" ..s.. "/**",
+ "doc/context/third/" ..s.. "/**",
+ "source/context/third/" ..s.. "/**",
+
+ "tex/context/" ..s.. "/**",
+ "doc/context/" ..s.. "/**",
+ "source/context/" ..s.. "/**",
+
+ "scripts/" ..s.. "/**",
+ }
+end
+
+local defaults = {
+ "tex/latex/**",
+ "tex/plain/**",
+
+ "doc/latex/**",
+ "doc/plain/**",
+ "doc/generic/**",
+
+ "source/latex/**",
+ "source/plain/**",
+ "source/generic/**",
+}
+
+local lists = {
+ ["tikz"] = {
+ url = "ctan",
+ zips = {
+ "graphics/pgf/base/pgf.tds.zip",
+ "graphics/pgf/contrib/pgfplots.tds.zip",
+ "graphics/pgf/contrib/circuitikz.tds.zip",
+ },
+ wipes = {
+ wipers("pgf"),
+ wipers("pgfplots"),
+ wipers("circuitikz"),
+ defaults,
+ }
+ },
+ -- from the context garden
+ ["pocketdiary"] = { url = "modules", zips = { "Collection-of-calendars-based-on-PocketDiary-module.zip" } },
+ ["collating"] = { url = "modules", zips = { "Environment-for-collating-marks.zip" } },
+ ["account"] = { url = "modules", zips = { "t-account.zip" } },
+ ["algorithmic"] = { url = "modules", zips = { "t-algorithmic.zip" } },
+ ["animation"] = { url = "modules", zips = { "t-animation.zip" } },
+ ["annotation"] = { url = "modules", zips = { "t-annotation.zip" } },
+ ["aquamints"] = { url = "modules", zips = { "aquamints.zip" } },
+ ["bibmod-doc"] = { url = "modules", zips = { "bibmod-doc.zip" } },
+ -- ["bnf-0.3"] = { url = "modules", zips = { "t-bnf-0.3.zip" } },
+ ["bnf"] = { url = "modules", zips = { "t-bnf.zip" } },
+ ["chromato"] = { url = "modules", zips = { "t-chromato.zip" } },
+ ["cmscbf"] = { url = "modules", zips = { "t-cmscbf.zip" } },
+ ["cmttbf"] = { url = "modules", zips = { "t-cmttbf.zip" } },
+ ["crossref"] = { url = "modules", zips = { "t-crossref.zip" } },
+ ["cyrillicnumbers"] = { url = "modules", zips = { "t-cyrillicnumbers.zip" } },
+ ["degrade"] = { url = "modules", zips = { "t-degrade.zip" } },
+ ["enigma"] = { url = "modules", zips = { "enigma.zip" } },
+ ["fancybreak"] = { url = "modules", zips = { "t-fancybreak.zip" } },
+ ["filter"] = { url = "modules", zips = { "t-filter.zip" } },
+ ["french"] = { url = "modules", zips = { "t-french.zip" } },
+ ["fullpage"] = { url = "modules", zips = { "t-fullpage.zip" } },
+ ["gantt"] = { url = "modules", zips = { "t-gantt.zip" } },
+ ["gfsdidot"] = { url = "modules", zips = { "gfsdidot.zip" } },
+ ["gm"] = { url = "modules", zips = { "t-gm.zip" } },
+ ["gnuplot"] = { url = "modules", zips = { "t-gnuplot.zip" } },
+ ["greek"] = { url = "modules", zips = { "t-greek.zip" } },
+ ["grph-downsample"] = { url = "modules", zips = { "grph-downsample.lua.zip" } },
+ ["gs"] = { url = "modules", zips = { "t-gs.zip" } },
+ ["high"] = { url = "modules", zips = { "high.zip" } },
+ ["inifile"] = { url = "modules", zips = { "t-inifile.zip" } },
+ ["karnaugh"] = { url = "modules", zips = { "karnaugh.zip" } },
+ ["layout"] = { url = "modules", zips = { "t-layout.zip" } },
+ ["letter"] = { url = "modules", zips = { "t-letter.zip" } },
+ ["letterspace"] = { url = "modules", zips = { "t-letterspace.mkiv.zip" } },
+ ["lettrine"] = { url = "modules", zips = { "t-lettrine.zip" } },
+ ["lua-widow-control"] = { url = "modules", zips = { "lua-widow-control.zip" } },
+ ["mathsets"] = { url = "modules", zips = { "t-mathsets.zip" } },
+ ["metaducks"] = { url = "modules", zips = { "metaducks.zip" } },
+ ["pret-c.lua"] = { url = "modules", zips = { "pret-c.lua.zip" } },
+ ["rst"] = { url = "modules", zips = { "t-rst.zip" } },
+ ["rsteps"] = { url = "modules", zips = { "t-rsteps.zip" } },
+ ["simplebib"] = { url = "modules", zips = { "t-simplebib.zip" } },
+ ["simplefonts"] = { url = "modules", zips = { "t-simplefonts.zip" } },
+ ["simpleslides"] = { url = "modules", zips = { "t-simpleslides.zip" } },
+ ["stormfontsupport"] = { url = "modules", zips = { "stormfontsupport.zip" } },
+ ["sudoku"] = { url = "modules", zips = { "sudoku.zip" } },
+ ["taspresent"] = { url = "modules", zips = { "t-taspresent.zip" } },
+ ["texshow"] = { url = "modules", zips = { "u-texshow.zip" } },
+ ["title"] = { url = "modules", zips = { "t-title.zip" } },
+ ["transliterator"] = { url = "modules", zips = { "t-transliterator.zip" } },
+ ["typearea"] = { url = "modules", zips = { "t-typearea.zip" } },
+ ["typescripts"] = { url = "modules", zips = { "t-typescripts.zip" } },
+ ["urwgaramond"] = { url = "modules", zips = { "f-urwgaramond.zip" } },
+ ["urwgothic"] = { url = "modules", zips = { "f-urwgothic.zip" } },
+ ["vim"] = { url = "modules", zips = { "t-vim.zip" } },
+ ["visualcounter"] = { url = "modules", zips = { "t-visualcounter.zip" } },
+}
+
+
+function scripts.modules.list()
+ for k, v in table.sortedhash(lists) do
+ report("%-20s: %-36s : % t",k,urls[v.url],v.zips)
+ end
+end
+
+function scripts.modules.install()
+ local curdir = dir.current()
+ local done = false
+ if not lfs.isdir(checkdir) then
+ report("unknown subdirectory %a",checkdir)
+ elseif not dir.mkdirs(targetdir) then
+ report("unable to create %a",targetdir)
+ elseif not lfs.chdir(targetdir) then
+ report("unable to go into %a",targetdir)
+ elseif environment.argument("module") or environment.argument("modules") then
+ local files = environment.files
+ if #files == 0 then
+ report("no archive names provided")
+ else
+ for i=1,#files do
+ local name = files[i]
+ install { url = "modules", zips = { file.addsuffix(name,"zip") } }
+ end
+ done = files
+ end
+ else
+ local files = environment.argument("all") and table.sortedkeys(lists) or environment.files
+ if #files == 0 then
+ report("no module names provided")
+ else
+ for i=1,#files do
+ local list = lists[files[i]]
+ if list then
+ install(list)
+ end
+ end
+ done = files
+ end
+ end
+ if done then
+ report()
+ report("renewing file database")
+ report()
+ resolvers.renewcache()
+ resolvers.load()
+ report()
+ report("installed: % t",done)
+ report()
+ end
+ lfs.chdir(curdir)
+end
+
+if environment.argument("list") then
+ scripts.modules.list()
+elseif environment.argument("install") then
+ scripts.modules.install()
+elseif environment.argument("exporthelp") then
+ application.export(environment.argument("exporthelp"),environment.files[1])
+else
+ application.help()
+ report("")
+end
+
diff --git a/scripts/context/lua/mtx-install-tikz.lua b/scripts/context/lua/mtx-install-tikz.lua
deleted file mode 100644
index 74a292241..000000000
--- a/scripts/context/lua/mtx-install-tikz.lua
+++ /dev/null
@@ -1,162 +0,0 @@
-if not modules then modules = { } end modules ['mtx-install-tikz'] = {
- version = 1.234,
- comment = "companion to mtxrun.lua",
- author = "Hans Hagen",
- copyright = "ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- Installing tikz is a bit tricky because there are many packages involved and it's
--- sort of impossible to derive from the names what to include in the installation.
--- I tried to use the ctan scrips we ship but there is no way to reliably derive a
--- set from the topics or packages using the web api (there are also some
--- inconsistencies between the jkson and xml interfaces that will not be fixed). A
--- wildcard pull of everything tikz/pgf is likely to fail or at least gives files we
--- don't want and/or need, the solution is to be specific.
---
--- We use curl and not the built in socket library because all kind of ssl and
--- redirection can kick in and who know how it evolves.
---
--- We use the context unzipper because we cannot be sure if unzip is present on the
--- system. In many cases windows, linux and osx installations lack it by default.
---
--- This script has no help info etc as it's a rather dumb downloader. One can always
--- do a better job than this suboptimal quick hack. Let me know if I forget to wipe
--- something.
---
--- mtxrun --script install-tikz
---
--- It should be run in the tex root and will quit when there is no texmf-context
--- path found. The modules path will be created when absent.
-
-local okay, curl = pcall(require,"libs-imp-curl")
-
-local fetched = curl and curl.fetch and function(str)
- local data, message = curl.fetch {
- url = str,
- followlocation = true,
- sslverifyhost = false,
- sslverifypeer = false,
- }
- if not data then
- report("some error: %s",message)
- end
- return data
-end or function(str)
- -- So, no redirect to http, which means that we cannot use the built in socket
- -- library. What if the client is happy with http?
- local data = os.resultof("curl -sSL " .. str)
- return data
-end
-
-local ctanurl = "https://mirrors.ctan.org/install"
-local tmpzipfile = "temp.zip"
-local checkdir = "texmf-context"
-local targetdir = "texmf-modules"
-
-local report = logs.reporter("install")
-
-scripts = scripts or { }
-scripts.ctan = scripts.ctan or { }
-
-function scripts.ctan.install(list)
- if type(list) ~= "table"then
- report("unknown specification")
- end
- local zips = list.zips
- local wipes = list.wipes
- if type(zips) ~= "table" or type(wipes) ~= "table" then
- report("incomplete specification")
- elseif not lfs.isdir(checkdir) then
- report("unknown subdirectory %a",checkdir)
- elseif not dir.mkdirs(targetdir) then
- report("unable to create %a",targetdir)
- elseif not lfs.chdir(targetdir) then
- report("unable to go into %a",targetdir)
- else
- report("installing into %a",targetdir)
- for i=1,#zips do
- local where = ctanurl .. "/" .. zips[i]
- local data = fetched(where)
- if string.find(data,"^PK") then
- io.savedata(tmpzipfile,data)
- report("from %a",where)
- report("into %a",targetdir)
- utilities.zipfiles.unzipdir {
- zipname = tmpzipfile,
- path = ".",
- verbose = "steps",
- }
- os.remove(tmpzipfile)
- else
- report("unknown %a",where)
- end
- end
-
- local function wiper(wipes)
- for i=1,#wipes do
- local s = wipes[i]
- if type(s) == "table" then
- wiper(s)
- elseif type(s) == "string" then
- local t = dir.glob(s)
- report("wiping %i files in %a",#t,s)
- for i=1,#t do
- os.remove(t[i])
- end
- end
- end
- end
-
- wiper(wipes)
-
- report("renewing file database")
- resolvers.renewcache()
- resolvers.load()
- end
-end
-
-local function wipers(s)
- return {
- "tex/context/third/" ..s.. "/**",
- "doc/context/third/" ..s.. "/**",
- "source/context/third/" ..s.. "/**",
-
- "tex/context/" ..s.. "/**",
- "doc/context/" ..s.. "/**",
- "source/context/" ..s.. "/**",
-
- "scripts/" ..s.. "/**",
- }
-end
-
-local defaults = {
- "tex/latex/**",
- "tex/plain/**",
-
- "doc/latex/**",
- "doc/plain/**",
- "doc/generic/**",
-
- "source/latex/**",
- "source/plain/**",
- "source/generic/**",
-}
-
-local lists = {
- tikz = {
- zips = {
- "graphics/pgf/base/pgf.tds.zip",
- "graphics/pgf/contrib/pgfplots.tds.zip",
- "graphics/pgf/contrib/circuitikz.tds.zip",
- },
- wipes = {
- wipers("pgf"),
- wipers("pgfplots"),
- wipers("circuitikz"),
- defaults,
- }
- },
-}
-
-scripts.ctan.install(lists.tikz)
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index f8ef74110..27c2e6cb0 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 23730, stripped down to: 14293
+-- original size: 32353, stripped down to: 16001
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -15902,11 +15902,13 @@ end
local files=utilities.files
local openfile=files.open
local closefile=files.close
+local getsize=files.size
local readstring=files.readstring
local readcardinal2=files.readcardinal2le
local readcardinal4=files.readcardinal4le
local setposition=files.setposition
local getposition=files.getposition
+local skipbytes=files.skip
local band=bit32.band
local rshift=bit32.rshift
local lshift=bit32.lshift
@@ -15929,6 +15931,55 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
handle=openfile(name,0),
}
end
+ local function update(handle,data)
+ position=data.offset
+ 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)
+ skipbytes(handle,4)
+ 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(handle,size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ end
+ if acceptable then
+ if filename~=data.filename then
+ else
+ position=position+30+namelength+extralength+skipped
+ data.position=position
+ return position
+ end
+ else
+ end
+ end
+ data.position=false
+ return false
+ end
local function collect(z)
if not z.list then
local list={}
@@ -15936,72 +15987,68 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
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
+ local size=getsize(handle)
+ for i=size-4,size-64*1024,-1 do
+ setposition(handle,i)
+ local enddirsignature=readcardinal4(handle)
+ if enddirsignature==0x06054B50 then
+ local thisdisknumber=readcardinal2(handle)
+ local centraldisknumber=readcardinal2(handle)
+ local thisnofentries=readcardinal2(handle)
+ local totalnofentries=readcardinal2(handle)
+ local centralsize=readcardinal4(handle)
+ local centraloffset=readcardinal4(handle)
+ local commentlength=readcardinal2(handle)
+ local comment=readstring(handle,length)
+ if size-i>=22 then
+ if thisdisknumber==centraldisknumber then
+ setposition(handle,centraloffset)
+ while true do
+ if readcardinal4(handle)==0x02014B50 then
+ skipbytes(handle,4)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ skipbytes(handle,4)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local commentlength=readcardinal2(handle)
+ skipbytes(handle,8)
+ local headeroffset=readcardinal4(handle)
+ local filename=readstring(handle,namelength)
+ skipbytes(handle,extralength+commentlength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=nil,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ offset=headeroffset,
+ }
+ hash[filename]=data
+ list[index]=data
+ end
+ else
+ break
+ end
+ end
+ end
+ break
end
- position=position+compressed
- else
- break
end
- z.list=list
- z.hash=hash
end
+ z.list=list
+ z.hash=hash
end
end
function getziplist(z)
@@ -16040,7 +16087,10 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
local handle=z.handle
local position=data.position
local compressed=data.compressed
- if compressed>0 then
+ if position==nil then
+ position=update(handle,data)
+ end
+ if position and compressed>0 then
setposition(handle,position)
local result=readstring(handle,compressed)
if data.method==8 then
@@ -26138,8 +26188,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1037585
--- stripped bytes : 408686
+-- original bytes : 1046208
+-- stripped bytes : 415601
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index f8ef74110..27c2e6cb0 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 23730, stripped down to: 14293
+-- original size: 32353, stripped down to: 16001
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -15902,11 +15902,13 @@ end
local files=utilities.files
local openfile=files.open
local closefile=files.close
+local getsize=files.size
local readstring=files.readstring
local readcardinal2=files.readcardinal2le
local readcardinal4=files.readcardinal4le
local setposition=files.setposition
local getposition=files.getposition
+local skipbytes=files.skip
local band=bit32.band
local rshift=bit32.rshift
local lshift=bit32.lshift
@@ -15929,6 +15931,55 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
handle=openfile(name,0),
}
end
+ local function update(handle,data)
+ position=data.offset
+ 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)
+ skipbytes(handle,4)
+ 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(handle,size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ end
+ if acceptable then
+ if filename~=data.filename then
+ else
+ position=position+30+namelength+extralength+skipped
+ data.position=position
+ return position
+ end
+ else
+ end
+ end
+ data.position=false
+ return false
+ end
local function collect(z)
if not z.list then
local list={}
@@ -15936,72 +15987,68 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
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
+ local size=getsize(handle)
+ for i=size-4,size-64*1024,-1 do
+ setposition(handle,i)
+ local enddirsignature=readcardinal4(handle)
+ if enddirsignature==0x06054B50 then
+ local thisdisknumber=readcardinal2(handle)
+ local centraldisknumber=readcardinal2(handle)
+ local thisnofentries=readcardinal2(handle)
+ local totalnofentries=readcardinal2(handle)
+ local centralsize=readcardinal4(handle)
+ local centraloffset=readcardinal4(handle)
+ local commentlength=readcardinal2(handle)
+ local comment=readstring(handle,length)
+ if size-i>=22 then
+ if thisdisknumber==centraldisknumber then
+ setposition(handle,centraloffset)
+ while true do
+ if readcardinal4(handle)==0x02014B50 then
+ skipbytes(handle,4)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ skipbytes(handle,4)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local commentlength=readcardinal2(handle)
+ skipbytes(handle,8)
+ local headeroffset=readcardinal4(handle)
+ local filename=readstring(handle,namelength)
+ skipbytes(handle,extralength+commentlength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=nil,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ offset=headeroffset,
+ }
+ hash[filename]=data
+ list[index]=data
+ end
+ else
+ break
+ end
+ end
+ end
+ break
end
- position=position+compressed
- else
- break
end
- z.list=list
- z.hash=hash
end
+ z.list=list
+ z.hash=hash
end
end
function getziplist(z)
@@ -16040,7 +16087,10 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
local handle=z.handle
local position=data.position
local compressed=data.compressed
- if compressed>0 then
+ if position==nil then
+ position=update(handle,data)
+ end
+ if position and compressed>0 then
setposition(handle,position)
local result=readstring(handle,compressed)
if data.method==8 then
@@ -26138,8 +26188,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1037585
--- stripped bytes : 408686
+-- original bytes : 1046208
+-- stripped bytes : 415601
-- end library merge
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index f8ef74110..27c2e6cb0 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 23730, stripped down to: 14293
+-- original size: 32353, stripped down to: 16001
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -15902,11 +15902,13 @@ end
local files=utilities.files
local openfile=files.open
local closefile=files.close
+local getsize=files.size
local readstring=files.readstring
local readcardinal2=files.readcardinal2le
local readcardinal4=files.readcardinal4le
local setposition=files.setposition
local getposition=files.getposition
+local skipbytes=files.skip
local band=bit32.band
local rshift=bit32.rshift
local lshift=bit32.lshift
@@ -15929,6 +15931,55 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
handle=openfile(name,0),
}
end
+ local function update(handle,data)
+ position=data.offset
+ 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)
+ skipbytes(handle,4)
+ 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(handle,size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ end
+ if acceptable then
+ if filename~=data.filename then
+ else
+ position=position+30+namelength+extralength+skipped
+ data.position=position
+ return position
+ end
+ else
+ end
+ end
+ data.position=false
+ return false
+ end
local function collect(z)
if not z.list then
local list={}
@@ -15936,72 +15987,68 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
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
+ local size=getsize(handle)
+ for i=size-4,size-64*1024,-1 do
+ setposition(handle,i)
+ local enddirsignature=readcardinal4(handle)
+ if enddirsignature==0x06054B50 then
+ local thisdisknumber=readcardinal2(handle)
+ local centraldisknumber=readcardinal2(handle)
+ local thisnofentries=readcardinal2(handle)
+ local totalnofentries=readcardinal2(handle)
+ local centralsize=readcardinal4(handle)
+ local centraloffset=readcardinal4(handle)
+ local commentlength=readcardinal2(handle)
+ local comment=readstring(handle,length)
+ if size-i>=22 then
+ if thisdisknumber==centraldisknumber then
+ setposition(handle,centraloffset)
+ while true do
+ if readcardinal4(handle)==0x02014B50 then
+ skipbytes(handle,4)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ skipbytes(handle,4)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local commentlength=readcardinal2(handle)
+ skipbytes(handle,8)
+ local headeroffset=readcardinal4(handle)
+ local filename=readstring(handle,namelength)
+ skipbytes(handle,extralength+commentlength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=nil,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ offset=headeroffset,
+ }
+ hash[filename]=data
+ list[index]=data
+ end
+ else
+ break
+ end
+ end
+ end
+ break
end
- position=position+compressed
- else
- break
end
- z.list=list
- z.hash=hash
end
+ z.list=list
+ z.hash=hash
end
end
function getziplist(z)
@@ -16040,7 +16087,10 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
local handle=z.handle
local position=data.position
local compressed=data.compressed
- if compressed>0 then
+ if position==nil then
+ position=update(handle,data)
+ end
+ if position and compressed>0 then
setposition(handle,position)
local result=readstring(handle,compressed)
if data.method==8 then
@@ -26138,8 +26188,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1037585
--- stripped bytes : 408686
+-- original bytes : 1046208
+-- stripped bytes : 415601
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index f8ef74110..27c2e6cb0 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 23730, stripped down to: 14293
+-- original size: 32353, stripped down to: 16001
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -15902,11 +15902,13 @@ end
local files=utilities.files
local openfile=files.open
local closefile=files.close
+local getsize=files.size
local readstring=files.readstring
local readcardinal2=files.readcardinal2le
local readcardinal4=files.readcardinal4le
local setposition=files.setposition
local getposition=files.getposition
+local skipbytes=files.skip
local band=bit32.band
local rshift=bit32.rshift
local lshift=bit32.lshift
@@ -15929,6 +15931,55 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
handle=openfile(name,0),
}
end
+ local function update(handle,data)
+ position=data.offset
+ 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)
+ skipbytes(handle,4)
+ 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(handle,size)
+ skipped=skipped+size+2
+ skipbytes(8)
+ skipped=skipped+8
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ size=readcardinal4(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+4
+ size=readcardinal2(handle)
+ skipbytes(handle,size)
+ skipped=skipped+size+2
+ end
+ if acceptable then
+ if filename~=data.filename then
+ else
+ position=position+30+namelength+extralength+skipped
+ data.position=position
+ return position
+ end
+ else
+ end
+ end
+ data.position=false
+ return false
+ end
local function collect(z)
if not z.list then
local list={}
@@ -15936,72 +15987,68 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
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
+ local size=getsize(handle)
+ for i=size-4,size-64*1024,-1 do
+ setposition(handle,i)
+ local enddirsignature=readcardinal4(handle)
+ if enddirsignature==0x06054B50 then
+ local thisdisknumber=readcardinal2(handle)
+ local centraldisknumber=readcardinal2(handle)
+ local thisnofentries=readcardinal2(handle)
+ local totalnofentries=readcardinal2(handle)
+ local centralsize=readcardinal4(handle)
+ local centraloffset=readcardinal4(handle)
+ local commentlength=readcardinal2(handle)
+ local comment=readstring(handle,length)
+ if size-i>=22 then
+ if thisdisknumber==centraldisknumber then
+ setposition(handle,centraloffset)
+ while true do
+ if readcardinal4(handle)==0x02014B50 then
+ skipbytes(handle,4)
+ local flag=readcardinal2(handle)
+ local method=readcardinal2(handle)
+ skipbytes(handle,4)
+ local crc32=readcardinal4(handle)
+ local compressed=readcardinal4(handle)
+ local uncompressed=readcardinal4(handle)
+ local namelength=readcardinal2(handle)
+ local extralength=readcardinal2(handle)
+ local commentlength=readcardinal2(handle)
+ skipbytes(handle,8)
+ local headeroffset=readcardinal4(handle)
+ local filename=readstring(handle,namelength)
+ skipbytes(handle,extralength+commentlength)
+ local descriptor=band(flag,8)~=0
+ local encrypted=band(flag,1)~=0
+ local acceptable=method==0 or method==8
+ if acceptable then
+ index=index+1
+ local data={
+ filename=filename,
+ index=index,
+ position=nil,
+ method=method,
+ compressed=compressed,
+ uncompressed=uncompressed,
+ crc32=crc32,
+ encrypted=encrypted,
+ offset=headeroffset,
+ }
+ hash[filename]=data
+ list[index]=data
+ end
+ else
+ break
+ end
+ end
+ end
+ break
end
- position=position+compressed
- else
- break
end
- z.list=list
- z.hash=hash
end
+ z.list=list
+ z.hash=hash
end
end
function getziplist(z)
@@ -16040,7 +16087,10 @@ local openzipfile,closezipfile,unzipfile,foundzipfile,getziphash,getziplist do
local handle=z.handle
local position=data.position
local compressed=data.compressed
- if compressed>0 then
+ if position==nil then
+ position=update(handle,data)
+ end
+ if position and compressed>0 then
setposition(handle,position)
local result=readstring(handle,compressed)
if data.method==8 then
@@ -26138,8 +26188,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1037585
--- stripped bytes : 408686
+-- original bytes : 1046208
+-- stripped bytes : 415601
-- end library merge