summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-16 00:09:44 +0100
committerwm4 <wm4@nowhere>2013-12-16 20:03:37 +0100
commitbc723f1b68f7f12d8f2a91aeecf69a83c9b582b7 (patch)
treea3c015b2d1a2922651b2d253b307db0969011974
parent19b506ea65ef9c6ade6bdc0991a66020f9af00fc (diff)
downloadmpv-bc723f1b68f7f12d8f2a91aeecf69a83c9b582b7.tar.bz2
mpv-bc723f1b68f7f12d8f2a91aeecf69a83c9b582b7.tar.xz
input: adjust code to make quoted/not quoted cases more unified
-rw-r--r--mpvcore/input/input.c19
1 files 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];