util-src/*.c: Don't create globals when loaded
authorKim Alvefur <zash@zash.se>
Tue, 16 Sep 2014 19:56:18 +0000 (21:56 +0200)
committerKim Alvefur <zash@zash.se>
Tue, 16 Sep 2014 19:56:18 +0000 (21:56 +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 b9b6160a03809c2eb7b1c04a2622f0a90814592b..3a0749494e68d8e94287625cd7d3396c023694cc 100644 (file)
@@ -361,17 +361,12 @@ static const luaL_Reg Reg_idna[] =
 
 /***************** 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);
index 33041e83bdb8929f3673d860a408a3e89b22c064..7ca00867d7f6c81b1417587703c5032644e64691 100644 (file)
@@ -203,7 +203,8 @@ static const luaL_Reg Reg[] =
 
 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);
index e307c628146351873175d0dd92eb25d66188f73d..84d7e84ec9e2956432e7ac3c4902502476a88e07 100644 (file)
@@ -112,6 +112,7 @@ int luaopen_util_net(lua_State* L)
                { NULL, NULL }
        };
 
-       luaL_register(L, "net",  exports);
+       lua_newtable(L);
+       luaL_register(L, NULL,  exports);
        return 1;
 }
index 9b3e97eb772b6756d76e598376e3d49ba8b67893..62bd0339486ffa3c5f2d591b2ff739e91a4db740 100644 (file)
@@ -768,7 +768,8 @@ int luaopen_util_pposix(lua_State *L)
                { NULL, NULL }
        };
 
-       luaL_register(L, "pposix",  exports);
+       lua_newtable(L);
+       luaL_register(L, NULL,  exports);
 
        lua_pushliteral(L, "pposix");
        lua_setfield(L, -2, "_NAME");
index 961d2d3e06acda484613a0ebdfc54a8f25625586..405689f5688a9b87c933b8ee02386785877a3f89 100644 (file)
@@ -384,7 +384,8 @@ int luaopen_util_signal(lua_State *L)
   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,
index 3d14ca956496c4cd8a02103182c7a3b356016b1a..9b79c66297cca57c434eaecf2a383b0a97fa3256 100644 (file)
@@ -81,7 +81,8 @@ static const luaL_Reg Reg[] =
 };
 
 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);