aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/auxiliar.c5
-rw-r--r--src/auxiliar.h2
-rw-r--r--src/buffer.c2
-rw-r--r--src/except.c2
-rw-r--r--src/inet.c2
-rw-r--r--src/luasocket.c4
-rw-r--r--src/luasocket.h6
-rw-r--r--src/makefile28
-rw-r--r--src/mime.c30
-rw-r--r--src/options.c5
-rw-r--r--src/select.c2
-rw-r--r--src/tcp.c4
-rw-r--r--src/timeout.c2
-rw-r--r--src/udp.c4
-rw-r--r--src/unix.c4
-rw-r--r--test/testclnt.lua15
-rw-r--r--test/testsrvr.lua2
17 files changed, 70 insertions, 49 deletions
diff --git a/src/auxiliar.c b/src/auxiliar.c
index 9514970..3396fc1 100644
--- a/src/auxiliar.c
+++ b/src/auxiliar.c
@@ -8,6 +8,7 @@
8#include <stdio.h> 8#include <stdio.h>
9 9
10#include "auxiliar.h" 10#include "auxiliar.h"
11#include "lua_typeerror.h"
11 12
12/*=========================================================================*\ 13/*=========================================================================*\
13* Exported functions 14* Exported functions
@@ -24,7 +25,7 @@ int auxiliar_open(lua_State *L) {
24* Creates a new class with given methods 25* Creates a new class with given methods
25* Methods whose names start with __ are passed directly to the metatable. 26* Methods whose names start with __ are passed directly to the metatable.
26\*-------------------------------------------------------------------------*/ 27\*-------------------------------------------------------------------------*/
27void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func) { 28void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) {
28 luaL_newmetatable(L, classname); /* mt */ 29 luaL_newmetatable(L, classname); /* mt */
29 /* create __index table to place methods */ 30 /* create __index table to place methods */
30 lua_pushstring(L, "__index"); /* mt,"__index" */ 31 lua_pushstring(L, "__index"); /* mt,"__index" */
@@ -81,7 +82,7 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna
81\*-------------------------------------------------------------------------*/ 82\*-------------------------------------------------------------------------*/
82int auxiliar_checkboolean(lua_State *L, int objidx) { 83int auxiliar_checkboolean(lua_State *L, int objidx) {
83 if (!lua_isboolean(L, objidx)) 84 if (!lua_isboolean(L, objidx))
84 luaL_typerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); 85 luaL_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
85 return lua_toboolean(L, objidx); 86 return lua_toboolean(L, objidx);
86} 87}
87 88
diff --git a/src/auxiliar.h b/src/auxiliar.h
index 57a2ecc..c53b39e 100644
--- a/src/auxiliar.h
+++ b/src/auxiliar.h
@@ -33,7 +33,7 @@
33#include "lauxlib.h" 33#include "lauxlib.h"
34 34
35int auxiliar_open(lua_State *L); 35int auxiliar_open(lua_State *L);
36void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func); 36void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func);
37void auxiliar_add2group(lua_State *L, const char *classname, const char *group); 37void auxiliar_add2group(lua_State *L, const char *classname, const char *group);
38void auxiliar_setclass(lua_State *L, const char *classname, int objidx); 38void auxiliar_setclass(lua_State *L, const char *classname, int objidx);
39void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx); 39void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx);
diff --git a/src/buffer.c b/src/buffer.c
index fbe00eb..8d90598 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -231,7 +231,7 @@ static int recvline(p_buffer buf, luaL_Buffer *b) {
231 pos = 0; 231 pos = 0;
232 while (pos < count && data[pos] != '\n') { 232 while (pos < count && data[pos] != '\n') {
233 /* we ignore all \r's */ 233 /* we ignore all \r's */
234 if (data[pos] != '\r') luaL_putchar(b, data[pos]); 234 if (data[pos] != '\r') luaL_addchar(b, data[pos]);
235 pos++; 235 pos++;
236 } 236 }
237 if (pos < count) { /* found '\n' */ 237 if (pos < count) { /* found '\n' */
diff --git a/src/except.c b/src/except.c
index 5faa5be..97c00a3 100644
--- a/src/except.c
+++ b/src/except.c
@@ -21,7 +21,7 @@ static int finalize(lua_State *L);
21static int do_nothing(lua_State *L); 21static int do_nothing(lua_State *L);
22 22
23/* except functions */ 23/* except functions */
24static luaL_reg func[] = { 24static luaL_Reg func[] = {
25 {"newtry", global_newtry}, 25 {"newtry", global_newtry},
26 {"protect", global_protect}, 26 {"protect", global_protect},
27 {NULL, NULL} 27 {NULL, NULL}
diff --git a/src/inet.c b/src/inet.c
index 571b838..dc24390 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -22,7 +22,7 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp);
22static int inet_global_gethostname(lua_State *L); 22static int inet_global_gethostname(lua_State *L);
23 23
24/* DNS functions */ 24/* DNS functions */
25static luaL_reg func[] = { 25static luaL_Reg func[] = {
26 { "toip", inet_global_toip}, 26 { "toip", inet_global_toip},
27 { "getaddrinfo", inet_global_getaddrinfo}, 27 { "getaddrinfo", inet_global_getaddrinfo},
28 { "tohostname", inet_global_tohostname}, 28 { "tohostname", inet_global_tohostname},
diff --git a/src/luasocket.c b/src/luasocket.c
index 3b29e8e..b43114e 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -45,7 +45,7 @@ static int base_open(lua_State *L);
45/*-------------------------------------------------------------------------*\ 45/*-------------------------------------------------------------------------*\
46* Modules and functions 46* Modules and functions
47\*-------------------------------------------------------------------------*/ 47\*-------------------------------------------------------------------------*/
48static const luaL_reg mod[] = { 48static const luaL_Reg mod[] = {
49 {"auxiliar", auxiliar_open}, 49 {"auxiliar", auxiliar_open},
50 {"except", except_open}, 50 {"except", except_open},
51 {"timeout", timeout_open}, 51 {"timeout", timeout_open},
@@ -57,7 +57,7 @@ static const luaL_reg mod[] = {
57 {NULL, NULL} 57 {NULL, NULL}
58}; 58};
59 59
60static luaL_reg func[] = { 60static luaL_Reg func[] = {
61 {"skip", global_skip}, 61 {"skip", global_skip},
62 {"__unload", global_unload}, 62 {"__unload", global_unload},
63 {NULL, NULL} 63 {NULL, NULL}
diff --git a/src/luasocket.h b/src/luasocket.h
index 3949421..608ff7b 100644
--- a/src/luasocket.h
+++ b/src/luasocket.h
@@ -11,7 +11,7 @@
11/*-------------------------------------------------------------------------*\ 11/*-------------------------------------------------------------------------*\
12* Current socket library version 12* Current socket library version
13\*-------------------------------------------------------------------------*/ 13\*-------------------------------------------------------------------------*/
14#define LUASOCKET_VERSION "LuaSocket 2.1.0" 14#define LUASOCKET_VERSION "LuaSocket 2.1.1"
15#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2011 Diego Nehab" 15#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2011 Diego Nehab"
16#define LUASOCKET_AUTHORS "Diego Nehab" 16#define LUASOCKET_AUTHORS "Diego Nehab"
17 17
@@ -22,6 +22,10 @@
22#define LUASOCKET_API extern 22#define LUASOCKET_API extern
23#endif 23#endif
24 24
25#if LUA_VERSION_NUM > 501 & !( defined LUA_COMPAT_MODULE)
26# error Lua 5.2 requires LUA_COMPAT_MODULE defined for luaL_openlib
27#endif
28
25/*-------------------------------------------------------------------------*\ 29/*-------------------------------------------------------------------------*\
26* Initializes the library. 30* Initializes the library.
27\*-------------------------------------------------------------------------*/ 31\*-------------------------------------------------------------------------*/
diff --git a/src/makefile b/src/makefile
index 9768ba1..b7c22da 100644
--- a/src/makefile
+++ b/src/makefile
@@ -2,9 +2,13 @@ PLAT?=macosx
2 2
3INSTALL_DATA=cp 3INSTALL_DATA=cp
4INSTALL_EXEC=cp 4INSTALL_EXEC=cp
5INSTALL_TOP=/opt/local 5#INSTALL_TOP=/opt/local
6INSTALL_TOP=./
7
8#LUAINC_macosx=/opt/local/include
9LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src
10#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src
6 11
7LUAINC_macosx=/opt/local/include
8LUAINC_linux=/usr/include/lua5.1 12LUAINC_linux=/usr/include/lua5.1
9LUAINC_win32="../../lua-5.1.3/src" 13LUAINC_win32="../../lua-5.1.3/src"
10LUALIB_win32="../../lua-5.1.3" 14LUALIB_win32="../../lua-5.1.3"
@@ -12,11 +16,15 @@ LUALIB_win32="../../lua-5.1.3"
12#------ 16#------
13# Install directories 17# Install directories
14# 18#
15INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.1 19#INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.1
16INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.1 20#INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.1
21INSTALL_TOP_SHARE=$(INSTALL_TOP)/share/lua/5.2
22INSTALL_TOP_LIB=$(INSTALL_TOP)/lib/lua/5.2
23
17INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket 24INSTALL_SOCKET_SHARE=$(INSTALL_TOP_SHARE)/socket
18INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket 25INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket
19INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime 26#INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime
27INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/foo/mime
20INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime 28INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime
21 29
22#------ 30#------
@@ -30,7 +38,7 @@ PLATS= macosx linux win32
30SO_macosx=so 38SO_macosx=so
31O_macosx=o 39O_macosx=o
32CC_macosx=gcc 40CC_macosx=gcc
33DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN \ 41DEF_macosx= -DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN -DLUA_COMPAT_MODULE \
34 -DLUASOCKET_API='__attribute__((visibility("default")))' \ 42 -DLUASOCKET_API='__attribute__((visibility("default")))' \
35 -DMIME_API='__attribute__((visibility("default")))' 43 -DMIME_API='__attribute__((visibility("default")))'
36CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \ 44CFLAGS_macosx= -I$(LUAINC) $(DEF) -pedantic -Wall -O2 -fno-common \
@@ -84,7 +92,7 @@ SOCKET_win32=wsocket.obj
84# 92#
85SO=$(SO_$(PLAT)) 93SO=$(SO_$(PLAT))
86O=$(O_$(PLAT)) 94O=$(O_$(PLAT))
87SOCKET_V=2.0.3 95SOCKET_V=2.1.1
88MIME_V=1.0.3 96MIME_V=1.0.3
89SOCKET_SO=socket.$(SO).$(SOCKET_V) 97SOCKET_SO=socket.$(SO).$(SOCKET_V)
90MIME_SO=mime.$(SO).$(MIME_V) 98MIME_SO=mime.$(SO).$(MIME_V)
@@ -117,7 +125,8 @@ SOCKET_OBJS= \
117 except.$(O) \ 125 except.$(O) \
118 select.$(O) \ 126 select.$(O) \
119 tcp.$(O) \ 127 tcp.$(O) \
120 udp.$(O) 128 udp.$(O) \
129 lua_typeerror.$(O)
121 130
122#------ 131#------
123# Modules belonging mime-core 132# Modules belonging mime-core
@@ -135,7 +144,8 @@ UNIX_OBJS=\
135 timeout.$(O) \ 144 timeout.$(O) \
136 io.$(O) \ 145 io.$(O) \
137 usocket.$(O) \ 146 usocket.$(O) \
138 unix.$(O) 147 unix.$(O) \
148 lua_typeerror.$(O)
139 149
140#------ 150#------
141# Files to install 151# Files to install
diff --git a/src/mime.c b/src/mime.c
index a1d7065..023559f 100644
--- a/src/mime.c
+++ b/src/mime.c
@@ -48,7 +48,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
48static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer); 48static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer);
49 49
50/* code support functions */ 50/* code support functions */
51static luaL_reg func[] = { 51static luaL_Reg func[] = {
52 { "dot", mime_global_dot }, 52 { "dot", mime_global_dot },
53 { "b64", mime_global_b64 }, 53 { "b64", mime_global_b64 },
54 { "eol", mime_global_eol }, 54 { "eol", mime_global_eol },
@@ -135,7 +135,7 @@ static int mime_global_wrp(lua_State *L)
135 left = length; 135 left = length;
136 luaL_addstring(&buffer, CRLF); 136 luaL_addstring(&buffer, CRLF);
137 } 137 }
138 luaL_putchar(&buffer, *input); 138 luaL_addchar(&buffer, *input);
139 left--; 139 left--;
140 break; 140 break;
141 } 141 }
@@ -374,9 +374,9 @@ static void qpsetup(UC *cl, UC *unbase)
374\*-------------------------------------------------------------------------*/ 374\*-------------------------------------------------------------------------*/
375static void qpquote(UC c, luaL_Buffer *buffer) 375static void qpquote(UC c, luaL_Buffer *buffer)
376{ 376{
377 luaL_putchar(buffer, '='); 377 luaL_addchar(buffer, '=');
378 luaL_putchar(buffer, qpbase[c >> 4]); 378 luaL_addchar(buffer, qpbase[c >> 4]);
379 luaL_putchar(buffer, qpbase[c & 0x0F]); 379 luaL_addchar(buffer, qpbase[c & 0x0F]);
380} 380}
381 381
382/*-------------------------------------------------------------------------*\ 382/*-------------------------------------------------------------------------*\
@@ -406,7 +406,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
406 qpquote(input[0], buffer); 406 qpquote(input[0], buffer);
407 luaL_addstring(buffer, marker); 407 luaL_addstring(buffer, marker);
408 return 0; 408 return 0;
409 } else luaL_putchar(buffer, input[0]); 409 } else luaL_addchar(buffer, input[0]);
410 break; 410 break;
411 /* might have to be quoted always */ 411 /* might have to be quoted always */
412 case QP_QUOTED: 412 case QP_QUOTED:
@@ -414,7 +414,7 @@ static size_t qpencode(UC c, UC *input, size_t size,
414 break; 414 break;
415 /* might never have to be quoted */ 415 /* might never have to be quoted */
416 default: 416 default:
417 luaL_putchar(buffer, input[0]); 417 luaL_addchar(buffer, input[0]);
418 break; 418 break;
419 } 419 }
420 input[0] = input[1]; input[1] = input[2]; 420 input[0] = input[1]; input[1] = input[2];
@@ -430,7 +430,7 @@ static size_t qppad(UC *input, size_t size, luaL_Buffer *buffer)
430{ 430{
431 size_t i; 431 size_t i;
432 for (i = 0; i < size; i++) { 432 for (i = 0; i < size; i++) {
433 if (qpclass[input[i]] == QP_PLAIN) luaL_putchar(buffer, input[i]); 433 if (qpclass[input[i]] == QP_PLAIN) luaL_addchar(buffer, input[i]);
434 else qpquote(input[i], buffer); 434 else qpquote(input[i], buffer);
435 } 435 }
436 if (size > 0) luaL_addstring(buffer, EQCRLF); 436 if (size > 0) luaL_addstring(buffer, EQCRLF);
@@ -500,7 +500,7 @@ static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
500 c = qpunbase[input[1]]; d = qpunbase[input[2]]; 500 c = qpunbase[input[1]]; d = qpunbase[input[2]];
501 /* if it is an invalid, do not decode */ 501 /* if it is an invalid, do not decode */
502 if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3); 502 if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3);
503 else luaL_putchar(buffer, (c << 4) + d); 503 else luaL_addchar(buffer, (c << 4) + d);
504 return 0; 504 return 0;
505 case '\r': 505 case '\r':
506 if (size < 2) return size; 506 if (size < 2) return size;
@@ -508,7 +508,7 @@ static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
508 return 0; 508 return 0;
509 default: 509 default:
510 if (input[0] == '\t' || (input[0] > 31 && input[0] < 127)) 510 if (input[0] == '\t' || (input[0] > 31 && input[0] < 127))
511 luaL_putchar(buffer, input[0]); 511 luaL_addchar(buffer, input[0]);
512 return 0; 512 return 0;
513 } 513 }
514} 514}
@@ -593,7 +593,7 @@ static int mime_global_qpwrp(lua_State *L)
593 left = length; 593 left = length;
594 luaL_addstring(&buffer, EQCRLF); 594 luaL_addstring(&buffer, EQCRLF);
595 } 595 }
596 luaL_putchar(&buffer, *input); 596 luaL_addchar(&buffer, *input);
597 left--; 597 left--;
598 break; 598 break;
599 default: 599 default:
@@ -601,7 +601,7 @@ static int mime_global_qpwrp(lua_State *L)
601 left = length; 601 left = length;
602 luaL_addstring(&buffer, EQCRLF); 602 luaL_addstring(&buffer, EQCRLF);
603 } 603 }
604 luaL_putchar(&buffer, *input); 604 luaL_addchar(&buffer, *input);
605 left--; 605 left--;
606 break; 606 break;
607 } 607 }
@@ -636,7 +636,7 @@ static int eolprocess(int c, int last, const char *marker,
636 return c; 636 return c;
637 } 637 }
638 } else { 638 } else {
639 luaL_putchar(buffer, c); 639 luaL_addchar(buffer, c);
640 return 0; 640 return 0;
641 } 641 }
642} 642}
@@ -676,7 +676,7 @@ static int mime_global_eol(lua_State *L)
676\*-------------------------------------------------------------------------*/ 676\*-------------------------------------------------------------------------*/
677static size_t dot(int c, size_t state, luaL_Buffer *buffer) 677static size_t dot(int c, size_t state, luaL_Buffer *buffer)
678{ 678{
679 luaL_putchar(buffer, c); 679 luaL_addchar(buffer, c);
680 switch (c) { 680 switch (c) {
681 case '\r': 681 case '\r':
682 return 1; 682 return 1;
@@ -684,7 +684,7 @@ static size_t dot(int c, size_t state, luaL_Buffer *buffer)
684 return (state == 1)? 2: 0; 684 return (state == 1)? 2: 0;
685 case '.': 685 case '.':
686 if (state == 2) 686 if (state == 2)
687 luaL_putchar(buffer, '.'); 687 luaL_addchar(buffer, '.');
688 default: 688 default:
689 return 0; 689 return 0;
690 } 690 }
diff --git a/src/options.c b/src/options.c
index 281a00f..801adf9 100644
--- a/src/options.c
+++ b/src/options.c
@@ -11,6 +11,7 @@
11#include "auxiliar.h" 11#include "auxiliar.h"
12#include "options.h" 12#include "options.h"
13#include "inet.h" 13#include "inet.h"
14#include "lua_typeerror.h"
14 15
15/*=========================================================================*\ 16/*=========================================================================*\
16* Internal functions prototypes 17* Internal functions prototypes
@@ -99,7 +100,7 @@ int opt_get_ip_multicast_loop(lua_State *L, p_socket ps)
99int opt_set_linger(lua_State *L, p_socket ps) 100int opt_set_linger(lua_State *L, p_socket ps)
100{ 101{
101 struct linger li; /* obj, name, table */ 102 struct linger li; /* obj, name, table */
102 if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); 103 if (!lua_istable(L, 3)) luaL_typeerror(L, 3, lua_typename(L, LUA_TTABLE));
103 lua_pushstring(L, "on"); 104 lua_pushstring(L, "on");
104 lua_gettable(L, 3); 105 lua_gettable(L, 3);
105 if (!lua_isboolean(L, -1)) 106 if (!lua_isboolean(L, -1))
@@ -165,7 +166,7 @@ int opt_set_ip6_v6only(lua_State *L, p_socket ps)
165static int opt_setmembership(lua_State *L, p_socket ps, int level, int name) 166static int opt_setmembership(lua_State *L, p_socket ps, int level, int name)
166{ 167{
167 struct ip_mreq val; /* obj, name, table */ 168 struct ip_mreq val; /* obj, name, table */
168 if (!lua_istable(L, 3)) luaL_typerror(L, 3, lua_typename(L, LUA_TTABLE)); 169 if (!lua_istable(L, 3)) luaL_typeerror(L, 3, lua_typename(L, LUA_TTABLE));
169 lua_pushstring(L, "multiaddr"); 170 lua_pushstring(L, "multiaddr");
170 lua_gettable(L, 3); 171 lua_gettable(L, 3);
171 if (!lua_isstring(L, -1)) 172 if (!lua_isstring(L, -1))
diff --git a/src/select.c b/src/select.c
index 0931b73..87b5dc2 100644
--- a/src/select.c
+++ b/src/select.c
@@ -27,7 +27,7 @@ static void make_assoc(lua_State *L, int tab);
27static int global_select(lua_State *L); 27static int global_select(lua_State *L);
28 28
29/* functions in library namespace */ 29/* functions in library namespace */
30static luaL_reg func[] = { 30static luaL_Reg func[] = {
31 {"select", global_select}, 31 {"select", global_select},
32 {NULL, NULL} 32 {NULL, NULL}
33}; 33};
diff --git a/src/tcp.c b/src/tcp.c
index b069136..19ee73c 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -40,7 +40,7 @@ static int meth_setfd(lua_State *L);
40static int meth_dirty(lua_State *L); 40static int meth_dirty(lua_State *L);
41 41
42/* tcp object methods */ 42/* tcp object methods */
43static luaL_reg tcp_methods[] = { 43static luaL_Reg tcp_methods[] = {
44 {"__gc", meth_close}, 44 {"__gc", meth_close},
45 {"__tostring", auxiliar_tostring}, 45 {"__tostring", auxiliar_tostring},
46 {"accept", meth_accept}, 46 {"accept", meth_accept},
@@ -76,7 +76,7 @@ static t_opt optset[] = {
76}; 76};
77 77
78/* functions in library namespace */ 78/* functions in library namespace */
79static luaL_reg func[] = { 79static luaL_Reg func[] = {
80 {"tcp", global_create}, 80 {"tcp", global_create},
81 {"tcp6", global_create6}, 81 {"tcp6", global_create6},
82 {"connect6", global_connect6}, 82 {"connect6", global_connect6},
diff --git a/src/timeout.c b/src/timeout.c
index cc7309c..a3f1318 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -35,7 +35,7 @@
35static int timeout_lua_gettime(lua_State *L); 35static int timeout_lua_gettime(lua_State *L);
36static int timeout_lua_sleep(lua_State *L); 36static int timeout_lua_sleep(lua_State *L);
37 37
38static luaL_reg func[] = { 38static luaL_Reg func[] = {
39 { "gettime", timeout_lua_gettime }, 39 { "gettime", timeout_lua_gettime },
40 { "sleep", timeout_lua_sleep }, 40 { "sleep", timeout_lua_sleep },
41 { NULL, NULL } 41 { NULL, NULL }
diff --git a/src/udp.c b/src/udp.c
index cc04fc8..13007fb 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -45,7 +45,7 @@ static int meth_setfd(lua_State *L);
45static int meth_dirty(lua_State *L); 45static int meth_dirty(lua_State *L);
46 46
47/* udp object methods */ 47/* udp object methods */
48static luaL_reg udp_methods[] = { 48static luaL_Reg udp_methods[] = {
49 {"__gc", meth_close}, 49 {"__gc", meth_close},
50 {"__tostring", auxiliar_tostring}, 50 {"__tostring", auxiliar_tostring},
51 {"close", meth_close}, 51 {"close", meth_close},
@@ -89,7 +89,7 @@ static t_opt optget[] = {
89}; 89};
90 90
91/* functions in library namespace */ 91/* functions in library namespace */
92static luaL_reg func[] = { 92static luaL_Reg func[] = {
93 {"udp", global_create}, 93 {"udp", global_create},
94 {"udp6", global_create6}, 94 {"udp6", global_create6},
95 {NULL, NULL} 95 {NULL, NULL}
diff --git a/src/unix.c b/src/unix.c
index 6962517..b08d325 100644
--- a/src/unix.c
+++ b/src/unix.c
@@ -39,7 +39,7 @@ static const char *unix_tryconnect(p_unix un, const char *path);
39static const char *unix_trybind(p_unix un, const char *path); 39static const char *unix_trybind(p_unix un, const char *path);
40 40
41/* unix object methods */ 41/* unix object methods */
42static luaL_reg un[] = { 42static luaL_Reg un[] = {
43 {"__gc", meth_close}, 43 {"__gc", meth_close},
44 {"__tostring", auxiliar_tostring}, 44 {"__tostring", auxiliar_tostring},
45 {"accept", meth_accept}, 45 {"accept", meth_accept},
@@ -71,7 +71,7 @@ static t_opt optset[] = {
71}; 71};
72 72
73/* our socket creation function */ 73/* our socket creation function */
74static luaL_reg func[] = { 74static luaL_Reg func[] = {
75 {"unix", global_create}, 75 {"unix", global_create},
76 {NULL, NULL} 76 {NULL, NULL}
77}; 77};
diff --git a/test/testclnt.lua b/test/testclnt.lua
index 4c2f211..ad3741a 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -4,8 +4,7 @@ host = host or "localhost"
4port = port or "8383" 4port = port or "8383"
5 5
6function printf(...) 6function printf(...)
7 local s = string.format(unpack(arg)) 7 io.stderr:write(string.format(...))
8 io.stderr:write(s)
9end 8end
10 9
11function pass(...) 10function pass(...)
@@ -21,12 +20,12 @@ function fail(...)
21end 20end
22 21
23function warn(...) 22function warn(...)
24 local s = string.format(unpack(arg)) 23 local s = string.format(...)
25 io.stderr:write("WARNING: ", s, "\n") 24 io.stderr:write("WARNING: ", s, "\n")
26end 25end
27 26
28function remote(...) 27function remote(...)
29 local s = string.format(unpack(arg)) 28 local s = string.format(...)
30 s = string.gsub(s, "\n", ";") 29 s = string.gsub(s, "\n", ";")
31 s = string.gsub(s, "%s+", " ") 30 s = string.gsub(s, "%s+", " ")
32 s = string.gsub(s, "^%s*", "") 31 s = string.gsub(s, "^%s*", "")
@@ -141,6 +140,9 @@ remote "data:send(str); data:close()"
141end 140end
142 141
143------------------------------------------------------------------------ 142------------------------------------------------------------------------
143if not math.mod then
144 math.mod = math.fmod
145end
144function test_asciiline(len) 146function test_asciiline(len)
145 reconnect() 147 reconnect()
146 io.stderr:write("length " .. len .. ": ") 148 io.stderr:write("length " .. len .. ": ")
@@ -445,7 +447,10 @@ end
445 447
446------------------------------------------------------------------------ 448------------------------------------------------------------------------
447function rebind_test() 449function rebind_test()
448 local c = socket.bind("localhost", 0) 450 local c ,c1 = socket.bind("localhost", 0)
451 if not c then pass ("failed to bind! " .. c .. ' ' .. c1) return end
452 assert(c,c1)
453
449 local i, p = c:getsockname() 454 local i, p = c:getsockname()
450 local s, e = socket.tcp() 455 local s, e = socket.tcp()
451 assert(s, e) 456 assert(s, e)
diff --git a/test/testsrvr.lua b/test/testsrvr.lua
index f1972c2..7ddff6e 100644
--- a/test/testsrvr.lua
+++ b/test/testsrvr.lua
@@ -10,6 +10,6 @@ while 1 do
10 command = assert(control:receive()); 10 command = assert(control:receive());
11 assert(control:send(ack)); 11 assert(control:send(ack));
12 print(command); 12 print(command);
13 (loadstring(command))(); 13 (load(command))();
14 end 14 end
15end 15end