aboutsummaryrefslogtreecommitdiff
path: root/src/ltn12.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2005-01-02 22:44:00 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2005-01-02 22:44:00 +0000
commit97b26e0b66c840a446a0179200c7df23565330d1 (patch)
tree272f9ea0451f13b563451fb8df21a03669e90d09 /src/ltn12.lua
parenta8254e94f8c14ac15b02be53a1cc69ba80899230 (diff)
downloadluasocket-97b26e0b66c840a446a0179200c7df23565330d1.tar.gz
luasocket-97b26e0b66c840a446a0179200c7df23565330d1.tar.bz2
luasocket-97b26e0b66c840a446a0179200c7df23565330d1.zip
Almost ready to release beta3
Diffstat (limited to 'src/ltn12.lua')
-rw-r--r--src/ltn12.lua22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/ltn12.lua b/src/ltn12.lua
index 813e7d6..8c80196 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -170,20 +170,16 @@ end
170 170
171-- creates a source that produces contents of several sources, one after the 171-- creates a source that produces contents of several sources, one after the
172-- other, as if they were concatenated 172-- other, as if they were concatenated
173-- (thanks to Wim Couwenberg)
173function source.cat(...) 174function source.cat(...)
174 local co = coroutine.create(function() 175 local src = table.remove(arg, 1)
175 local i = 1
176 while i <= table.getn(arg) do
177 local chunk, err = arg[i]()
178 if chunk then coroutine.yield(chunk)
179 elseif err then return nil, err
180 else i = i + 1 end
181 end
182 end)
183 return function() 176 return function()
184 local ret, a, b = coroutine.resume(co) 177 while src do
185 if ret then return a, b 178 local chunk, err = src()
186 else return nil, a end 179 if chunk then return chunk end
180 if err then return nil, err end
181 src = table.remove(arg, 1)
182 end
187 end 183 end
188end 184end
189 185
@@ -276,4 +272,4 @@ function pump.all(src, snk, step)
276 end 272 end
277end 273end
278 274
279getmetatable(_M).__index = nil 275--getmetatable(_M).__index = nil