diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-04-17 16:57:13 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-04-17 16:57:13 +0000 |
commit | 34dd9e912952befefa30ba0d64dbd18d84201552 (patch) | |
tree | dbb00e26a43968894da680ac61b8a3eee316d9d1 /plugins | |
parent | cffb2b2c6934428fc5f677b2330eaf9cb438909e (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')
-rw-r--r-- | plugins/MirLua/src/mlua_utils.cpp | 10 |
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);
|