# HG changeset patch # User Kim Alvefur # Date 1483881668 -3600 # Node ID 54669df178c2759c4fe1de4ede1dd1aac89843a3 # Parent 2624f4ee34a29b218372f1de7018bd9239dfacb2 util-src: Make C modules assert that the Lua runtime matches what it was compiled for diff -r 2624f4ee34a2 -r 54669df178c2 util-src/crand.c --- a/util-src/crand.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/crand.c Sun Jan 08 14:21:08 2017 +0100 @@ -130,6 +130,9 @@ #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 -r 2624f4ee34a2 -r 54669df178c2 util-src/encodings.c --- a/util-src/encodings.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/encodings.c Sun Jan 08 14:21:08 2017 +0100 @@ -524,6 +524,9 @@ /***************** 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 -r 2624f4ee34a2 -r 54669df178c2 util-src/hashes.c --- a/util-src/hashes.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/hashes.c Sun Jan 08 14:21:08 2017 +0100 @@ -212,6 +212,9 @@ }; 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 -r 2624f4ee34a2 -r 54669df178c2 util-src/net.c --- a/util-src/net.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/net.c Sun Jan 08 14:21:08 2017 +0100 @@ -125,6 +125,9 @@ } 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 -r 2624f4ee34a2 -r 54669df178c2 util-src/pposix.c --- a/util-src/pposix.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/pposix.c Sun Jan 08 14:21:08 2017 +0100 @@ -779,6 +779,9 @@ /* 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 -r 2624f4ee34a2 -r 54669df178c2 util-src/ringbuffer.c --- a/util-src/ringbuffer.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/ringbuffer.c Sun Jan 08 14:21:08 2017 +0100 @@ -197,6 +197,9 @@ } 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 -r 2624f4ee34a2 -r 54669df178c2 util-src/signal.c --- a/util-src/signal.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/signal.c Sun Jan 08 14:21:08 2017 +0100 @@ -384,6 +384,9 @@ }; int luaopen_util_signal(lua_State* L) { +#if (LUA_VERSION_NUM > 501) + luaL_checkversion(L); +#endif int i = 0; /* add the library */ diff -r 2624f4ee34a2 -r 54669df178c2 util-src/table.c --- a/util-src/table.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/table.c Sun Jan 08 14:21:08 2017 +0100 @@ -21,6 +21,9 @@ 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 -r 2624f4ee34a2 -r 54669df178c2 util-src/windows.c --- a/util-src/windows.c Fri Jan 06 13:14:17 2017 +0100 +++ b/util-src/windows.c Sun Jan 08 14:21:08 2017 +0100 @@ -103,6 +103,9 @@ }; 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");