Skip to content

Commit 9419b64

Browse files
committed
Squish error messages.
1 parent 94a67fe commit 9419b64

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

util/UNZIP.LUA

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ local function inflate(data)
229229
dv = db + da
230230

231231
if dv <= 0 or dv > op then
232-
error("invalid distance "..tostring(dv).." (outpos="..tostring(op)..")")
232+
error("Invalid distance " .. tostring(dv) .. " (outpos=" .. tostring(op) .. ")")
233233
end
234234

235235
-- bi = base index
@@ -238,7 +238,7 @@ local function inflate(data)
238238
end
239239
end
240240
else
241-
error("unsupported block type: "..tostring(t))
241+
error("Unsupported block type: "..tostring(t))
242242
end
243243

244244
if f == 1 then kg = false end
@@ -304,33 +304,33 @@ local function unzip(path)
304304
os = inflate(cd)
305305
else
306306
-- unsupported compression
307-
io.stderr:write("Unsupported compression method: "..tostring(cm).."\n")
307+
print("Unsupported compression")
308308
end
309309

310310
if os then
311-
if #os ~= us then
312-
io.stderr:write(string.format("Warning: uncompressed size mismatch for %s: expected %d, got %d\n", fn, us, #os))
313-
end
311+
if #os ~= us then print("Size mismatch") end
314312

315313
-- c = actual crc32
316-
local c = crc32(os)
317-
318-
if cr ~= c then
319-
io.stderr:write(string.format("CRC mismatch for %s: expected %08x, got %08x\n", fn, cr, c))
320-
end
321-
322314
-- di = directory
323-
local di = fn:match("(.+)/")
315+
-- of = output file
316+
local c, di, of = crc32(os)
317+
318+
if cr ~= c then print("CRC mismatch") end
324319

320+
di = fn:match("(.+)/")
325321
if di then
326322
if os.execute then
327323
-- portable make dir (POSIX/Windows-friendly-ish)
328324
os.execute('mkdir -p "'.. di ..'"')
329325
end
330326
end
331-
local of = assert(io.open(fn, "wb"))
332-
of:write(os)
333-
of:close()
327+
328+
of, di = io.open(fn, "wb")
329+
if di then
330+
print(di)
331+
else
332+
of:write(os) of:close()
333+
end
334334
end
335335

336336
p = st + cs

0 commit comments

Comments
 (0)