diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2016-06-18 13:05:32 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2016-06-18 13:05:32 +0000 |
commit | 7ca306fd83e41b3ee0e45f24c17bd2b04d0fe87e (patch) | |
tree | 8fe8cfb116bb5d6813050cbcf8788f3467844fca /plugins/MirLua | |
parent | 591fc6380f5610588661cdbb8097f0f1ac3a16fb (diff) |
MirLua: fix interpolate
git-svn-id: http://svn.miranda-ng.org/main/trunk@17007 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua')
-rw-r--r-- | plugins/MirLua/src/mlua_utils.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
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;
|