gzip: Some changes to make embedding decompression code compatible with uglify

Thu, 27 May 2010 15:31:53 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 27 May 2010 15:31:53 +0100
changeset 65
41aeda62af16
parent 64
4beddef56d73
child 66
28feb008ca2a

gzip: Some changes to make embedding decompression code compatible with uglify

gzip/deflatelua.lua file | annotate | diff | comparison | revisions
gzip/squish.gzip.lua file | annotate | diff | comparison | revisions
--- 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)
 
--- 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,"'))()");

mercurial