aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-11-17 04:55:57 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-11-17 04:55:57 +0000
commitbdc3e241bb61a8bbf64353cb4090b4da417b06b0 (patch)
tree3c34621efe4294c6bad590e34b7646ef1d1c7a83
parent3700bf65b71c5ce24cdd9aa523366daad6dd5fe2 (diff)
downloadluasocket-bdc3e241bb61a8bbf64353cb4090b4da417b06b0.tar.gz
luasocket-bdc3e241bb61a8bbf64353cb4090b4da417b06b0.tar.bz2
luasocket-bdc3e241bb61a8bbf64353cb4090b4da417b06b0.zip
Little bug in manual.
-rw-r--r--doc/smtp.html2
-rw-r--r--src/ltn12.lua24
-rw-r--r--test/mimetest.lua4
3 files changed, 27 insertions, 3 deletions
diff --git a/doc/smtp.html b/doc/smtp.html
index b975045..4a9aaac 100644
--- a/doc/smtp.html
+++ b/doc/smtp.html
@@ -122,7 +122,7 @@ smtp.<b>send{</b><br>
122&nbsp;&nbsp;[user = <i>string</i>,]<br> 122&nbsp;&nbsp;[user = <i>string</i>,]<br>
123&nbsp;&nbsp;[password = <i>string</i>,]<br> 123&nbsp;&nbsp;[password = <i>string</i>,]<br>
124&nbsp;&nbsp;[server = <i>string</i>,]<br> 124&nbsp;&nbsp;[server = <i>string</i>,]<br>
125&nbsp;&nbsp;[port = <i>string</i>,]<br> 125&nbsp;&nbsp;[port = <i>number</i>,]<br>
126&nbsp;&nbsp;[domain = <i>string</i>,]<br> 126&nbsp;&nbsp;[domain = <i>string</i>,]<br>
127&nbsp;&nbsp;[step = <i>LTN12 pump step</i>,]<br> 127&nbsp;&nbsp;[step = <i>LTN12 pump step</i>,]<br>
128<b>}</b> 128<b>}</b>
diff --git a/src/ltn12.lua b/src/ltn12.lua
index 9917ce8..ed39ec8 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -31,6 +31,7 @@ function filter.cycle(low, ctx, extra)
31 end 31 end
32end 32end
33 33
34--[[
34local function chain2(f1, f2) 35local function chain2(f1, f2)
35 local ff1, ff2 = "", "" 36 local ff1, ff2 = "", ""
36 return function(chunk) 37 return function(chunk)
@@ -55,6 +56,29 @@ local function chain2(f1, f2)
55 end 56 end
56 end 57 end
57end 58end
59]]
60
61local function chain2(f1, f2)
62 local co = coroutine.create(function(chunk)
63 while true do
64 local filtered1 = f1(chunk)
65 local filtered2 = f2(filtered1)
66 local done2 = filtered1 and ""
67 while true do
68 if filtered2 == "" or filtered2 == nil then break end
69 coroutine.yield(filtered2)
70 filtered2 = f2(done2)
71 end
72 if filtered1 == "" then chunk = coroutine.yield(filtered1)
73 elseif filtered1 == nil then return nil
74 else chunk = chunk and "" end
75 end
76 end)
77 return function(chunk)
78 local _, res = coroutine.resume(co, chunk)
79 return res
80 end
81end
58 82
59-- chains a bunch of filters together 83-- chains a bunch of filters together
60function filter.chain(...) 84function filter.chain(...)
diff --git a/test/mimetest.lua b/test/mimetest.lua
index 89926d8..834d99f 100644
--- a/test/mimetest.lua
+++ b/test/mimetest.lua
@@ -187,7 +187,7 @@ local function cleanup_qptest()
187end 187end
188 188
189-- create test file 189-- create test file
190function create_b64test() 190local function create_b64test()
191 local f = assert(io.open(b64test, "wb")) 191 local f = assert(io.open(b64test, "wb"))
192 local t = {} 192 local t = {}
193 for j = 1, 100 do 193 for j = 1, 100 do
@@ -282,8 +282,8 @@ end
282 282
283local t = socket.gettime() 283local t = socket.gettime()
284 284
285identity_test()
286create_b64test() 285create_b64test()
286identity_test()
287encode_b64test() 287encode_b64test()
288decode_b64test() 288decode_b64test()
289compare_b64test() 289compare_b64test()