From 5b10d245e368cd54f33928665b282462a52fd5d8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 Jan 2017 14:21:08 +0100 Subject: util-src: Make C modules assert that the Lua runtime matches what it was compiled for --- util-src/crand.c | 3 +++ util-src/encodings.c | 3 +++ util-src/hashes.c | 3 +++ util-src/net.c | 3 +++ util-src/pposix.c | 3 +++ util-src/ringbuffer.c | 3 +++ util-src/signal.c | 3 +++ util-src/table.c | 3 +++ util-src/windows.c | 3 +++ 9 files changed, 27 insertions(+) (limited to 'util-src') diff --git a/util-src/crand.c b/util-src/crand.c index fbdec8f8..177511ce 100644 --- a/util-src/crand.c +++ b/util-src/crand.c @@ -130,6 +130,9 @@ int Lseed(lua_State *L) { #endif int luaopen_util_crand(lua_State *L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); lua_pushcfunction(L, Lrandom); lua_setfield(L, -2, "bytes"); diff --git a/util-src/encodings.c b/util-src/encodings.c index 35677095..6389b2be 100644 --- a/util-src/encodings.c +++ b/util-src/encodings.c @@ -524,6 +524,9 @@ static const luaL_Reg Reg_idna[] = { /***************** end *****************/ LUALIB_API int luaopen_util_encodings(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif #ifdef USE_STRINGPREP_ICU init_icu(); #endif diff --git a/util-src/hashes.c b/util-src/hashes.c index ecab2e32..d6f848c7 100644 --- a/util-src/hashes.c +++ b/util-src/hashes.c @@ -212,6 +212,9 @@ static const luaL_Reg Reg[] = { }; LUALIB_API int luaopen_util_hashes(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); luaL_setfuncs(L, Reg, 0);; lua_pushliteral(L, "-3.14"); diff --git a/util-src/net.c b/util-src/net.c index 3ccc7618..18f3d27a 100644 --- a/util-src/net.c +++ b/util-src/net.c @@ -125,6 +125,9 @@ static int lc_local_addresses(lua_State* L) { } int luaopen_util_net(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif luaL_Reg exports[] = { { "local_addresses", lc_local_addresses }, { NULL, NULL } diff --git a/util-src/pposix.c b/util-src/pposix.c index 7037730f..39d8742b 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -779,6 +779,9 @@ int lc_fallocate(lua_State* L) { /* Register functions */ int luaopen_util_pposix(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif luaL_Reg exports[] = { { "abort", lc_abort }, diff --git a/util-src/ringbuffer.c b/util-src/ringbuffer.c index f5fa136b..d60a43d9 100644 --- a/util-src/ringbuffer.c +++ b/util-src/ringbuffer.c @@ -197,6 +197,9 @@ int rb_gc(lua_State* L) { } int luaopen_util_ringbuffer(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif if(luaL_newmetatable(L, "ringbuffer_mt")) { lua_pushcfunction(L, rb_tostring); lua_setfield(L, -2, "__tostring"); diff --git a/util-src/signal.c b/util-src/signal.c index 725555fa..3f29febb 100644 --- a/util-src/signal.c +++ b/util-src/signal.c @@ -384,6 +384,9 @@ static const struct luaL_Reg lsignal_lib[] = { }; int luaopen_util_signal(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif int i = 0; /* add the library */ diff --git a/util-src/table.c b/util-src/table.c index 63415541..93acae65 100644 --- a/util-src/table.c +++ b/util-src/table.c @@ -21,6 +21,9 @@ static int Lpack(lua_State* L) { int luaopen_util_table(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); lua_pushcfunction(L, Lcreate_table); lua_setfield(L, -2, "create"); diff --git a/util-src/windows.c b/util-src/windows.c index 4fcbf21e..e4457994 100644 --- a/util-src/windows.c +++ b/util-src/windows.c @@ -103,6 +103,9 @@ static const luaL_Reg Reg[] = { }; LUALIB_API int luaopen_util_windows(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif lua_newtable(L); luaL_setfuncs(L, Reg, 0); lua_pushliteral(L, "-3.14"); -- cgit v1.2.3