summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-01 14:21:32 +0200
committerwm4 <wm4@nowhere>2016-09-01 14:21:32 +0200
commit6b4f560f3ccca0f7db345bd7a6ed65e9307b432d (patch)
tree831199a941a1bf34959ca3809460655eb05f7685 /options/m_option.c
parentec3c428e5fb03244b9f8f4f7432779b45a181166 (diff)
downloadmpv-6b4f560f3ccca0f7db345bd7a6ed65e9307b432d.tar.bz2
mpv-6b4f560f3ccca0f7db345bd7a6ed65e9307b432d.tar.xz
vo, ao: disable positional parameter suboptions
Positional parameters cause problems because they can be ambiguous with flag options. If a flag option is removed or turned into a non-flag option, it'll usually be interpreted as value for the first sub-option (as positional parameter), resulting in very confusing error messages. This changes it into a simple "option not found" error. I don't expect that anyone really used positional parameters with --vo or --ao. Although the docs for --ao=pulse seem to encourage positional parameters for the host/sink options, which means it could possibly annoy some PulseAudio users. --vf and --af are still mostly used with positional parameters, so this must be a configurable option in the option parser.
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/options/m_option.c b/options/m_option.c
index cc8d818eec..a44ca0012d 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2648,7 +2648,8 @@ static void copy_obj_settings_list(const m_option_t *opt, void *dst,
// without '=' sets a flag, or whether it's a positional argument.
static int get_obj_param(struct mp_log *log, bstr opt_name, bstr obj_name,
struct m_config *config, bstr name, bstr val,
- int flags, int *nold, bstr *out_name, bstr *out_val)
+ int flags, bool nopos,
+ int *nold, bstr *out_name, bstr *out_val)
{
int r;
@@ -2658,7 +2659,7 @@ static int get_obj_param(struct mp_log *log, bstr opt_name, bstr obj_name,
// va.start != NULL => of the form name=val (not positional)
// If it's just "name", and the associated option exists and is a flag,
// don't accept it as positional argument.
- if (val.start || m_config_option_requires_param(config, name) == 0) {
+ if (val.start || m_config_option_requires_param(config, name) == 0 || nopos) {
r = m_config_set_option_ext(config, name, val, flags);
if (r < 0) {
if (r == M_OPT_UNKNOWN) {
@@ -2714,7 +2715,7 @@ static int get_obj_param(struct mp_log *log, bstr opt_name, bstr obj_name,
// desc is optional.
static int m_obj_parse_sub_config(struct mp_log *log, struct bstr opt_name,
struct bstr name, struct bstr *pstr,
- struct m_config *config, int flags,
+ struct m_config *config, int flags, bool nopos,
struct m_obj_desc *desc, char ***ret)
{
int nold = 0;
@@ -2735,8 +2736,8 @@ static int m_obj_parse_sub_config(struct mp_log *log, struct bstr opt_name,
goto exit;
if (bstr_equals0(fname, "help"))
goto print_help;
- r = get_obj_param(log, opt_name, name, config, fname, fval, flags, &nold,
- &fname, &fval);
+ r = get_obj_param(log, opt_name, name, config, fname, fval, flags,
+ nopos, &nold, &fname, &fval);
if (r < 0)
goto exit;
@@ -2791,6 +2792,7 @@ static int parse_obj_settings(struct mp_log *log, struct bstr opt,
char **plist = NULL;
struct m_obj_desc desc;
bstr label = {0};
+ bool nopos = list->disallow_positional_parameters;
if (bstr_eatstart0(pstr, "@")) {
if (!bstr_split_tok(*pstr, ":", &label, pstr)) {
@@ -2826,7 +2828,7 @@ static int parse_obj_settings(struct mp_log *log, struct bstr opt,
struct m_config *config = m_config_from_obj_desc_noalloc(NULL, log, &desc);
bstr s = bstr0(desc.init_options);
m_obj_parse_sub_config(log, opt, str, &s, config,
- M_SETOPT_CHECK_ONLY, NULL, &plist);
+ M_SETOPT_CHECK_ONLY, nopos, NULL, &plist);
assert(s.len == 0);
talloc_free(config);
}
@@ -2836,7 +2838,7 @@ static int parse_obj_settings(struct mp_log *log, struct bstr opt,
if (!skip)
config = m_config_from_obj_desc_noalloc(NULL, log, &desc);
r = m_obj_parse_sub_config(log, opt, str, pstr, config,
- M_SETOPT_CHECK_ONLY, &desc,
+ M_SETOPT_CHECK_ONLY, nopos, &desc,
_ret ? &plist : NULL);
talloc_free(config);
if (r < 0)