summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/MirLua/src/mlua_utils.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp
index 3bb82e8fb3..c0b6629ffc 100644
--- a/plugins/MirLua/src/mlua_utils.cpp
+++ b/plugins/MirLua/src/mlua_utils.cpp
@@ -170,18 +170,16 @@ int luaM_interpolate(lua_State *L)
const char *string = luaL_checkstring(L, 1);
luaL_checktype(L, 2, LUA_TTABLE);
- lua_pushnil(L);
- while (lua_next(L, -2) != 0)
+ for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2))
{
- const char *key = luaL_checkstring(L, -2);
- const char *val = lua_tostring(L, -1);
+ lua_pushvalue(L, -2);
+ const char *key = lua_tostring(L, -1);
+ const char *val = lua_tostring(L, -2);
char pattern[32];
mir_snprintf(pattern, "{%s}", key);
string = luaL_gsub(L, string, pattern, val);
lua_pop(L, 1);
-
- lua_pop(L, 1);
}
lua_pushstring(L, string);