24 code = compressed:read("*a"); |
24 code = compressed:read("*a"); |
25 |
25 |
26 local maxequals = 0; |
26 local maxequals = 0; |
27 code:gsub("(=+)", function (equals_string) maxequals = math.max(maxequals, #equals_string); end); |
27 code:gsub("(=+)", function (equals_string) maxequals = math.max(maxequals, #equals_string); end); |
28 |
28 |
29 outfile:write(require_resource "gunzip.lua"); |
29 outfile:write("local ungz = (function ()", require_resource "gunzip.lua", " end)()\n"); |
30 |
30 |
31 outfile:write[[function _gunzip(data) local uncompressed = {}; |
31 outfile:write[[return assert(loadstring((function (i)local o={} ungz{input=i,output=function(b)table.insert(o,string.char(b))end}return table.concat(o)end) ]]; |
32 gunzip{input=data,output=function(b) table.insert(uncompressed, string.char(b)) end}; |
|
33 return table.concat(uncompressed, ""); end ]]; |
|
34 |
32 |
35 outfile:write [[return assert(loadstring(_gunzip]] |
33 --outfile:write [[return assert(loadstring(_gunzip]] |
36 outfile:write(string.format("%q", code)); |
34 outfile:write(string.format("%q", code)); |
37 --outfile:write("[", string.rep("=", maxequals+1), "[", code, "]", string.rep("=", maxequals+1), "]"); |
35 --outfile:write("[", string.rep("=", maxequals+1), "[", code, "]", string.rep("=", maxequals+1), "]"); |
38 outfile:write(", '@", outfile_fn,"'))()"); |
36 outfile:write(", '@", outfile_fn,"'))()"); |
39 outfile:close(); |
37 outfile:close(); |
40 os.rename(outfile_fn..".gzipped", outfile_fn); |
38 os.rename(outfile_fn..".gzipped", outfile_fn); |