[MPlayer-cvslog] r34257 - in trunk: cfg-common.h cfg-mplayer.h m_option.c m_option.h

reimar subversion at mplayerhq.hu
Tue Oct 25 22:18:35 CEST 2011


Author: reimar
Date: Tue Oct 25 22:18:35 2011
New Revision: 34257

Log:
Sanitize include behaviour.

The normal func_param argument type will iterate over all previous
values each time a new value is assigned.
This leads e.g. to a complete mess and non-working recursion limiting
when creating a config file that includes itself.
Seem to also fix bug #1994.

Modified:
   trunk/cfg-common.h
   trunk/cfg-mplayer.h
   trunk/m_option.c
   trunk/m_option.h

Modified: trunk/cfg-common.h
==============================================================================
--- trunk/cfg-common.h	Tue Oct 25 21:22:10 2011	(r34256)
+++ trunk/cfg-common.h	Tue Oct 25 22:18:35 2011	(r34257)
@@ -305,7 +305,7 @@ const m_option_t common_opts[] = {
 #ifdef CONFIG_ICONV
     {"msgcharset", &mp_msg_charset, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
 #endif
-    {"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL},
+    {"include", cfg_include, CONF_TYPE_FUNC_PARAM_IMMEDIATE, CONF_NOSAVE, 0, 0, NULL},
 #ifdef CONFIG_PRIORITY
     {"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
 #endif

Modified: trunk/cfg-mplayer.h
==============================================================================
--- trunk/cfg-mplayer.h	Tue Oct 25 21:22:10 2011	(r34256)
+++ trunk/cfg-mplayer.h	Tue Oct 25 22:18:35 2011	(r34257)
@@ -301,7 +301,7 @@ const m_option_t mplayer_opts[]={
     {"noenqueue", &enqueue, CONF_TYPE_FLAG, 0, 1, 0, NULL},
     {"guiwid", "-guiwid has been removed, use -gui-wid instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
     {"gui-wid", &guiWinID, CONF_TYPE_INT, 0, 0, 0, NULL},
-    {"gui-include", cfg_gui_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL},
+    {"gui-include", cfg_gui_include, CONF_TYPE_FUNC_PARAM_IMMEDIATE, CONF_NOSAVE, 0, 0, NULL},
 #endif
 
     {"noloop", &mpctx_s.loop_times, CONF_TYPE_FLAG, 0, 0, -1, NULL},

Modified: trunk/m_option.c
==============================================================================
--- trunk/m_option.c	Tue Oct 25 21:22:10 2011	(r34256)
+++ trunk/m_option.c	Tue Oct 25 22:18:35 2011	(r34257)
@@ -715,6 +715,25 @@ const m_option_type_t m_option_type_stri
 
 ///////////////////  Func based options
 
+static int parse_call_func(const m_option_t* opt,const char *name, const char *param, void* dst, int src) {
+  ((m_opt_func_param_t) opt->p)(opt,param);
+}
+
+// special variant, will not have a history/be able to
+// be used as per-file option etc.
+const m_option_type_t m_option_type_func_param_immediate = {
+  "Func param once",
+  "",
+  0,
+  M_OPT_TYPE_INDIRECT,
+  parse_call_func,
+  NULL,
+  NULL, // Nothing to do on save
+  NULL,
+  NULL,
+  NULL
+};
+
 // A chained list to save the various calls for func_param and func_full
 typedef struct m_func_save m_func_save_t;
 struct m_func_save {

Modified: trunk/m_option.h
==============================================================================
--- trunk/m_option.h	Tue Oct 25 21:22:10 2011	(r34256)
+++ trunk/m_option.h	Tue Oct 25 22:18:35 2011	(r34257)
@@ -62,6 +62,7 @@ extern const m_option_type_t m_option_ty
 // Func-based types
 extern const m_option_type_t m_option_type_func_full;
 extern const m_option_type_t m_option_type_func_param;
+extern const m_option_type_t m_option_type_func_param_immediate;
 extern const m_option_type_t m_option_type_func;
 
 /// Callback used to reset func options.
@@ -177,6 +178,7 @@ extern const m_obj_params_t m_span_param
 #define CONF_TYPE_STRING	(&m_option_type_string)
 #define CONF_TYPE_FUNC		(&m_option_type_func)
 #define CONF_TYPE_FUNC_PARAM	(&m_option_type_func_param)
+#define CONF_TYPE_FUNC_PARAM_IMMEDIATE (&m_option_type_func_param_immediate)
 #define CONF_TYPE_PRINT		(&m_option_type_print)
 #define CONF_TYPE_PRINT_INDIRECT (&m_option_type_print_indirect)
 #define CONF_TYPE_PRINT_FUNC	(&m_option_type_print_func)


More information about the MPlayer-cvslog mailing list