From e9f49ea84de06e657067c16d9f43d531ef22b062 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Dec 2013 23:11:35 +0100 Subject: options: remove legacy hacks for sub-option handling --- mpvcore/m_config.c | 24 ---------------------- mpvcore/m_config.h | 5 ----- mpvcore/m_option.c | 58 ++++++++++++------------------------------------------ mpvcore/m_option.h | 2 -- video/filter/vf.c | 25 ++++++++--------------- 5 files changed, 21 insertions(+), 93 deletions(-) diff --git a/mpvcore/m_config.c b/mpvcore/m_config.c index 2d6cc5a554..851b54489e 100644 --- a/mpvcore/m_config.c +++ b/mpvcore/m_config.c @@ -237,12 +237,6 @@ int m_config_apply_defaults(struct m_config *config, const char *name, for (int n = 0; defaults && defaults[n].name; n++) { struct m_obj_settings *entry = &defaults[n]; if (name && strcmp(entry->name, name) == 0) { - if (entry->attribs && strcmp(entry->attribs[0], "_oldargs_") == 0) { - mp_tmsg(MSGT_CFGPARSER, MSGL_ERR, - "Filter '%s' can't take defaults, because it uses " - "custom option parsing.\n", name); - return -1; - } r = m_config_set_obj_params(config, entry->attribs); break; } @@ -250,24 +244,6 @@ int m_config_apply_defaults(struct m_config *config, const char *name, return r; } -int m_config_initialize_obj(struct m_config *config, struct m_obj_desc *desc, - void **ppriv, char ***pargs) -{ - if (desc->priv_size) { - int r = m_config_set_obj_params(config, *pargs); - if (r < 0) - return r; - *ppriv = config->optstruct; - *pargs = NULL; - } else if (*pargs && !strcmp((*pargs)[0], "_oldargs_")) { - // Handle things which still use the old subopt parser - *pargs = (char **)((*pargs)[1]); - } else { - *pargs = NULL; - } - return 0; -} - static void ensure_backup(struct m_config *config, struct m_config_option *co) { if (co->opt->type->flags & M_OPT_TYPE_HAS_CHILD) diff --git a/mpvcore/m_config.h b/mpvcore/m_config.h index c4c20a2ca5..8a8865d68e 100644 --- a/mpvcore/m_config.h +++ b/mpvcore/m_config.h @@ -93,11 +93,6 @@ int m_config_set_obj_params(struct m_config *conf, char **args); int m_config_apply_defaults(struct m_config *config, const char *name, struct m_obj_settings *defaults); -// Initialize an object (VO/VF/...) in one go, including legacy handling. -// This is pretty specialized, and is just for convenience. -int m_config_initialize_obj(struct m_config *config, struct m_obj_desc *desc, - void **ppriv, char ***pargs); - // Make sure the option is backed up. If it's already backed up, do nothing. // All backed up options can be restored with m_config_restore_backups(). void m_config_backup_opt(struct m_config *config, const char *opt); diff --git a/mpvcore/m_option.c b/mpvcore/m_option.c index 54ab15ba58..cda2569454 100644 --- a/mpvcore/m_option.c +++ b/mpvcore/m_option.c @@ -2164,11 +2164,8 @@ static int parse_obj_settings(struct bstr opt, struct bstr *pstr, if (bstr_eatstart0(pstr, "=") || bstr_eatstart0(pstr, ":")) has_param = true; - bool legacy = false; bool skip = false; - if (m_obj_list_find(&desc, list, str)) { - legacy = !desc.priv_size && list->legacy_hacks; - } else { + if (!m_obj_list_find(&desc, list, str)) { if (!list->allow_unknown_entries) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: %.*s doesn't exist.\n", BSTR_P(opt), BSTR_P(str)); @@ -2188,38 +2185,15 @@ static int parse_obj_settings(struct bstr opt, struct bstr *pstr, } if (has_param) { - if (legacy) { - // Should perhaps be parsed as escape-able string. But this is a - // compatibility path, so it's not worth the trouble. - int next = bstrcspn(*pstr, ","); - bstr param = bstr_splice(*pstr, 0, next); - *pstr = bstr_cut(*pstr, next); - if (!bstrcmp0(param, "help")) { - if (desc.print_help) { - desc.print_help(); - } else { - mp_msg(MSGT_CFGPARSER, MSGL_WARN, - "Option %.*s: %.*s has no option description.\n", - BSTR_P(opt), BSTR_P(str)); - } - return M_OPT_EXIT - 1; - } - if (_ret) { - plist = talloc_zero_array(NULL, char *, 4); - plist[0] = talloc_strdup(NULL, "_oldargs_"); - plist[1] = bstrto0(NULL, param); - } - } else { - struct m_config *config = NULL; - if (!skip) - config = m_config_from_obj_desc_noalloc(NULL, &desc); - r = m_obj_parse_sub_config(opt, str, pstr, config, - M_SETOPT_CHECK_ONLY, desc.print_help, - _ret ? &plist : NULL); - talloc_free(config); - if (r < 0) - return r; - } + struct m_config *config = NULL; + if (!skip) + config = m_config_from_obj_desc_noalloc(NULL, &desc); + r = m_obj_parse_sub_config(opt, str, pstr, config, + M_SETOPT_CHECK_ONLY, desc.print_help, + _ret ? &plist : NULL); + talloc_free(config); + if (r < 0) + return r; } if (!_ret) return 1; @@ -2482,15 +2456,9 @@ static char *print_obj_settings_list(const m_option_t *opt, const void *val) for (int i = 0; entry->attribs[i * 2 + 0]; i++) { if (i > 0) res = talloc_strdup_append(res, ":"); - if (strcmp(entry->attribs[i * 2 + 0], "_oldargs_") == 0) { - // Compatibility crap; write just the arg without escaping, - // and hope it won't crash and burn. - res = talloc_strdup_append(res, entry->attribs[i * 2 + 1]); - } else { - append_param(&res, entry->attribs[i * 2 + 0]); - res = talloc_strdup_append(res, "="); - append_param(&res, entry->attribs[i * 2 + 1]); - } + append_param(&res, entry->attribs[i * 2 + 0]); + res = talloc_strdup_append(res, "="); + append_param(&res, entry->attribs[i * 2 + 1]); } } } diff --git a/mpvcore/m_option.h b/mpvcore/m_option.h index 684fc2c715..dfc9e28a9b 100644 --- a/mpvcore/m_option.h +++ b/mpvcore/m_option.h @@ -127,8 +127,6 @@ struct m_obj_list { // Allow unknown entries, for which a dummy entry is inserted, and whose // options are skipped and ignored. bool allow_unknown_entries; - // If object has no options set, assume it parses options on its own. - bool legacy_hacks; }; // Find entry by name diff --git a/video/filter/vf.c b/video/filter/vf.c index c88621afdb..100b9d241b 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -266,27 +266,18 @@ error: vf_instance_t *vf_open_filter(struct MPOpts *opts, vf_instance_t *next, const char *name, char **args) { - if (args && strcmp(args[0], "_oldargs_")) { + if (strcmp(name, "vo") != 0) { int i, l = 0; for (i = 0; args && args[2 * i]; i++) l += 1 + strlen(args[2 * i]) + 1 + strlen(args[2 * i + 1]); l += strlen(name); - { - char str[l + 1]; - char *p = str; - p += sprintf(str, "%s", name); - for (i = 0; args && args[2 * i]; i++) - p += sprintf(p, " %s=%s", args[2 * i], args[2 * i + 1]); - mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n", - mp_gtext("Opening video filter: "), str); - } - } else if (strcmp(name, "vo")) { - if (args && strcmp(args[0], "_oldargs_") == 0) - mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s=%s]\n", - mp_gtext("Opening video filter: "), name, args[1]); - else - mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n", - mp_gtext("Opening video filter: "), name); + char str[l + 1]; + char *p = str; + p += sprintf(str, "%s", name); + for (i = 0; args && args[2 * i]; i++) + p += sprintf(p, " %s=%s", args[2 * i], args[2 * i + 1]); + mp_msg(MSGT_VFILTER, MSGL_INFO, "%s[%s]\n", + "Opening video filter: ", str); } return vf_open(opts, next, name, args); } -- cgit v1.2.3