diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-07-27 20:59:44 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-07-29 05:02:05 +0300 |
commit | 507fa7e2c23623dcbecf20a392ee025002c83866 (patch) | |
tree | 8bb5f2331af88dca98cfc799ac6ca45b09d775fe /parser-mpcmd.c | |
parent | 0958620591375b41a8d21dd2a3501e1c9e5e9cba (diff) | |
download | mpv-507fa7e2c23623dcbecf20a392ee025002c83866.tar.bz2 mpv-507fa7e2c23623dcbecf20a392ee025002c83866.tar.xz |
options: indicate ambiguous option parameters explicitly
Command line options like "-foo xyz" are ambiguous: "xyz" may be a
parameter to the option "foo" or an unrelated argument. Instead of
relying on the struct m_config mode field (commandline/file) pass
parameters to specify ambiguous mode explicitly. Meant for "--foo"
options which are never ambiguous on command line either.
Diffstat (limited to 'parser-mpcmd.c')
-rw-r--r-- | parser-mpcmd.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/parser-mpcmd.c b/parser-mpcmd.c index d1b5f45753..354d4fd7a5 100644 --- a/parser-mpcmd.c +++ b/parser-mpcmd.c @@ -23,6 +23,7 @@ #include <string.h> #include <errno.h> #include <assert.h> +#include <stdbool.h> #include "mp_msg.h" #include "m_option.h" @@ -186,11 +187,12 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, if (mp_opt != NULL) { // Option exist if (mode == GLOBAL || (mp_opt->flags & M_OPT_GLOBAL)) tmp = (i + 1 < argc) - ? m_config_set_option(config, opt, argv[i + 1]) - : m_config_set_option(config, opt, NULL); + ? m_config_set_option(config, opt, argv[i + 1], + true) + : m_config_set_option(config, opt, NULL, false); else { tmp = m_config_check_option(config, opt, - (i + 1 < argc) ? argv[i + 1] : NULL); + (i + 1 < argc) ? argv[i + 1] : NULL, true); if (tmp >= 0 && mode != DROP_LOCAL) { play_tree_t *pt = last_entry ? last_entry : last_parent; @@ -255,7 +257,7 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, // Lock stdin if it will be used as input if (strcasecmp(argv[i], "-") == 0) - m_config_set_option(config, "noconsolecontrols", NULL); + m_config_set_option(config, "consolecontrols", "no", false); add_entry(&last_parent, &last_entry, entry); mode = LOCAL; // We start entry specific options } @@ -304,8 +306,8 @@ int m_config_preparse_command_line(m_config_t *config, int argc, char **argv) if (!opt) continue; // Set, non-pre-parse options will be ignored - int r = m_config_set_option(config, arg, - i+1 < argc ? argv[i+1] : NULL); + int r = m_config_set_option(config, arg, i+1 < argc ? argv[i+1] : NULL, + true); if (r < 0) ret = r; else |