From c57e98cd7debd8d8ea46159cbbf2eb7597544d4c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 16 Sep 2014 21:56:18 +0200 Subject: util-src/*.c: Don't create globals when loaded --- util-src/windows.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util-src/windows.c') diff --git a/util-src/windows.c b/util-src/windows.c index 3d14ca95..9b79c662 100644 --- a/util-src/windows.c +++ b/util-src/windows.c @@ -81,7 +81,8 @@ static const luaL_Reg Reg[] = }; LUALIB_API int luaopen_util_windows(lua_State *L) { - luaL_register(L, "windows", Reg); + lua_newtable(L); + luaL_register(L, NULL, Reg); lua_pushliteral(L, "version"); /** version */ lua_pushliteral(L, "-3.14"); lua_settable(L,-3); -- cgit v1.2.3 From 4f6f0fe48047cf1832061f52aa96b9df5d9460fa Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 17 Sep 2014 02:23:17 +0200 Subject: util-src/*.c: Use the more concise lua_setfield --- util-src/windows.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'util-src/windows.c') diff --git a/util-src/windows.c b/util-src/windows.c index 9b79c662..a209539f 100644 --- a/util-src/windows.c +++ b/util-src/windows.c @@ -83,8 +83,7 @@ static const luaL_Reg Reg[] = LUALIB_API int luaopen_util_windows(lua_State *L) { lua_newtable(L); luaL_register(L, NULL, Reg); - lua_pushliteral(L, "version"); /** version */ lua_pushliteral(L, "-3.14"); - lua_settable(L,-3); + lua_setfield(L, -2, "version"); return 1; } -- cgit v1.2.3 From 8affcc3ff7d35ca73fe748418046bec386496cd2 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 17 Sep 2014 14:30:29 +0200 Subject: util-src/*.c: Add macro for compiling with Lua 5.2 --- util-src/windows.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'util-src/windows.c') diff --git a/util-src/windows.c b/util-src/windows.c index a209539f..37f850e3 100644 --- a/util-src/windows.c +++ b/util-src/windows.c @@ -19,6 +19,10 @@ #include "lua.h" #include "lauxlib.h" +#if (LUA_VERSION_NUM == 502) +#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0) +#endif + static int Lget_nameservers(lua_State *L) { char stack_buffer[1024]; // stack allocated buffer IP4_ARRAY* ips = (IP4_ARRAY*) stack_buffer; -- cgit v1.2.3