gzip/squish.gzip.lua

changeset 65
41aeda62af16
parent 59
165b36273ce7
child 73
9827b66cd3b2
--- 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