From 920bc9762954454468d056a61391635cbd849406 Mon Sep 17 00:00:00 2001 From: moteus Date: Mon, 27 May 2013 12:45:09 +0400 Subject: Build with Lua 5.2 without LUA_COMPAT_MODULE flag. LUASOCKET_USE_GLOBAL flag enable create global variables when load socket/mime modules. --- src/ltn12.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/ltn12.lua') diff --git a/src/ltn12.lua b/src/ltn12.lua index fca1cb2..c5f7c4c 100644 --- a/src/ltn12.lua +++ b/src/ltn12.lua @@ -10,16 +10,19 @@ local string = require("string") local table = require("table") local base = _G -module("ltn12") +ltn12 = {} +local _M = ltn12 -filter = {} -source = {} -sink = {} -pump = {} +local filter,source,sink,pump = {},{},{},{} + +_M.filter = filter +_M.source = source +_M.sink = sink +_M.pump = pump -- 2048 seems to be better in windows... -BLOCKSIZE = 2048 -_VERSION = "LTN12 1.0.2" +_M.BLOCKSIZE = 2048 +_M._VERSION = "LTN12 1.0.2" ----------------------------------------------------------------------------- -- Filter stuff @@ -38,7 +41,7 @@ end -- (thanks to Wim Couwenberg) function filter.chain(...) local arg = {...} - local n = #arg + local n = select('#',...) local top, index = 1, 1 local retry = "" return function(chunk) @@ -89,7 +92,7 @@ end function source.file(handle, io_err) if handle then return function() - local chunk = handle:read(BLOCKSIZE) + local chunk = handle:read(_M.BLOCKSIZE) if not chunk then handle:close() end return chunk end @@ -112,8 +115,8 @@ function source.string(s) if s then local i = 1 return function() - local chunk = string.sub(s, i, i+BLOCKSIZE-1) - i = i + BLOCKSIZE + local chunk = string.sub(s, i, i+_M.BLOCKSIZE-1) + i = i + _M.BLOCKSIZE if chunk ~= "" then return chunk else return nil end end @@ -291,3 +294,4 @@ function pump.all(src, snk, step) end end +return _M \ No newline at end of file -- cgit v1.2.3-55-g6feb