diff options
Diffstat (limited to 'src/luasocket.c')
-rw-r--r-- | src/luasocket.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/luasocket.c b/src/luasocket.c index bea23d7..e6ee747 100644 --- a/src/luasocket.c +++ b/src/luasocket.c | |||
@@ -79,31 +79,11 @@ static int global_unload(lua_State *L) { | |||
79 | } | 79 | } |
80 | 80 | ||
81 | #if LUA_VERSION_NUM > 501 | 81 | #if LUA_VERSION_NUM > 501 |
82 | |||
83 | int luaL_typerror (lua_State *L, int narg, const char *tname) { | 82 | int luaL_typerror (lua_State *L, int narg, const char *tname) { |
84 | const char *msg = lua_pushfstring(L, "%s expected, got %s", | 83 | const char *msg = lua_pushfstring(L, "%s expected, got %s", |
85 | tname, luaL_typename(L, narg)); | 84 | tname, luaL_typename(L, narg)); |
86 | return luaL_argerror(L, narg, msg); | 85 | return luaL_argerror(L, narg, msg); |
87 | } | 86 | } |
88 | |||
89 | #if ! defined(LUA_COMPAT_MODULE) | ||
90 | void luaL_openlib(lua_State *L, const char *name, const luaL_Reg *funcs, int idx) { | ||
91 | if (name != NULL) { | ||
92 | #ifdef LUASOCKET_USE_GLOBAL | ||
93 | lua_getglobal(L,name); | ||
94 | if (lua_isnil(L,-1)) { | ||
95 | lua_newtable(L); | ||
96 | lua_setglobal(L,name); | ||
97 | lua_getglobal(L,name); | ||
98 | } | ||
99 | #else | ||
100 | lua_newtable(L); | ||
101 | #endif | ||
102 | } | ||
103 | luaL_setfuncs(L,funcs,0); | ||
104 | } | ||
105 | #endif | ||
106 | |||
107 | #endif | 87 | #endif |
108 | 88 | ||
109 | /*-------------------------------------------------------------------------*\ | 89 | /*-------------------------------------------------------------------------*\ |
@@ -112,7 +92,12 @@ void luaL_openlib(lua_State *L, const char *name, const luaL_Reg *funcs, int idx | |||
112 | static int base_open(lua_State *L) { | 92 | static int base_open(lua_State *L) { |
113 | if (socket_open()) { | 93 | if (socket_open()) { |
114 | /* export functions (and leave namespace table on top of stack) */ | 94 | /* export functions (and leave namespace table on top of stack) */ |
95 | #if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE) | ||
96 | lua_newtable(L); | ||
97 | luaL_setfuncs(L, func, 0); | ||
98 | #else | ||
115 | luaL_openlib(L, "socket", func, 0); | 99 | luaL_openlib(L, "socket", func, 0); |
100 | #endif | ||
116 | #ifdef LUASOCKET_DEBUG | 101 | #ifdef LUASOCKET_DEBUG |
117 | lua_pushstring(L, "_DEBUG"); | 102 | lua_pushstring(L, "_DEBUG"); |
118 | lua_pushboolean(L, 1); | 103 | lua_pushboolean(L, 1); |