lua: fix array detection

This was dumb and could return something like "{name=123}" as an array.

Also, fix the error message if a key is not a string. lua_typename()
takes a type directly, not a stack item.
This commit is contained in:
wm4 2016-09-24 17:52:36 +02:00
parent 68d2903cb1
commit 2361ec35aa
1 changed files with 2 additions and 2 deletions

View File

@ -709,7 +709,7 @@ static void makenode(void *tmp, mpv_node *dst, lua_State *L, int t)
bool empty = lua_isnil(L, -1); // t[n] bool empty = lua_isnil(L, -1); // t[n]
lua_pop(L, 1); // - lua_pop(L, 1); // -
if (empty) { if (empty) {
count = n; count = n - 1;
break; break;
} }
} }
@ -751,7 +751,7 @@ static void makenode(void *tmp, mpv_node *dst, lua_State *L, int t)
makenode(tmp, &list->values[list->num], L, -1); makenode(tmp, &list->values[list->num], L, -1);
if (lua_type(L, -2) != LUA_TSTRING) { if (lua_type(L, -2) != LUA_TSTRING) {
luaL_error(L, "key must be a string, but got %s", luaL_error(L, "key must be a string, but got %s",
lua_typename(L, -2)); lua_typename(L, lua_type(L, -2)));
} }
list->keys[list->num] = talloc_strdup(tmp, lua_tostring(L, -2)); list->keys[list->num] = talloc_strdup(tmp, lua_tostring(L, -2));
list->num++; list->num++;