diff options
author | Diego Nehab <diego@impa.br> | 2013-05-29 16:56:56 +0800 |
---|---|---|
committer | Diego Nehab <diego@impa.br> | 2013-05-29 16:56:56 +0800 |
commit | 79e6c4915d267e149e1f3b134901bf355d439c15 (patch) | |
tree | fded0a926a268d88710e652fa8cdf06ec77cf217 /src/unix.c | |
parent | 5167ddaf499cf198b10208a2f76c27629e99ae1b (diff) | |
download | luasocket-79e6c4915d267e149e1f3b134901bf355d439c15.tar.gz luasocket-79e6c4915d267e149e1f3b134901bf355d439c15.tar.bz2 luasocket-79e6c4915d267e149e1f3b134901bf355d439c15.zip |
Export global only if LUA_COMPAT_MODULE defined.
Diffstat (limited to 'src/unix.c')
-rw-r--r-- | src/unix.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -69,6 +69,8 @@ static t_opt optset[] = { | |||
69 | }; | 69 | }; |
70 | 70 | ||
71 | /* our socket creation function */ | 71 | /* our socket creation function */ |
72 | /* this is an ad-hoc module that returns a single function | ||
73 | * as such, do not include other functions in this array. */ | ||
72 | static luaL_Reg func[] = { | 74 | static luaL_Reg func[] = { |
73 | {"unix", global_create}, | 75 | {"unix", global_create}, |
74 | {NULL, NULL} | 76 | {NULL, NULL} |
@@ -87,11 +89,14 @@ int luaopen_socket_unix(lua_State *L) { | |||
87 | auxiliar_add2group(L, "unix{master}", "unix{any}"); | 89 | auxiliar_add2group(L, "unix{master}", "unix{any}"); |
88 | auxiliar_add2group(L, "unix{client}", "unix{any}"); | 90 | auxiliar_add2group(L, "unix{client}", "unix{any}"); |
89 | auxiliar_add2group(L, "unix{server}", "unix{any}"); | 91 | auxiliar_add2group(L, "unix{server}", "unix{any}"); |
90 | /* make sure the function ends up in the package table */ | 92 | #if LUA_VERSION_NUM > 501 && !defined(LUA_COMPAT_MODULE) |
93 | lua_pushcfunction(L, global_create); | ||
94 | #else | ||
95 | /* set function into socket namespace */ | ||
91 | luaL_openlib(L, "socket", func, 0); | 96 | luaL_openlib(L, "socket", func, 0); |
97 | lua_pushcfunction(L, global_create); | ||
98 | #endif | ||
92 | /* return the function instead of the 'socket' table */ | 99 | /* return the function instead of the 'socket' table */ |
93 | lua_pushstring(L, "unix"); | ||
94 | lua_gettable(L, -2); | ||
95 | return 1; | 100 | return 1; |
96 | } | 101 | } |
97 | 102 | ||