diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-07-28 11:07:47 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-07-29 05:50:38 +0300 |
commit | e873d703e956d3e2e68b9e18562983b029b5c7a8 (patch) | |
tree | 44a2c48ae4e94bd580ffd5833cd71a037af36043 /parser-mpcmd.c | |
parent | d8374376c0d46ffab88b96eb32b52621c34f562c (diff) | |
download | mpv-e873d703e956d3e2e68b9e18562983b029b5c7a8.tar.bz2 mpv-e873d703e956d3e2e68b9e18562983b029b5c7a8.tar.xz |
options: change option parsing to use bstr
Using bstr allows simpler parsing code, especially because it avoids
the need to modify or copy strings just to terminate extracted
substrings.
Diffstat (limited to 'parser-mpcmd.c')
-rw-r--r-- | parser-mpcmd.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/parser-mpcmd.c b/parser-mpcmd.c index 354d4fd7a5..52de313e71 100644 --- a/parser-mpcmd.c +++ b/parser-mpcmd.c @@ -183,15 +183,15 @@ play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc, } else if (mode == LOCAL) // Drop params for empty entry mode = DROP_LOCAL; } else if (tmp == 0) { // 'normal' options - mp_opt = m_config_get_option(config, opt); + mp_opt = m_config_get_option(config, bstr(opt)); 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_option0(config, opt, argv[i + 1], true) - : m_config_set_option(config, opt, NULL, false); + : m_config_set_option0(config, opt, NULL, false); else { - tmp = m_config_check_option(config, opt, + tmp = m_config_check_option0(config, opt, (i + 1 < argc) ? argv[i + 1] : NULL, true); if (tmp >= 0 && mode != DROP_LOCAL) { play_tree_t *pt = @@ -257,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, "consolecontrols", "no", false); + m_config_set_option0(config, "consolecontrols", "no", false); add_entry(&last_parent, &last_entry, entry); mode = LOCAL; // We start entry specific options } @@ -301,13 +301,13 @@ int m_config_preparse_command_line(m_config_t *config, int argc, char **argv) break; arg++; - opt = m_config_get_option(config, arg); + opt = m_config_get_option(config, bstr(arg)); // Ignore invalid option 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, - true); + int r = m_config_set_option0(config, arg, i+1 < argc ? argv[i+1] : NULL, + true); if (r < 0) ret = r; else |