From 223821d91c7ace8a4f7f726f1868bf2ae76b90ba Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 13 Feb 2018 03:16:29 +0100 Subject: options: minor cleanup to --no-... handling Most options starting with --no- are automatically translated to --=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. --- options/m_config.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'options/m_config.c') 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; } -- cgit v1.2.3