# HG changeset patch # User reimar # Date 1319573915 0 # Node ID 9b617726812c2b9948606ed211941a8238c8f28a # Parent 55abe512548204357d65894249ccb01cba76a675 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. diff -r 55abe5125482 -r 9b617726812c cfg-common.h --- 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 diff -r 55abe5125482 -r 9b617726812c cfg-mplayer.h --- 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}, diff -r 55abe5125482 -r 9b617726812c m_option.c --- 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 { diff -r 55abe5125482 -r 9b617726812c m_option.h --- 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)