Skip to content
This repository
Browse code

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.
  • Loading branch information...
commit 9fbfac25daaf6bdaab4c1213a294b59bded29b24 1 parent c02d0ee
authored May 07, 2012
3  cfg-mplayer.h
@@ -373,7 +373,8 @@ const m_option_t common_opts[] = {
373 373
 // ------------------------- common options --------------------
374 374
     OPT_MAKE_FLAGS("quiet", quiet, CONF_GLOBAL),
375 375
     {"really-quiet", &verbose, CONF_TYPE_FLAG, CONF_GLOBAL|CONF_PRE_PARSE, 0, -10, NULL},
376  
-    {"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL},
  376
+    // -v is handled in command line preparser
  377
+    {"v", NULL, CONF_TYPE_FLAG, CONF_NOCFG, 0, 0, NULL},
377 378
         {"msglevel", (void *) msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
378 379
     {"msgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
379 380
     {"nomsgcolor", &mp_msg_color, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
8  mplayer.c
@@ -149,12 +149,6 @@ char *heartbeat_cmd;
149 149
 //             Config file
150 150
 //**************************************************************************//
151 151
 
152  
-static int cfg_inc_verbose(m_option_t *conf)
153  
-{
154  
-    ++verbose;
155  
-    return 0;
156  
-}
157  
-
158 152
 #include "path.h"
159 153
 
160 154
 //**************************************************************************//
@@ -3952,7 +3946,7 @@ int main(int argc, char *argv[])
3952 3946
     mp_input_register_options(mpctx->mconfig);
3953 3947
 
3954 3948
     // Preparse the command line
3955  
-    m_config_preparse_command_line(mpctx->mconfig, argc, argv);
  3949
+    m_config_preparse_command_line(mpctx->mconfig, argc, argv, &verbose);
3956 3950
 
3957 3951
 #if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL)
3958 3952
     set_path_env();
8  parser-mpcmd.c
@@ -308,7 +308,8 @@ extern int mp_msg_levels[];
308 308
  * command line parsing), and --really-quiet suppresses messages printed
309 309
  * during normal options parsing.
310 310
  */
311  
-int m_config_preparse_command_line(m_config_t *config, int argc, char **argv)
  311
+int m_config_preparse_command_line(m_config_t *config, int argc, char **argv,
  312
+                                   int *verbose)
312 313
 {
313 314
     int ret = 0;
314 315
 
@@ -330,6 +331,11 @@ int m_config_preparse_command_line(m_config_t *config, int argc, char **argv)
330 331
         // Ignore invalid options
331 332
         if (map_to_option(config, old_syntax, NULL, &opt, &param) < 0)
332 333
             continue;
  334
+        // "-v" is handled here
  335
+        if (!bstrcmp0(opt, "v")) {
  336
+            (*verbose)++;
  337
+            continue;
  338
+        }
333 339
         // Set, non-pre-parse options will be ignored
334 340
         int r = m_config_set_option(config, opt, param, old_syntax);
335 341
         if (r < 0)
3  parser-mpcmd.h
@@ -24,6 +24,7 @@
24 24
 
25 25
 play_tree_t *m_config_parse_mp_command_line(m_config_t *config, int argc,
26 26
                                             char **argv);
27  
-int m_config_preparse_command_line(m_config_t *config, int argc, char **argv);
  27
+int m_config_preparse_command_line(m_config_t *config, int argc, char **argv,
  28
+                                   int *verbose);
28 29
 
29 30
 #endif /* MPLAYER_PARSER_MPCMD_H */

0 notes on commit 9fbfac2

Please sign in to comment.
Something went wrong with that request. Please try again.