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_option.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'options/m_option.c') diff --git a/options/m_option.c b/options/m_option.c index e777c5a19e..4a32582873 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -183,11 +183,11 @@ const m_option_type_t m_option_type_flag = { // need yes or no in config files .name = "Flag", .size = sizeof(int), - .flags = M_OPT_TYPE_OPTIONAL_PARAM, + .flags = M_OPT_TYPE_OPTIONAL_PARAM | M_OPT_TYPE_CHOICE, .parse = parse_flag, .print = print_flag, .copy = copy_opt, - .add = add_flag, + .add = add_flag, .set = flag_set, .get = flag_get, }; @@ -747,6 +747,7 @@ static char *print_choice(const m_option_t *opt, const void *val) const struct m_option_type m_option_type_choice = { .name = "Choice", .size = sizeof(int), + .flags = M_OPT_TYPE_CHOICE, .parse = parse_choice, .print = print_choice, .copy = copy_opt, @@ -1087,6 +1088,7 @@ static int parse_float_aspect(struct mp_log *log, const m_option_t *opt, const m_option_type_t m_option_type_aspect = { .name = "Aspect", .size = sizeof(float), + .flags = M_OPT_TYPE_CHOICE, .parse = parse_float_aspect, .print = print_float, .pretty_print = print_float_f3, -- cgit v1.2.3