diff --git a/etc/README b/etc/README index e72471d..6be740b 100644 --- a/etc/README +++ b/etc/README @@ -1,11 +1,6 @@ This directory contains code that is more useful than the examples. This code *is* supported. - lua.lua -- new require and requirelib implementations - -This is to support dynamic loading of LuaSocket. Check the INSTALL -file for more information. - tftp.lua -- Trivial FTP client This module implements file retrieval by the TFTP protocol. Its main use diff --git a/etc/dict.lua b/etc/dict.lua index 6c40a32..a52b977 100644 --- a/etc/dict.lua +++ b/etc/dict.lua @@ -151,4 +151,4 @@ get = socket.protect(function(gett) else return tget(gett) end end) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/etc/lp.lua b/etc/lp.lua index cc358d1..7637d16 100644 --- a/etc/lp.lua +++ b/etc/lp.lua @@ -318,4 +318,4 @@ query = socket.protect(function(p) return data end) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/etc/tftp.lua b/etc/tftp.lua index 91b26c9..ba21a43 100644 --- a/etc/tftp.lua +++ b/etc/tftp.lua @@ -153,4 +153,4 @@ get = socket.protect(function(gett) else return tget(gett) end end) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/luasocket.vcproj b/luasocket.vcproj index 4699498..14cbebf 100644 --- a/luasocket.vcproj +++ b/luasocket.vcproj @@ -19,7 +19,7 @@ + RelativePath=".\compat-5.1r2\compat-5.1.c"> diff --git a/makefile.dist b/makefile.dist index a31a9a5..b1ac1fa 100644 --- a/makefile.dist +++ b/makefile.dist @@ -4,6 +4,8 @@ DIST = luasocket-2.0-beta3 +COMPAT = compat-5.1r2 + LUA = \ ftp.lua \ http.lua \ @@ -11,7 +13,6 @@ LUA = \ mime.lua \ smtp.lua \ socket.lua \ - compat-5.1.lua \ tp.lua \ url.lua @@ -72,9 +73,7 @@ CORE = \ usocket.c \ usocket.h \ wsocket.c \ - wsocket.h \ - compat-5.1.c \ - compat-5.1.h + wsocket.h MAKE = \ makefile.Darwin \ @@ -92,7 +91,7 @@ MANUAL = \ manual/ltn12.html \ manual/luasocket.png \ manual/mime.html \ - manual/instalation.html \ + manual/installation.html \ manual/reference.css \ manual/reference.html \ manual/smtp.html \ @@ -107,6 +106,7 @@ dist: mkdir -p $(DIST)/etc mkdir -p $(DIST)/lua mkdir -p $(DIST)/manual + cp -vfr $(COMPAT) $(DIST) cp -vf TODO $(DIST) cp -vf $(CORE) $(DIST) cp -vf README $(DIST) diff --git a/mime.vcproj b/mime.vcproj index 9fe7aa8..9e73f7b 100644 --- a/mime.vcproj +++ b/mime.vcproj @@ -19,7 +19,7 @@ + RelativePath=".\compat-5.1r2\compat-5.1.c"> diff --git a/samples/README b/samples/README index 3ce4067..0100a4a 100644 --- a/samples/README +++ b/samples/README @@ -7,7 +7,7 @@ is not supported. listener.lua and talker.lua are about the simplest applications you can write using LuaSocket. Run - 'lua listen.lua' and 'lua talk.lua' + 'lua listener.lua' and 'lua talker.lua' on different terminals. Whatever you type on talk.lua will be printed by listen.lua. diff --git a/samples/echoclnt.lua b/samples/echoclnt.lua index 038061d..764e433 100644 --- a/samples/echoclnt.lua +++ b/samples/echoclnt.lua @@ -12,13 +12,13 @@ if arg then port = arg[2] or port end host = socket.dns.toip(host) -udp = socket.try(socket.udp()) -socket.try(udp:setpeername(host, port)) +udp = assert(socket.udp()) +assert(udp:setpeername(host, port)) print("Using remote host '" ..host.. "' and port " .. port .. "...") while 1 do line = io.read() - if not line then os.exit() end - socket.try(udp:send(line)) - dgram = socket.try(udp:receive()) + if not line or line == "" then os.exit() end + assert(udp:send(line)) + dgram = assert(udp:receive()) print(dgram) end diff --git a/samples/echosrvr.lua b/samples/echosrvr.lua index 3ebbe85..d4449e5 100644 --- a/samples/echosrvr.lua +++ b/samples/echosrvr.lua @@ -12,10 +12,11 @@ if arg then port = arg[2] or port end print("Binding to host '" ..host.. "' and port " ..port.. "...") -udp = socket.try(socket.udp()) -socket.try(udp:setsockname(host, port)) -socket.try(udp:settimeout(5)) -ip, port = socket.try(udp:getsockname()) +udp = assert(socket.udp()) +assert(udp:setsockname(host, port)) +assert(udp:settimeout(5)) +ip, port = udp:getsockname() +assert(ip, port) print("Waiting packets on " .. ip .. ":" .. port .. "...") while 1 do dgram, ip, port = udp:receivefrom() diff --git a/samples/listener.lua b/samples/listener.lua index 65c6501..4d4c3b6 100644 --- a/samples/listener.lua +++ b/samples/listener.lua @@ -12,10 +12,11 @@ if arg then port = arg[2] or port end print("Binding to host '" ..host.. "' and port " ..port.. "...") -s = socket.try(socket.bind(host, port)) -i, p = socket.try(s:getsockname()) +s = assert(socket.bind(host, port)) +i, p = s:getsockname() +assert(i, p) print("Waiting connection from talker on " .. i .. ":" .. p .. "...") -c = socket.try(s:accept()) +c = assert(s:accept()) print("Connected. Here is the stuff:") l, e = c:receive() while not e do diff --git a/samples/talker.lua b/samples/talker.lua index 3f6e69c..901ed2c 100644 --- a/samples/talker.lua +++ b/samples/talker.lua @@ -12,10 +12,10 @@ if arg then port = arg[2] or port end print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") -c = socket.try(socket.connect(host, port)) +c = assert(socket.connect(host, port)) print("Connected! Please type stuff (empty line to stop):") l = io.read() while l and l ~= "" and not e do - socket.try(c:send(l, "\n")) + assert(c:send(l .. "\n")) l = io.read() end diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua index 13f42ec..684e7c0 100644 --- a/samples/tinyirc.lua +++ b/samples/tinyirc.lua @@ -14,8 +14,8 @@ if arg then port2 = arg[3] or port2 end -server1 = socket.try(socket.bind(host, port1)) -server2 = socket.try(socket.bind(host, port2)) +server1 = assert(socket.bind(host, port1)) +server2 = assert(socket.bind(host, port2)) server1:settimeout(1) -- make sure we don't block in accept server2:settimeout(1) diff --git a/src/ftp.lua b/src/ftp.lua index c55ec4e..9b7c1e5 100644 --- a/src/ftp.lua +++ b/src/ftp.lua @@ -278,4 +278,4 @@ get = socket.protect(function(gett) else return tget(gett) end end) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/src/http.lua b/src/http.lua index 27ce960..5fb59ce 100644 --- a/src/http.lua +++ b/src/http.lua @@ -259,4 +259,4 @@ request = socket.protect(function(reqt, body) else return trequest(reqt) end end) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil 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 -- creates a source that produces contents of several sources, one after the -- other, as if they were concatenated +-- (thanks to Wim Couwenberg) function source.cat(...) - local co = coroutine.create(function() - local i = 1 - while i <= table.getn(arg) do - local chunk, err = arg[i]() - if chunk then coroutine.yield(chunk) - elseif err then return nil, err - else i = i + 1 end - end - end) + local src = table.remove(arg, 1) return function() - local ret, a, b = coroutine.resume(co) - if ret then return a, b - else return nil, a end + while src do + local chunk, err = src() + if chunk then return chunk end + if err then return nil, err end + src = table.remove(arg, 1) + end end end @@ -276,4 +272,4 @@ function pump.all(src, snk, step) end end -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/src/luasocket.h b/src/luasocket.h index 33524e3..db54a18 100644 --- a/src/luasocket.h +++ b/src/luasocket.h @@ -13,7 +13,9 @@ /*-------------------------------------------------------------------------*\ * Current luasocket version \*-------------------------------------------------------------------------*/ -#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)" +#define LUASOCKET_VERSION "LuaSocket 2.0 (beta3)" +#define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2005 Diego Nehab" +#define LUASOCKET_AUTHORS "Diego Nehab" /*-------------------------------------------------------------------------*\ * This macro prefixes all exported API functions diff --git a/src/mime.lua b/src/mime.lua index 71efdb3..4d5bdba 100644 --- a/src/mime.lua +++ b/src/mime.lua @@ -85,4 +85,4 @@ function mime.stuff() return ltn12.filter.cycle(dot, 2) end -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/src/smtp.lua b/src/smtp.lua index 6281544..12c2195 100644 --- a/src/smtp.lua +++ b/src/smtp.lua @@ -245,4 +245,4 @@ send = socket.protect(function(mailt) return s:close() end) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/src/socket.lua b/src/socket.lua index 57619fa..e3c85f0 100644 --- a/src/socket.lua +++ b/src/socket.lua @@ -172,4 +172,4 @@ socket.sourcet["default"] = socket.sourcet["until-closed"] socket.source = socket.choose(socket.sourcet) -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/src/tp.lua b/src/tp.lua index 085cc2b..1adc656 100644 --- a/src/tp.lua +++ b/src/tp.lua @@ -120,4 +120,4 @@ function connect(host, port, timeout) return base.setmetatable({c = c}, metat) end -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/src/url.lua b/src/url.lua index e6132f8..8d7b88f 100644 --- a/src/url.lua +++ b/src/url.lua @@ -273,4 +273,4 @@ function build_path(parsed, unsafe) return path end -getmetatable(_M).__index = nil +--getmetatable(_M).__index = nil diff --git a/test/httptest.lua b/test/httptest.lua index 71021a4..8862ceb 100644 --- a/test/httptest.lua +++ b/test/httptest.lua @@ -23,7 +23,7 @@ http.TIMEOUT = 10 local t = socket.gettime() host = host or "diego.student.princeton.edu" -proxy = proxy or "http://localhost:3128" +proxy = proxy or "http://dell-diego:3128" prefix = prefix or "/luasocket-test" cgiprefix = cgiprefix or "/luasocket-test-cgi" index_file = "test/index.html" @@ -399,7 +399,6 @@ print("ok") ------------------------------------------------------------------------ io.write("testing HEAD method: ") -http.TIMEOUT = 1 local r, c, h = http.request { method = "HEAD", url = "http://www.cs.princeton.edu/~diego/"