options: accept "yes" and "no" only for flags

This removes the alternative values like "off", "0", "false" etc., and
also the non-English versions of these.

This is done for general consistency. It's better to have a single way
of doing things when multiple ways don't add singificant value.

Also update some choices for consistency.
This commit is contained in:
wm4 2012-09-18 15:50:24 +02:00
parent 69ce4591d0
commit 1a5a7a4929
5 changed files with 25 additions and 33 deletions

View File

@ -87,8 +87,8 @@
:``--afm=ffmpeg``: Try FFmpeg's libavcodec codecs first.
:``--afm=acm,dshow``: Try Win32 codecs first.
--aid=<ID|auto|off>
Select audio channel. ``auto`` selects the default, ``off`` disables audio.
--aid=<ID|auto|no>
Select audio channel. ``auto`` selects the default, ``no`` disables audio.
See also ``--alang``.
--alang=<languagecode[,languagecode,...]>
@ -789,7 +789,7 @@
backwards since it has to rewind to the beginning to find an exact frame
position.
--hr-seek=<off|absolute|always>
--hr-seek=<no|absolute|yes>
Select when to use precise seeks that are not limited to keyframes. Such
seeks require decoding video from the previous keyframe up to the target
position and so can take some time depending on decoding performance. For
@ -797,11 +797,11 @@
default choice to use for seeks; it's possible to explicitly override that
default in the definition of key bindings and in slave mode commands.
:off: Never use precise seeks.
:no: Never use precise seeks.
:absolute: Use precise seeks if the seek is to an absolute position in the
file, such as a chapter seek, but not for relative seeks like
the default behavior of arrow keys (default).
:always: Use precise seeks whenever possible.
:yes: Use precise seeks whenever possible.
--hr-seek-demuxer-offset=<seconds>
This option exists to work around failures to do precise seeks (as in
@ -1139,8 +1139,8 @@
*NOTE*: This option is obsolete now that MPlayer has OpenDML support.
--loop=<number|inf|off>
Loops playback <number> times. ``inf`` means forever and ``off`` disables
--loop=<number|inf|no>
Loops playback <number> times. ``inf`` means forever and ``no`` disables
looping.
--mc=<seconds/frame>
@ -1694,9 +1694,9 @@
--shuffle
Play files in random order.
--sid=<ID|auto|off>
--sid=<ID|auto|no>
Display the subtitle stream specified by <ID> (0-31). ``auto`` selects the
default, ``off`` disables subtitles.
default, ``no`` disables subtitles.
See also ``--slang``, ``--vobsubid``, ``--no-sub``.
--slang=<languagecode[,languagecode,...]>
@ -2256,8 +2256,8 @@
:``--vfm=xanim``:
Try XAnim codecs first.
--vid=<ID|auto|off>
Select video channel. ``auto`` selects the default, ``off`` disables video.
--vid=<ID|auto|no>
Select video channel. ``auto`` selects the default, ``no`` disables video.
--vm
Try to change to a different video mode. Supported by the x11 and xv video

View File

@ -333,7 +333,7 @@ const m_option_t common_opts[] = {
{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
OPT_CHOICE("no-config", noconfig, CONF_GLOBAL | CONF_NOCFG | CONF_PRE_PARSE,
({"off", 0}, {"user", 1}, {"system", 2}, {"all", 3})),
({"no", 0}, {"user", 1}, {"system", 2}, {"all", 3})),
// ------------------------- stream options --------------------
@ -695,7 +695,7 @@ const m_option_t mplayer_opts[]={
OPT_FLAG_CONSTANTS("no-loop", loop_times, 0, 0, -1),
OPT_CHOICE_OR_INT("loop", loop_times, 0, 1, 10000,
({"off", -1}, {"0", -1},
({"no", -1}, {"0", -1},
{"inf", 0})),
{"playlist", NULL, CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN, 1, 0, NULL},
@ -712,7 +712,7 @@ const m_option_t mplayer_opts[]={
({"auto", 0}, {"decoder", 1}, {"sort", 2})),
OPT_MAKE_FLAGS("initial-audio-sync", initial_audio_sync, 0),
OPT_CHOICE("hr-seek", hr_seek, 0,
({"off", -1}, {"absolute", 0}, {"always", 1}, {"on", 1})),
({"no", -1}, {"absolute", 0}, {"always", 1}, {"yes", 1})),
OPT_FLOATRANGE("hr-seek-demuxer-offset", hr_seek_demuxer_offset, 0, -9, 99),
OPT_FLAG_CONSTANTS("no-autosync", autosync, 0, 0, -1),
OPT_INTRANGE("autosync", autosync, 0, 0, 10000),
@ -722,7 +722,7 @@ const m_option_t mplayer_opts[]={
OPT_CHOICE("term-osd", term_osd, 0,
({"force", 1},
{"auto", 2}, {"", 2},
{"off", 0})),
{"no", 0})),
OPT_STRING("term-osd-esc", term_osd_esc, 0, OPTDEF_STR("\x1b[A\r\x1b[K")),
OPT_STRING("playing-msg", playing_msg, 0),

View File

@ -94,23 +94,15 @@ static int parse_flag(const m_option_t *opt, struct bstr name,
struct bstr param, void *dst)
{
if (param.len) {
char * const enable[] = { "yes", "on", "ja", "si", "igen", "y", "j",
"i", "tak", "ja", "true", "1" };
for (int i = 0; i < sizeof(enable) / sizeof(enable[0]); i++) {
if (!bstrcasecmp0(param, enable[i])) {
if (dst)
VAL(dst) = opt->max;
return 1;
}
if (!bstrcasecmp0(param, "yes")) {
if (dst)
VAL(dst) = opt->max;
return 1;
}
char * const disable[] = { "no", "off", "nein", "nicht", "nem", "n",
"nie", "nej", "false", "0" };
for (int i = 0; i < sizeof(disable) / sizeof(disable[0]); i++) {
if (!bstrcasecmp0(param, disable[i])) {
if (dst)
VAL(dst) = opt->min;
return 1;
}
if (!bstrcasecmp0(param, "no")) {
if (dst)
VAL(dst) = opt->min;
return 1;
}
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Invalid parameter for %.*s flag: %.*s\n",

View File

@ -488,7 +488,7 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
#define OPT_CHOICE_OR_INT_(optname, varname, flags, minval, maxval, choices, ...) OPT_GENERAL(optname, varname, (flags) | CONF_RANGE, .min = minval, .max = maxval, .priv = (void *)&(const struct m_opt_choice_alternatives[]){OPT_HELPER_REMOVEPAREN choices, {NULL}}, __VA_ARGS__)
#define OPT_TIME(...) OPT_GENERAL(__VA_ARGS__, .type = &m_option_type_time)
#define OPT_TRACKCHOICE(name, var) OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"off", -2}, {"no", -2}, {"auto", -1}))
#define OPT_TRACKCHOICE(name, var) OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1}))
// subconf must have the type struct m_sub_options.
// flagv should be M_OPT_MERGE or M_OPT_FLATTEN.

View File

@ -2253,7 +2253,7 @@ int reinit_video_chain(struct MPContext *mpctx)
&vf_info_ass, NULL
};
char *vf_arg[] = {
"auto", "1", NULL
"auto", "yes", NULL
};
int retcode = 0;
struct vf_instance *vf_ass = vf_open_plugin_noerr(opts, libass_vfs,