From 7da19138e37c4e0123860f1fecbceb80c3d2627d Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Tue, 3 Dec 2002 07:20:34 +0000 Subject: Faltam testes de ftp e smtp. O resto passa. --- src/buffer.c | 4 ++-- src/http.lua | 6 +++--- src/select.c | 2 -- src/timeout.c | 6 +++--- src/url.lua | 6 +++--- 5 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/buffer.c b/src/buffer.c index a9a9782..4260f20 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -74,7 +74,7 @@ int buf_send(lua_State *L, p_buf buf) } priv_pusherror(L, err); lua_pushnumber(L, total); -#ifdef _DEBUG +#ifdef LUASOCKET_DEBUG /* push time elapsed during operation as the last return value */ lua_pushnumber(L, tm_getelapsed(&base->base_tm)/1000.0); #endif @@ -139,7 +139,7 @@ int buf_receive(lua_State *L, p_buf buf) for ( ; arg <= top; arg++) lua_pushnil(L); /* last return is an error code */ priv_pusherror(L, err); -#ifdef _DEBUG +#ifdef LUASOCKET_DEBUG /* push time elapsed during operation as the last return value */ lua_pushnumber(L, tm_getelapsed(&base->base_tm)/1000.0); #endif diff --git a/src/http.lua b/src/http.lua index dce3ac8..9543d59 100644 --- a/src/http.lua +++ b/src/http.lua @@ -8,7 +8,7 @@ ----------------------------------------------------------------------------- local Public, Private = {}, {} -HTTP = Public +http = Public ----------------------------------------------------------------------------- -- Program constants @@ -195,7 +195,7 @@ end function Private.receivebody_bylength(sock, length, receive_cb) local uerr, go while length > 0 do - local size = min(Public.BLOCKSIZE, length) + local size = math.min(Public.BLOCKSIZE, length) local chunk, err = sock:receive(size) if err then go, uerr = receive_cb(nil, err) @@ -542,7 +542,7 @@ function Public.request_cb(request, response) scheme = "http" }) if parsed.scheme ~= "http" then - response.error = format("unknown scheme '%s'", parsed.scheme) + response.error = string.format("unknown scheme '%s'", parsed.scheme) return response end -- explicit authentication info overrides that given by the URL diff --git a/src/select.c b/src/select.c index 1aaa7fe..5c08730 100644 --- a/src/select.c +++ b/src/select.c @@ -31,8 +31,6 @@ void select_open(lua_State *L) { /* push select auxiliar lua function and register * select_lua_select with it as an upvalue */ -#ifdef LUASOCKET_DEBUG -#endif luaL_loadfile(L, "lsselect.lua"); lua_call(L, 0, 1); lua_pushcclosure(L, select_lua_select, 1); diff --git a/src/timeout.c b/src/timeout.c index fdbc47a..940ddca 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -20,7 +20,7 @@ /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ -#ifdef _DEBUG +#ifdef LUASOCKET_DEBUG static int tm_lua_time(lua_State *L); static int tm_lua_sleep(lua_State *L); #endif @@ -123,7 +123,7 @@ int tm_gettime(void) void tm_open(lua_State *L) { (void) L; -#ifdef _DEBUG +#ifdef LUASOCKET_DEBUG lua_pushcfunction(L, tm_lua_time); priv_newglobal(L, "_time"); lua_pushcfunction(L, tm_lua_sleep); @@ -137,7 +137,7 @@ void tm_open(lua_State *L) /*-------------------------------------------------------------------------*\ * Returns the time the system has been up, in secconds. \*-------------------------------------------------------------------------*/ -#ifdef _DEBUG +#ifdef LUASOCKET_DEBUG static int tm_lua_time(lua_State *L) { lua_pushnumber(L, tm_gettime()/1000.0); diff --git a/src/url.lua b/src/url.lua index 0ecec3c..4d2bfa7 100644 --- a/src/url.lua +++ b/src/url.lua @@ -143,8 +143,8 @@ function Public.parse_path(path) for i = 1, table.getn(parsed) do parsed[i] = Code.unescape(parsed[i]) end - if stringsub(path, 1, 1) == "/" then parsed.is_absolute = 1 end - if stringsub(path, -1, -1) == "/" then parsed.is_directory = 1 end + if string.sub(path, 1, 1) == "/" then parsed.is_absolute = 1 end + if string.sub(path, -1, -1) == "/" then parsed.is_directory = 1 end return parsed end @@ -214,7 +214,7 @@ end -- corresponding absolute path ----------------------------------------------------------------------------- function Private.absolute_path(base_path, relative_path) - if stringsub(relative_path, 1, 1) == "/" then return relative_path end + if string.sub(relative_path, 1, 1) == "/" then return relative_path end local path = string.gsub(base_path, "[^/]*$", "") path = path .. relative_path path = string.gsub(path, "([^/]*%./)", function (s) -- cgit v1.2.3-55-g6feb