util-src/*.c: Invert Lua 5.2 compat to be 5.2+ by default and a macro to support 5.1
authorKim Alvefur <zash@zash.se>
Sun, 26 Apr 2015 10:38:37 +0000 (12:38 +0200)
committerKim Alvefur <zash@zash.se>
Sun, 26 Apr 2015 10:38:37 +0000 (12:38 +0200)
util-src/encodings.c
util-src/hashes.c
util-src/net.c
util-src/pposix.c
util-src/signal.c
util-src/windows.c

index c00b2267e06bb5b53f69c6a9d64e68520227d008..35677095181fbf990c2c56a61527442e9009bcbf 100644 (file)
@@ -21,8 +21,8 @@
 #include "lua.h"
 #include "lauxlib.h"
 
-#if (LUA_VERSION_NUM == 502)
-#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#if (LUA_VERSION_NUM == 501)
+#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
 #endif
 
 /***************** BASE64 *****************/
@@ -530,19 +530,19 @@ LUALIB_API int luaopen_util_encodings(lua_State* L) {
        lua_newtable(L);
 
        lua_newtable(L);
-       luaL_register(L, NULL, Reg_base64);
+       luaL_setfuncs(L, Reg_base64, 0);
        lua_setfield(L, -2, "base64");
 
        lua_newtable(L);
-       luaL_register(L, NULL, Reg_stringprep);
+       luaL_setfuncs(L, Reg_stringprep, 0);
        lua_setfield(L, -2, "stringprep");
 
        lua_newtable(L);
-       luaL_register(L, NULL, Reg_idna);
+       luaL_setfuncs(L, Reg_idna, 0);
        lua_setfield(L, -2, "idna");
 
        lua_newtable(L);
-       luaL_register(L, NULL, Reg_utf8);
+       luaL_setfuncs(L, Reg_utf8, 0);
        lua_setfield(L, -2, "utf8");
 
        lua_pushliteral(L, "-3.14");
index a58a424d31a29f0e74b265db7391780e6422b07a..ecab2e328e892833d8d5780066e6afaf8c8f88c8 100644 (file)
@@ -27,8 +27,8 @@ typedef unsigned __int32 uint32_t;
 #include <openssl/sha.h>
 #include <openssl/md5.h>
 
-#if (LUA_VERSION_NUM == 502)
-#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#if (LUA_VERSION_NUM == 501)
+#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
 #endif
 
 #define HMAC_IPAD 0x36363636
@@ -213,7 +213,7 @@ static const luaL_Reg Reg[] = {
 
 LUALIB_API int luaopen_util_hashes(lua_State* L) {
        lua_newtable(L);
-       luaL_register(L, NULL, Reg);
+       luaL_setfuncs(L, Reg, 0);;
        lua_pushliteral(L, "-3.14");
        lua_setfield(L, -2, "version");
        return 1;
index ad09d04153d41d05bf5770a8b98dbe830d217517..3ccc7618e95dfbb1292f7f25e7b14a52cc1bc6cd 100644 (file)
@@ -26,8 +26,8 @@
 #include <lua.h>
 #include <lauxlib.h>
 
-#if (LUA_VERSION_NUM == 502)
-#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#if (LUA_VERSION_NUM == 501)
+#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
 #endif
 
 /* Enumerate all locally configured IP addresses */
@@ -131,6 +131,6 @@ int luaopen_util_net(lua_State* L) {
        };
 
        lua_newtable(L);
-       luaL_register(L, NULL,  exports);
+       luaL_setfuncs(L, exports, 0);
        return 1;
 }
index 5288b08cd03217e8c86db35cfa0c16a20027817c..02ea00871a7e2e3fea1c3df83bc01b8bff973c86 100644 (file)
@@ -35,8 +35,8 @@
 #include "lualib.h"
 #include "lauxlib.h"
 
-#if (LUA_VERSION_NUM == 502)
-#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#if (LUA_VERSION_NUM == 501)
+#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
 #endif
 
 #include <fcntl.h>
@@ -803,7 +803,7 @@ int luaopen_util_pposix(lua_State* L) {
        };
 
        lua_newtable(L);
-       luaL_register(L, NULL,  exports);
+       luaL_setfuncs(L, exports, 0);
 
        lua_pushliteral(L, "pposix");
        lua_setfield(L, -2, "_NAME");
index 1e988a2c59a606eab13f196322127473220dedc4..725555fa58ec7b79b9dd95f029871de2dc3b79dd 100644 (file)
@@ -32,8 +32,8 @@
 #include "lua.h"
 #include "lauxlib.h"
 
-#if (LUA_VERSION_NUM == 502)
-#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#if (LUA_VERSION_NUM == 501)
+#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
 #endif
 
 #ifndef lsig
@@ -388,7 +388,7 @@ int luaopen_util_signal(lua_State* L) {
 
        /* add the library */
        lua_newtable(L);
-       luaL_register(L, NULL, lsignal_lib);
+       luaL_setfuncs(L, lsignal_lib, 0);
 
        /* push lua_signals table into the registry */
        /* put the signals inside the library table too,
index aaa0740771098d62fa366579f8205db0b028356c..4fcbf21ea5bed5cfc72966584a24e3358d68c7ff 100644 (file)
@@ -19,8 +19,8 @@
 #include "lua.h"
 #include "lauxlib.h"
 
-#if (LUA_VERSION_NUM == 502)
-#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#if (LUA_VERSION_NUM == 501)
+#define luaL_setfuncs(L, R, N) luaL_register(L, NULL, R)
 #endif
 
 static int Lget_nameservers(lua_State* L) {
@@ -104,7 +104,7 @@ static const luaL_Reg Reg[] = {
 
 LUALIB_API int luaopen_util_windows(lua_State* L) {
        lua_newtable(L);
-       luaL_register(L, NULL, Reg);
+       luaL_setfuncs(L, Reg, 0);
        lua_pushliteral(L, "-3.14");
        lua_setfield(L, -2, "version");
        return 1;