summaryrefslogtreecommitdiffstats
path: root/options/m_config.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-02-13 03:16:29 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-13 17:45:29 -0800
commit223821d91c7ace8a4f7f726f1868bf2ae76b90ba (patch)
tree4083f216ae0b3cb6205ba3e73387345038a93fcc /options/m_config.c
parentd7c38a0b23970569afe76f1c647c895506bfb65d (diff)
downloadmpv-223821d91c7ace8a4f7f726f1868bf2ae76b90ba.tar.bz2
mpv-223821d91c7ace8a4f7f726f1868bf2ae76b90ba.tar.xz
options: minor cleanup to --no-... handling
Most options starting with --no-<name> are automatically translated to --<name>=no. Make the code slightly nicer by using a flag instead of explicitly comparing option types. Also fix an issue that made the option parser print nonsense error messages for if --no-... was used for options which don't support it.
Diffstat (limited to 'options/m_config.c')
-rw-r--r--options/m_config.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/options/m_config.c b/options/m_config.c
index dc0fcf9c54..09f14eb2e4 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -819,16 +819,16 @@ static struct m_config_option *m_config_mogrify_cli_opt(struct m_config *config,
return co;
// Turn "--no-foo" into "foo" + set *out_negate.
- if (!co && bstr_eatstart0(name, "no-")) {
- co = m_config_get_co(config, *name);
+ bstr no_name = *name;
+ if (!co && bstr_eatstart0(&no_name, "no-")) {
+ co = m_config_get_co(config, no_name);
// Not all choice types have this value - if they don't, then parsing
// them will simply result in an error. Good enough.
- if (co && co->opt->type != CONF_TYPE_FLAG &&
- co->opt->type != CONF_TYPE_CHOICE &&
- co->opt->type != &m_option_type_aspect)
+ if (!co || !(co->opt->type->flags & M_OPT_TYPE_CHOICE))
return NULL;
+ *name = no_name;
*out_negate = true;
return co;
}