changeset 5655:117f34bb7097

Add correct loop option parsing in command line parser. Reset the config while looping inside a file You can now define GLOBAL_OPTIONS_ONLY in your config.h to have only global options (ie no per file option)
author albeu
date Wed, 17 Apr 2002 12:23:52 +0000
parents a8e785ce5cbf
children 70031f0cc4d2
files cfgparser.c mplayer.c
diffstat 2 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfgparser.c	Wed Apr 17 07:43:56 2002 +0000
+++ b/cfgparser.c	Wed Apr 17 12:23:52 2002 +0000
@@ -28,7 +28,11 @@
 #define CONFIG_RUNNING (1<<1)
 
 #define SET_GLOBAL(c)  (c->flags |= CONFIG_GLOBAL)
+#ifdef GLOBAL_OPTIONS_ONLY
+#define UNSET_GLOBAL(c)
+#else
 #define UNSET_GLOBAL(c) (c->flags &= (!CONFIG_GLOBAL))
+#endif
 #define IS_GLOBAL(c) (c->flags & CONFIG_GLOBAL)
 #define SET_RUNNING(c) (c->flags |= CONFIG_RUNNING)
 #define IS_RUNNING(c) (c->flags & CONFIG_RUNNING)
@@ -1052,11 +1056,26 @@
 		    opt++;
 
 		    mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "this_opt = option: %s\n", opt);
+		    // We handle here some specific option
 		    if(strcasecmp(opt,"list-options") == 0) {
 		      m_config_list_options(config);
 		      exit(1);
-		    }
-		    tmp = m_config_set_option(config, opt, argv[i + 1]);
+		      // Loop option when it apply to a group
+		    } else if(strcasecmp(opt,"loop") == 0 &&
+			      (! config->last_entry || config->last_entry->child) ) {
+		      int l;
+		      char* end;
+		      l = strtol(argv[i+1],&end,0);
+		      if(!end)
+			tmp = ERR_OUT_OF_RANGE;
+		      else {
+			play_tree_t* pt = config->last_entry ? config->last_entry : config->last_parent;
+			l = l <= 0 ? -1 : l;
+			pt->loop = l;
+			tmp = 1;
+		      }
+		    } else // All normal options
+		      tmp = m_config_set_option(config, opt, argv[i + 1]);
 
 		    switch (tmp) {
 		    case ERR_NOT_AN_OPTION:
@@ -1091,7 +1110,7 @@
 	--config->recursion_depth;
 	if(config->last_parent != config->pt)
 	  mp_msg(MSGT_CFGPARSER, MSGL_ERR,"Missing }- ?\n");
-	UNSET_GLOBAL(config);
+	config->flags &= (!CONFIG_GLOBAL);
 	SET_RUNNING(config);
 	return 1; 
 #if 0
--- a/mplayer.c	Wed Apr 17 07:43:56 2002 +0000
+++ b/mplayer.c	Wed Apr 17 12:23:52 2002 +0000
@@ -2670,7 +2670,9 @@
   
   /* Looping. */
   if(eof==1 && loop_times>=0) {
-
+    int l = loop_times;
+    play_tree_iter_step(playtree_iter,0,0);
+    loop_times = l;
     mp_msg(MSGT_CPLAYER,MSGL_V,"loop_times = %d, eof = %d\n", loop_times,eof);
 
     if(loop_times>1) loop_times--; else