From 1a5a7a49293c2c70a5caf9d51dad7bd5aa938471 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 18 Sep 2012 15:50:24 +0200 Subject: 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. --- DOCS/man/en/options.rst | 22 +++++++++++----------- cfg-mplayer.h | 8 ++++---- m_option.c | 24 ++++++++---------------- m_option.h | 2 +- mplayer.c | 2 +- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 70b791c1ba..da7ed79e03 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -87,8 +87,8 @@ :``--afm=ffmpeg``: Try FFmpeg's libavcodec codecs first. :``--afm=acm,dshow``: Try Win32 codecs first. ---aid= - Select audio channel. ``auto`` selects the default, ``off`` disables audio. +--aid= + Select audio channel. ``auto`` selects the default, ``no`` disables audio. See also ``--alang``. --alang= @@ -789,7 +789,7 @@ backwards since it has to rewind to the beginning to find an exact frame position. ---hr-seek= +--hr-seek= 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= 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= - Loops playback times. ``inf`` means forever and ``off`` disables +--loop= + Loops playback times. ``inf`` means forever and ``no`` disables looping. --mc= @@ -1694,9 +1694,9 @@ --shuffle Play files in random order. ---sid= +--sid= Display the subtitle stream specified by (0-31). ``auto`` selects the - default, ``off`` disables subtitles. + default, ``no`` disables subtitles. See also ``--slang``, ``--vobsubid``, ``--no-sub``. --slang= @@ -2256,8 +2256,8 @@ :``--vfm=xanim``: Try XAnim codecs first. ---vid= - Select video channel. ``auto`` selects the default, ``off`` disables video. +--vid= + 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 diff --git a/cfg-mplayer.h b/cfg-mplayer.h index 8dfebd2a5d..dd90df21d6 100644 --- a/cfg-mplayer.h +++ b/cfg-mplayer.h @@ -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), diff --git a/m_option.c b/m_option.c index 62887f4c48..48539b3a4c 100644 --- a/m_option.c +++ b/m_option.c @@ -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", diff --git a/m_option.h b/m_option.h index acbbb3fd9f..69694c4286 100644 --- a/m_option.h +++ b/m_option.h @@ -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. diff --git a/mplayer.c b/mplayer.c index 376b243d58..4e59dd397e 100644 --- a/mplayer.c +++ b/mplayer.c @@ -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, -- cgit v1.2.3