summaryrefslogtreecommitdiff
path: root/plugins/MirLua
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-04-17 16:57:13 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-04-17 16:57:13 +0000
commit34dd9e912952befefa30ba0d64dbd18d84201552 (patch)
treedbb00e26a43968894da680ac61b8a3eee316d9d1 /plugins/MirLua
parentcffb2b2c6934428fc5f677b2330eaf9cb438909e (diff)
MirLua: fix for number table key in string interpolation: print('some {1} string' % { 'cool' })
git-svn-id: http://svn.miranda-ng.org/main/trunk@16700 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-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);