# HG changeset patch # User Kim Alvefur # Date 1410897378 -7200 # Node ID 6c8f6364bc48027989f3d2f91b6dc0a8b6860cb7 # Parent 4bbd198cf3e6c9140f11697942adad2197601fb3 util-src/*.c: Don't create globals when loaded diff -r 4bbd198cf3e6 -r 6c8f6364bc48 util-src/encodings.c --- a/util-src/encodings.c Thu Sep 11 00:55:51 2014 +0200 +++ b/util-src/encodings.c Tue Sep 16 21:56:18 2014 +0200 @@ -361,17 +361,12 @@ /***************** end *****************/ -static const luaL_Reg Reg[] = -{ - { NULL, NULL } -}; - LUALIB_API int luaopen_util_encodings(lua_State *L) { #ifdef USE_STRINGPREP_ICU init_icu(); #endif - luaL_register(L, "encodings", Reg); + lua_newtable(L); lua_pushliteral(L, "base64"); lua_newtable(L); diff -r 4bbd198cf3e6 -r 6c8f6364bc48 util-src/hashes.c --- a/util-src/hashes.c Thu Sep 11 00:55:51 2014 +0200 +++ b/util-src/hashes.c Tue Sep 16 21:56:18 2014 +0200 @@ -203,7 +203,8 @@ LUALIB_API int luaopen_util_hashes(lua_State *L) { - luaL_register(L, "hashes", Reg); + lua_newtable(L); + luaL_register(L, NULL, Reg); lua_pushliteral(L, "version"); /** version */ lua_pushliteral(L, "-3.14"); lua_settable(L,-3); diff -r 4bbd198cf3e6 -r 6c8f6364bc48 util-src/net.c --- a/util-src/net.c Thu Sep 11 00:55:51 2014 +0200 +++ b/util-src/net.c Tue Sep 16 21:56:18 2014 +0200 @@ -112,6 +112,7 @@ { NULL, NULL } }; - luaL_register(L, "net", exports); + lua_newtable(L); + luaL_register(L, NULL, exports); return 1; } diff -r 4bbd198cf3e6 -r 6c8f6364bc48 util-src/pposix.c --- a/util-src/pposix.c Thu Sep 11 00:55:51 2014 +0200 +++ b/util-src/pposix.c Tue Sep 16 21:56:18 2014 +0200 @@ -768,7 +768,8 @@ { NULL, NULL } }; - luaL_register(L, "pposix", exports); + lua_newtable(L); + luaL_register(L, NULL, exports); lua_pushliteral(L, "pposix"); lua_setfield(L, -2, "_NAME"); diff -r 4bbd198cf3e6 -r 6c8f6364bc48 util-src/signal.c --- a/util-src/signal.c Thu Sep 11 00:55:51 2014 +0200 +++ b/util-src/signal.c Tue Sep 16 21:56:18 2014 +0200 @@ -384,7 +384,8 @@ int i = 0; /* add the library */ - luaL_register(L, "signal", lsignal_lib); + lua_newtable(L); + luaL_register(L, NULL, lsignal_lib); /* push lua_signals table into the registry */ /* put the signals inside the library table too, diff -r 4bbd198cf3e6 -r 6c8f6364bc48 util-src/windows.c --- a/util-src/windows.c Thu Sep 11 00:55:51 2014 +0200 +++ b/util-src/windows.c Tue Sep 16 21:56:18 2014 +0200 @@ -81,7 +81,8 @@ }; 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);