From 50008adf4af5360f87109d6264aa77ac82f2a80a Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 26 Jun 2017 21:07:00 +0200 Subject: options: handle suffixes like -add in a more generic way This affects options like --vf or --display-tags. These used a "*" suffix to match all options starting with a specific name, and handled the rest in the option parser. Change this to remove the "*" special case, and require every option parser to declare a list of allowed suffixes via m_option_type.actions. The new way is conceptually simpler, because we don't have to account for the "*" in a bunch of places anymore, and instead everything is centrally handled in the CLI part of the option parser, where it's actually needed. It automatically enables suffixes like -add for a bunch of other stringlist options. --- player/command.c | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index bb94fb0892..bc9ee4ab26 100644 --- a/player/command.c +++ b/player/command.c @@ -351,15 +351,7 @@ int mp_on_set_option(void *ctx, struct m_config_option *co, void *data, int flag { struct MPContext *mpctx = ctx; struct command_ctx *cmd = mpctx->command_ctx; - - // Normalize "vf*" to "vf" const char *name = co->name; - bstr bname = bstr0(name); - char tmp[50]; - if (bstr_eatend0(&bname, "*")) { - snprintf(tmp, sizeof(tmp), "%.*s", BSTR_P(bname)); - name = tmp; - } // Skip going through mp_property_generic_option (typically), because the // property implementation is trivial, and can break some obscure features @@ -430,17 +422,6 @@ static int mp_property_generic_option(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } -// Dumb special-case: the option name ends in a "*". -static int mp_property_generic_option_star(void *ctx, struct m_property *prop, - int action, void *arg) -{ - struct m_property prop2 = *prop; - char name[80]; - snprintf(name, sizeof(name), "%s*", prop->name); - prop2.name = name; - return mp_property_generic_option(ctx, &prop2, action, arg); -} - /// Playback speed (RW) static int mp_property_playback_speed(void *ctx, struct m_property *prop, int action, void *arg) @@ -5721,12 +5702,6 @@ void command_init(struct MPContext *mpctx) .call = mp_property_generic_option, .is_option = true, }; - - bstr bname = bstr0(prop.name); - if (bstr_eatend0(&bname, "*")) { - prop.name = bstrto0(ctx, bname); - prop.call = mp_property_generic_option_star; - } } if (prop.name) { -- cgit v1.2.3