changeset 34169:9b617726812c

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.
author reimar
date Tue, 25 Oct 2011 20:18:35 +0000
parents 55abe5125482
children a05c274e1409
files cfg-common.h cfg-mplayer.h m_option.c m_option.h
diffstat 4 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Tue Oct 25 19:22:10 2011 +0000
+++ b/cfg-common.h	Tue Oct 25 20:18:35 2011 +0000
@@ -305,7 +305,7 @@
 #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
--- a/cfg-mplayer.h	Tue Oct 25 19:22:10 2011 +0000
+++ b/cfg-mplayer.h	Tue Oct 25 20:18:35 2011 +0000
@@ -301,7 +301,7 @@
     {"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},
--- a/m_option.c	Tue Oct 25 19:22:10 2011 +0000
+++ b/m_option.c	Tue Oct 25 20:18:35 2011 +0000
@@ -715,6 +715,25 @@
 
 ///////////////////  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 {
--- a/m_option.h	Tue Oct 25 19:22:10 2011 +0000
+++ b/m_option.h	Tue Oct 25 20:18:35 2011 +0000
@@ -62,6 +62,7 @@
 // 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 @@
 #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)