util-src: Make C modules assert that the Lua runtime matches what it was compiled for
authorKim Alvefur <zash@zash.se>
Sun, 08 Jan 2017 14:21:08 +0100
changeset 7821 54669df178c2
parent 7819 2624f4ee34a2
child 7822 ad709ee7d3d8
util-src: Make C modules assert that the Lua runtime matches what it was compiled for
util-src/crand.c
util-src/encodings.c
util-src/hashes.c
util-src/net.c
util-src/pposix.c
util-src/ringbuffer.c
util-src/signal.c
util-src/table.c
util-src/windows.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");
--- 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
--- 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");
--- 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 }
--- 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 },
 
--- 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");
--- 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 */
--- 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");
--- 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");