summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-05-07 23:51:58 +0300
committerUoti Urpala <uau@mplayer2.org>2012-05-07 23:51:58 +0300
commit9fbfac25daaf6bdaab4c1213a294b59bded29b24 (patch)
treee72621d807b4777fcf92cd9cb5c78454bc2bd44a
parentc02d0ee703a52f50c3763a0eda67cfea13e4c76a (diff)
downloadmpv-9fbfac25daaf6bdaab4c1213a294b59bded29b24.tar.bz2
mpv-9fbfac25daaf6bdaab4c1213a294b59bded29b24.tar.xz
options: change -v parsing
Handle -v flags as a special case in command line preparsing stage, and change the option entry into a dummy one. Specifying "v" in config file no longer works (and the dummy entry shows an error in this case); "msglevel" can still be used for that purpose. Because the flag is now interpreted at an earlier parsing stage, it now affects the printing of some early messages that were only affected by the MPLAYER_VERBOSE environment variable before. The main motivation for this change is to get rid of the last CONF_TYPE_FUNC option.
-rw-r--r--cfg-mplayer.h3
-rw-r--r--mplayer.c8
-rw-r--r--parser-mpcmd.c8
-rw-r--r--parser-mpcmd.h3
4 files changed, 12 insertions, 10 deletions
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 6d105569ae..66b381a920 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -373,7 +373,8 @@ const m_option_t common_opts[] = {
// ------------------------- common options --------------------
OPT_MAKE_FLAGS("quiet", quiet, CONF_GLOBAL),
{"really-quiet", &verbose, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL},
- {"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL},
+ // -v is handled in command line preparser
+ {"v", NULL, CONF_TYPE_FLAG, CONF_NOCFG, 0, 0, NULL},
{"msglevel", (void *) msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
{"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
{"nomsgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
diff --git a/mplayer.c b/mplayer.c
index 2ca8518335..e1984e601c 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -149,12 +149,6 @@ char *heartbeat_cmd;
// Config file
//**************************************************************************//
-static int cfg_inc_verbose(m_option_t *conf)
-{
- ++verbose;
- return 0;
-}
-
#include "path.h"
//**************************************************************************//
@@ -3952,7 +3946,7 @@ int main(int argc, char *argv[])
mp_input_register_options(mpctx->mconfig);
// Preparse the command line
- m_config_preparse_command_line(mpctx->mconfig, argc, argv);
+ m_config_preparse_command_line(mpctx->mconfig, argc, argv, &verbose);
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL)
set_path_env();
diff --git a/parser-mpcmd.c b/parser-mpcmd.c
index 49b4e0c5fd..93011d3760 100644
--- a/parser-mpcmd.c
+++ b/parser-mpcmd.c
@@ -308,7 +308,8 @@ extern int mp_msg_levels[];
* command line parsing), and --really-quiet suppresses messages printed
* during normal options parsing.
*/
-int m_config_preparse_command_line(m_config_t *config, int argc, char **argv)
+int m_config_preparse_command_line(m_config_t *config, int argc, char **argv,
+ int *verbose)
{
int ret = 0;
@@ -330,6 +331,11 @@ int m_config_preparse_command_line(m_config_t *config, int argc, char **argv)
// Ignore invalid options
if (map_to_option(config, old_syntax, NULL, &opt, &param) < 0)
continue;
+ // "-v" is handled here
+ if (!bstrcmp0(opt, "v")) {
+ (*verbose)++;
+ continue;
+ }
// Set, non-pre-parse options will be ignored
int r = m_config_set_option(config, opt, param, old_syntax);
if (r < 0)
diff --git a/parser-mpcmd.h b/parser-mpcmd.h
index 3de9f626b5..948105ab6f 100644
--- a/parser-mpcmd.h
+++ b/parser-mpcmd.h
@@ -24,6 +24,7 @@
play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc,
char **argv);
-int m_config_preparse_command_line(m_config_t *config, int argc, char **argv);
+int m_config_preparse_command_line(m_config_t *config, int argc, char **argv,
+ int *verbose);
#endif /* MPLAYER_PARSER_MPCMD_H */