diff options
Diffstat (limited to 'plugins/MirLua/src/mlua_utils.cpp')
-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;
|