From 7ca306fd83e41b3ee0e45f24c17bd2b04d0fe87e Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 18 Jun 2016 13:05:32 +0000 Subject: MirLua: fix interpolate git-svn-id: http://svn.miranda-ng.org/main/trunk@17007 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_utils.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'plugins/MirLua/src/mlua_utils.cpp') diff --git a/plugins/MirLua/src/mlua_utils.cpp b/plugins/MirLua/src/mlua_utils.cpp index 574de71ba2..0abf0c66c1 100644 --- a/plugins/MirLua/src/mlua_utils.cpp +++ b/plugins/MirLua/src/mlua_utils.cpp @@ -237,19 +237,23 @@ int luaM_interpolate(lua_State *L) } lua_Debug ar; - lua_getstack(L, 1, &ar); - const char *name = lua_getlocal(L, &ar, 1); - size_t i = 1; - while (const char *key = lua_getlocal(L, &ar, i++)) - { - const char *val = lua_tostring(L, -1); + size_t level = 1; - mir_snprintf(pattern, "${%s}", name); - string = luaL_gsub(L, string, pattern, val); - lua_pop(L, 1); + while (lua_getstack(L, level++, &ar)) + { + size_t i = 1; + while (const char *name = lua_getlocal(L, &ar, i++)) + { + const char *val = lua_tostring(L, -1); + if (val) + { + mir_snprintf(pattern, "${%s}", name); + string = luaL_gsub(L, string, pattern, val); + lua_pop(L, 1); + } + } } - lua_pushstring(L, string); return 1; -- cgit v1.2.3