summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-05 23:34:28 +0200
committerwm4 <wm4@nowhere>2012-08-05 23:51:49 +0200
commit94782e464d985b6e653618d8a61cf2ee817c3e9f (patch)
treeab0aa78634cff9e743340d86537e8ec1a94d989a /input
parent039a6194a473564f37525e94b689494c00145c5d (diff)
downloadmpv-94782e464d985b6e653618d8a61cf2ee817c3e9f.tar.bz2
mpv-94782e464d985b6e653618d8a61cf2ee817c3e9f.tar.xz
options: get rid of ambiguous option parsing
Options parsing used to be ambiguous, as in the splitting into option and values pairs was ambiguous. Example: -option -something It wasn't clear whether -option actually takes an argument or not. The string "-something" could either be a separate option, or an argument to "-option". The code had to call the option specific parser function to resolve this. This made everything complicated and didn't even have a real use. There was only one case where this was actually used: string lists (m_option_type_string_list) and options based on it. That is because this option type actually turns a single option into a proxy for several real arguments, e.g. "vf*" can handle "-vf-add" and "-vf-clr". Options suffixed with "-clr" are the only options of this group which take no arguments. This is ambiguous only with the "old syntax" (as shown above). The "new" option syntax always puts option name and value into same argument. (E.g. "--option=--something" or "--option" "--something".) Simplify the code by making it statically known whether an option takes a parameter or not with the flag M_OPT_TYPE_OLD_SYNTAX_NO_PARAM. If it's set, the option parser assumes the option takes no argument. The only real ambiguity left, string list options that end on "-clr", are special cased in the parser. Remove some duplication of the logic in the command line parser by moving all argument splitting logic into split_opt(). (It's arguable whether that can be considered code duplication, but now the code is a bit simpler anyway. This might be subjective.) Remove the "ambiguous" parameter from all option parsing related code. Make m_config unaware of the pre-parsing concept. Make most CONF_NOCFG options also CONF_GLOBAL (except those explicitly usable as per-file options.)
Diffstat (limited to 'input')
-rw-r--r--input/input.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/input/input.c b/input/input.c
index 496c5ca46e..690321f7fe 100644
--- a/input/input.c
+++ b/input/input.c
@@ -484,8 +484,8 @@ static const m_option_t input_conf[] = {
OPT_STRING("conf", input.config_file, CONF_GLOBAL, OPTDEF_STR("input.conf")),
OPT_INT("ar-delay", input.ar_delay, CONF_GLOBAL),
OPT_INT("ar-rate", input.ar_rate, CONF_GLOBAL),
- { "keylist", print_key_list, CONF_TYPE_PRINT_FUNC, CONF_NOCFG },
- { "cmdlist", print_cmd_list, CONF_TYPE_PRINT_FUNC, CONF_NOCFG },
+ { "keylist", print_key_list, CONF_TYPE_PRINT_FUNC, CONF_GLOBAL | CONF_NOCFG },
+ { "cmdlist", print_cmd_list, CONF_TYPE_PRINT_FUNC, CONF_GLOBAL | CONF_NOCFG },
OPT_STRING("js-dev", input.js_dev, CONF_GLOBAL),
OPT_STRING("ar-dev", input.ar_dev, CONF_GLOBAL),
OPT_STRING("file", input.in_file, CONF_GLOBAL),