From 3006c4ba5dd119160bdcf1d650c66197a44de602 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 12 Mar 2020 14:04:14 +0100 Subject: options: remove min/max support from strings and string lists We don't really use this anymore. Only --playlist and vf_lavfi filter names did (to error on empty parameters), but it doesn't really matter. --- options/m_option.c | 28 +--------------------------- options/options.c | 3 +-- 2 files changed, 2 insertions(+), 29 deletions(-) (limited to 'options') diff --git a/options/m_option.c b/options/m_option.c index c55ca06bc8..3f01663fa9 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1155,17 +1155,6 @@ const m_option_type_t m_option_type_aspect = { #undef VAL #define VAL(x) (*(char **)(x)) -static int clamp_str(const m_option_t *opt, void *val) -{ - char *v = VAL(val); - int len = v ? strlen(v) : 0; - if ((opt->flags & M_OPT_MIN) && (len < opt->min)) - return M_OPT_OUT_OF_RANGE; - if ((opt->flags & M_OPT_MAX) && (len > opt->max)) - return M_OPT_OUT_OF_RANGE; - return 0; -} - static int parse_str(struct mp_log *log, const m_option_t *opt, struct bstr name, struct bstr param, void *dst) { @@ -1176,18 +1165,6 @@ static int parse_str(struct mp_log *log, const m_option_t *opt, return r; } - if ((opt->flags & M_OPT_MIN) && (param.len < opt->min)) { - mp_err(log, "Parameter must be >= %d chars: %.*s\n", - (int) opt->min, BSTR_P(param)); - return M_OPT_OUT_OF_RANGE; - } - - if ((opt->flags & M_OPT_MAX) && (param.len > opt->max)) { - mp_err(log, "Parameter must be <= %d chars: %.*s\n", - (int) opt->max, BSTR_P(param)); - return M_OPT_OUT_OF_RANGE; - } - if (dst) { talloc_free(VAL(dst)); VAL(dst) = bstrdup0(NULL, param); @@ -1214,7 +1191,7 @@ static int str_set(const m_option_t *opt, void *dst, struct mpv_node *src) if (src->format != MPV_FORMAT_STRING) return M_OPT_UNKNOWN; char *s = src->u.string; - int r = s ? clamp_str(opt, &s) : M_OPT_INVALID; + int r = s ? 0 : M_OPT_INVALID; if (r >= 0) copy_str(opt, dst, &s); return r; @@ -1458,9 +1435,6 @@ static int parse_str_list_impl(struct mp_log *log, const m_option_t *opt, } if (n == 0 && op != OP_NONE) return M_OPT_INVALID; - if (((opt->flags & M_OPT_MIN) && (n < opt->min)) || - ((opt->flags & M_OPT_MAX) && (n > opt->max))) - return M_OPT_OUT_OF_RANGE; if (!dst) return 1; diff --git a/options/options.c b/options/options.c index 3eebc2e0df..6443a294f0 100644 --- a/options/options.c +++ b/options/options.c @@ -341,8 +341,7 @@ static const m_option_t mp_opts[] = { // handled in command line pre-parser (parse_commandline.c) {"v", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, .offset = -1}, - {"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FILE, - .min = 1, .offset = -1}, + {"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FILE, .offset = -1}, {"{", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, .offset = -1}, {"}", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, -- cgit v1.2.3