mirror of https://github.com/mpv-player/mpv
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:
parent
68d2903cb1
commit
2361ec35aa
|
@ -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]
|
||||
lua_pop(L, 1); // -
|
||||
if (empty) {
|
||||
count = n;
|
||||
count = n - 1;
|
||||
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);
|
||||
if (lua_type(L, -2) != LUA_TSTRING) {
|
||||
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->num++;
|
||||
|
|
Loading…
Reference in New Issue