From bc723f1b68f7f12d8f2a91aeecf69a83c9b582b7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 16 Dec 2013 00:09:44 +0100 Subject: input: adjust code to make quoted/not quoted cases more unified --- mpvcore/input/input.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c index 464aeb47ea..b716ed13cf 100644 --- a/mpvcore/input/input.c +++ b/mpvcore/input/input.c @@ -1012,6 +1012,7 @@ static int parse_cmd(struct input_ctx *ictx, struct mp_cmd **dest, bstr str, str = bstr_lstrip(str); bstr arg = {0}; + bool got_token = false; if (bstr_eatstart0(&str, "\"")) { if (!read_escaped_string(tmp, &str, &arg)) { MP_ERR(ictx, "Command %s: argument %d has broken string escapes.\n", @@ -1023,23 +1024,25 @@ static int parse_cmd(struct input_ctx *ictx, struct mp_cmd **dest, bstr str, cmd->name, i + 1); goto error; } + got_token = true; } else { - bool got_token = read_token(str, &str, &arg); - if (is_vararg && !got_token) + got_token = read_token(str, &str, &arg); + } + + if (!got_token) { + if (is_vararg) continue; // Skip optional arguments - if (!got_token && opt->defval) { + if (opt->defval) { struct mp_cmd_arg *cmdarg = &cmd->args[cmd->nargs]; cmdarg->type = opt; memcpy(&cmdarg->v, opt->defval, opt->type->size); cmd->nargs++; continue; } - if (!got_token) { - MP_ERR(ictx, "Command %s requires more than %d arguments.\n", - cmd->name, cmd->nargs); - goto error; - } + MP_ERR(ictx, "Command %s requires more than %d arguments.\n", + cmd->name, cmd->nargs); + goto error; } struct mp_cmd_arg *cmdarg = &cmd->args[cmd->nargs]; -- cgit v1.2.3