# HG changeset patch # User Matthew Wild # Date 1274970713 -3600 # Node ID 41aeda62af160ef6491e0cbe1059eba1d22154a3 # Parent 4beddef56d732d756d96db66244d81f1c16cfe75 gzip: Some changes to make embedding decompression code compatible with uglify diff -r 4beddef56d73 -r 41aeda62af16 gzip/deflatelua.lua --- a/gzip/deflatelua.lua Thu May 27 15:09:02 2010 +0100 +++ b/gzip/deflatelua.lua Thu May 27 15:31:53 2010 +0100 @@ -436,7 +436,7 @@ repeat until parse_block(bs, os) end -function gunzip(t) +return function (t) local bs = get_bitstream(t.input) local outbs = get_obytestream(t.output) diff -r 4beddef56d73 -r 41aeda62af16 gzip/squish.gzip.lua --- a/gzip/squish.gzip.lua Thu May 27 15:09:02 2010 +0100 +++ b/gzip/squish.gzip.lua Thu May 27 15:31:53 2010 +0100 @@ -26,13 +26,11 @@ local maxequals = 0; code:gsub("(=+)", function (equals_string) maxequals = math.max(maxequals, #equals_string); end); - outfile:write(require_resource "gunzip.lua"); + outfile:write("local ungz = (function ()", require_resource "gunzip.lua", " end)()\n"); - outfile:write[[function _gunzip(data) local uncompressed = {}; - gunzip{input=data,output=function(b) table.insert(uncompressed, string.char(b)) end}; - return table.concat(uncompressed, ""); end ]]; + 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) ]]; - outfile:write [[return assert(loadstring(_gunzip]] + --outfile:write [[return assert(loadstring(_gunzip]] outfile:write(string.format("%q", code)); --outfile:write("[", string.rep("=", maxequals+1), "[", code, "]", string.rep("=", maxequals+1), "]"); outfile:write(", '@", outfile_fn,"'))()");