diff options
author | aunsane <aunsane@gmail.com> | 2017-10-10 21:55:12 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-10-10 21:55:26 +0300 |
commit | 39e461bb614d75a6f23511a016afaeb3aba35f1a (patch) | |
tree | b61e3b3571bec7cb072abf91b512d0c398ee9195 /plugins/MirLua/src/mlua.cpp | |
parent | d3387c7307fa3f883e77c17e443874b3a085ded5 (diff) |
MirLua:
- m_json moved into base plugin
- added m_http module
-version bump
Diffstat (limited to 'plugins/MirLua/src/mlua.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index d3ded45a40..952e528e44 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -39,12 +39,13 @@ static int mlua_print(lua_State *L) break;
case LUA_TNUMBER:
data.AppendFormat("%s", lua_tostring(L, i));
+ break;
case LUA_TSTRING:
data.AppendFormat("'%s'", lua_tostring(L, i));
break;
default:
if (luaL_callmeta(L, i, "__tostring")) {
- data.AppendFormat("[[%s]]", lua_tostring(L, i));
+ data.AppendFormat("'%s'", lua_tostring(L, -1));
break;
}
data.AppendFormat("%s(0x%p)", luaL_typename(L, i), lua_topointer(L, i));
@@ -142,24 +143,19 @@ static int mlua_interpolate(lua_State *L) char pattern[128];
- if (lua_istable(L, 2))
- {
- for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2))
- {
+ if (lua_istable(L, 2)) {
+ for (lua_pushnil(L); lua_next(L, 2); lua_pop(L, 2)) {
lua_pushvalue(L, -2);
const char *key = lua_tostring(L, -1);
const char *val = lua_tostring(L, -2);
mir_snprintf(pattern, "{%s}", key);
string = luaL_gsub(L, string, pattern, val);
- lua_pop(L, 1);
}
}
- else
- {
+ else {
int nargs = lua_gettop(L);
- for (int i = 2; i <= nargs; i++)
- {
+ for (int i = 2; i <= nargs; i++) {
const char *val = lua_tostring(L, i);
mir_snprintf(pattern, "{%d}", i - 1);
|