diff options
author | wm4 <wm4@nowhere> | 2012-09-03 22:44:44 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-18 21:07:29 +0200 |
commit | d29d4df634a9d847a2b5ef7a04f32726cd03c1ef (patch) | |
tree | 0d9b1f7adcd2bce7f45ea9e0e0bc8a0ce019df9b /m_option.c | |
parent | f97a85595bb5117db27fe18ea14986c42c116492 (diff) | |
download | mpv-d29d4df634a9d847a2b5ef7a04f32726cd03c1ef.tar.bz2 mpv-d29d4df634a9d847a2b5ef7a04f32726cd03c1ef.tar.xz |
options: remove M_OPT_IMPLICIT_DEFAULT
This was to make an option without value use the option's default value
(e.g. --term-osd is the same as --term-osd=auto). Make it simpler by
handling this case as an empty choice.
The flag was probably needed when option handling still did ambiguous
argument parsing.
Diffstat (limited to 'm_option.c')
-rw-r--r-- | m_option.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/m_option.c b/m_option.c index 583c2252c5..d2ab925a70 100644 --- a/m_option.c +++ b/m_option.c @@ -267,21 +267,13 @@ const struct m_option_type m_option_type_intpair = { static int parse_choice(const struct m_option *opt, struct bstr name, struct bstr param, void *dst) { - bool allow_empty = opt->flags & M_OPT_IMPLICIT_DEFAULT; - int ret; - struct m_opt_choice_alternatives *alt = opt->priv; - if (param.len == 0) { - if (!allow_empty) - return M_OPT_MISSING_PARAM; - ret = 0; - } else { - for ( ; alt->name; alt++) - if (!bstrcasecmp0(param, alt->name)) - break; - ret = 1; - } + for ( ; alt->name; alt++) + if (!bstrcasecmp0(param, alt->name)) + break; if (!alt->name) { + if (param.len == 0) + return M_OPT_MISSING_PARAM; mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid value for option %.*s: %.*s\n", BSTR_P(name), BSTR_P(param)); @@ -294,7 +286,7 @@ static int parse_choice(const struct m_option *opt, struct bstr name, if (dst) *(int *)dst = alt->value; - return ret; + return 1; } static char *print_choice(const m_option_t *opt, const void *val) |