From 0bb41524f0a9ed89559b50bd7407de9d8b8aee40 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 8 Jul 2013 19:44:46 +0200 Subject: 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). --- core/input/input.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core') diff --git a/core/input/input.c b/core/input/input.c index 73ac5bc698..ce7b868c02 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -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; } -- cgit v1.2.3