mirror of https://github.com/mpv-player/mpv
input: actually copy sub commands
This was missing from the previous commit. It worked by luck, because the sub-commands weren't freed either (as long as the original command was around), but this is proper. Also, set the original string for command lists (needed for input-test only).
This commit is contained in:
parent
846f46ec1d
commit
0bb41524f0
|
@ -1034,6 +1034,7 @@ mp_cmd_t *mp_input_parse_cmd(bstr str, const char *loc)
|
|||
*list = (struct mp_cmd) {
|
||||
.id = MP_CMD_COMMAND_LIST,
|
||||
.name = "list",
|
||||
.original = bstrdup(list, str),
|
||||
};
|
||||
list->args[0].v.p = cmd;
|
||||
while (cmd) {
|
||||
|
@ -1775,6 +1776,17 @@ mp_cmd_t *mp_cmd_clone(mp_cmd_t *cmd)
|
|||
ret->args[i].v.s = talloc_strdup(ret, cmd->args[i].v.s);
|
||||
}
|
||||
|
||||
if (cmd->id == MP_CMD_COMMAND_LIST) {
|
||||
bool first = true;
|
||||
for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next) {
|
||||
sub = mp_cmd_clone(sub);
|
||||
talloc_steal(cmd, sub);
|
||||
if (first)
|
||||
cmd->args[0].v.p = sub;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue