util-src/*.c: Use the more concise lua_setfield
authorKim Alvefur <zash@zash.se>
Wed, 17 Sep 2014 00:23:17 +0000 (02:23 +0200)
committerKim Alvefur <zash@zash.se>
Wed, 17 Sep 2014 00:23:17 +0000 (02:23 +0200)
util-src/encodings.c
util-src/hashes.c
util-src/signal.c
util-src/windows.c

index 3a0749494e68d8e94287625cd7d3396c023694cc..fb8385517c15ef87afc3b3a5ca5800ae6802a56d 100644 (file)
@@ -368,23 +368,19 @@ LUALIB_API int luaopen_util_encodings(lua_State *L)
 #endif
        lua_newtable(L);
 
-       lua_pushliteral(L, "base64");
        lua_newtable(L);
        luaL_register(L, NULL, Reg_base64);
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "base64");
 
-       lua_pushliteral(L, "stringprep");
        lua_newtable(L);
        luaL_register(L, NULL, Reg_stringprep);
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "stringprep");
 
-       lua_pushliteral(L, "idna");
        lua_newtable(L);
        luaL_register(L, NULL, Reg_idna);
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "idna");
 
-       lua_pushliteral(L, "version");                  /** version */
        lua_pushliteral(L, "-3.14");
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "version");
        return 1;
 }
index 7ca00867d7f6c81b1417587703c5032644e64691..39ab51802060c88791e18a287e612adc401f9b06 100644 (file)
@@ -205,8 +205,7 @@ LUALIB_API int luaopen_util_hashes(lua_State *L)
 {
        lua_newtable(L);
        luaL_register(L, NULL, Reg);
-       lua_pushliteral(L, "version");                  /** version */
        lua_pushliteral(L, "-3.14");
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "version");
        return 1;
 }
index 405689f5688a9b87c933b8ee02386785877a3f89..3d0a8a50b2ab8ff3505a03def27c3a0d50264ce8 100644 (file)
@@ -391,7 +391,7 @@ int luaopen_util_signal(lua_State *L)
   /* put the signals inside the library table too,
    * they are only a reference */
   lua_pushstring(L, LUA_SIGNAL);
-  lua_createtable(L, 0, 0);
+  lua_newtable(L);
 
   while (lua_signals[i].name != NULL)
   {
index 9b79c66297cca57c434eaecf2a383b0a97fa3256..a209539f756f889638bd3fca4c2b18c701462ba0 100644 (file)
@@ -83,8 +83,7 @@ static const luaL_Reg Reg[] =
 LUALIB_API int luaopen_util_windows(lua_State *L) {
        lua_newtable(L);
        luaL_register(L, NULL, Reg);
-       lua_pushliteral(L, "version");                  /** version */
        lua_pushliteral(L, "-3.14");
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "version");
        return 1;
 }