ws-cleanup-types: archive, audio, data, font, image, layered, music, playlist, subtitle, vector, video: annotations, casts, one value per re-assignment where the solver loses the type
This commit is contained in:
1 parent
dc98aec2ec
commit
f459b2dcdf
44 files changed
+172
-119
No files matched your search
@@ -177,7 +177,8 @@ local function folder(r: Bytes.Reader): Folder
|
||||
check(r)
|
||||
local nin, nout = 1, 1
|
||||
if bit32.band(flags, 0x10) ~= 0 then
|
||||
nin, nout = number(r), number(r)
|
||||
nin = number(r)
|
||||
nout = number(r)
|
||||
if nin > 64 or nout > 64 then
|
||||
bad(r, "bad coder stream count")
|
||||
end
|
||||
@@ -416,11 +417,11 @@ local function filesInfo(r: Bytes.Reader): { File }
|
||||
if n > 1000000 then
|
||||
bad(r, "too many files", Err.LIMIT)
|
||||
end
|
||||
local files: { File } = table.create(n)
|
||||
local files: { File } = table.create(n) :: { File }
|
||||
for i = 1, n do
|
||||
files[i] = { name = "", emptyStream = false, emptyFile = false, anti = false }
|
||||
end
|
||||
local empties = {}
|
||||
local empties: { number } = {}
|
||||
while true do
|
||||
local t = byte(r)
|
||||
if t == K.End then
|
||||
|
||||
@@ -144,7 +144,9 @@ local function decodeFolder(ctx: Ctx, s: Header.Streams, f: Header.Folder): (buf
|
||||
if not b then
|
||||
return nil, e
|
||||
end
|
||||
src, so, sl = b, 0, buffer.len(b)
|
||||
src = b
|
||||
so = 0
|
||||
sl = buffer.len(b)
|
||||
else
|
||||
local k = table.find(f.packed, inIdx)
|
||||
if not k then
|
||||
@@ -162,7 +164,7 @@ local function decodeFolder(ctx: Ctx, s: Header.Streams, f: Header.Folder): (buf
|
||||
src = ctx.buf
|
||||
end
|
||||
local id = c.id
|
||||
local opts = { maxBytes = ctx.maxBytes }
|
||||
local opts: { maxBytes: number?, verify: boolean? } = { maxBytes = ctx.maxBytes }
|
||||
if id == "\0" then
|
||||
if sl < size then
|
||||
return nil, Err.new(Err.TRUNCATED, "short stored stream")
|
||||
@@ -226,7 +228,7 @@ local function folderMethod(f: Header.Folder): string
|
||||
end
|
||||
|
||||
function SevenZip.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Archive?, Err.Err?)
|
||||
local o = opts or {}
|
||||
local o: DecodeOptions = opts or {}
|
||||
local maxBytes = if type(o.maxBytes) == "number" then o.maxBytes else 2 ^ 30
|
||||
local checkCrc = o.checkCrc ~= false
|
||||
local b, base, limit = r.buf, r.base, r.limit
|
||||
@@ -280,17 +282,19 @@ function SevenZip.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Archive?
|
||||
if f.crc and Crc32.raw(hb, 0, buffer.len(hb)) ~= f.crc then
|
||||
return nil, Err.new(Err.CHECKSUM, "encoded header CRC-32 mismatch")
|
||||
end
|
||||
hbuf, hoff, hlen = hb, 0, buffer.len(hb)
|
||||
hbuf = hb
|
||||
hoff = 0
|
||||
hlen = buffer.len(hb)
|
||||
end
|
||||
if not parsed then
|
||||
return nil, Err.new(Err.CORRUPT, "nested encoded headers")
|
||||
end
|
||||
local s = parsed.streams or { packPos = 0, packSizes = {}, folders = {}, subSizes = {}, subCrcs = {} }
|
||||
local s: Header.Streams = parsed.streams or { packPos = 0, packSizes = {}, folders = {}, subSizes = {}, subCrcs = {} }
|
||||
a.meta.folders = #s.folders
|
||||
a.meta.solid = false
|
||||
-- folder caches and the substream -> folder map
|
||||
local cache: { [number]: buffer } = {}
|
||||
local subFolder, subOffset = {}, {}
|
||||
local subFolder: { number }, subOffset: { number } = {}, {}
|
||||
do
|
||||
local si = 1
|
||||
for fi, f in s.folders do
|
||||
|
||||
Reference in new issue
Block a user