mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 12:17:12 +00:00
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.
This commit is contained in:
parent
06718da79c
commit
3006c4ba5d
@ -1091,7 +1091,7 @@ const struct mp_user_filter_entry af_lavfi = {
|
||||
.name = "lavfi",
|
||||
.priv_size = sizeof(OPT_BASE_STRUCT),
|
||||
.options = (const m_option_t[]){
|
||||
OPT_STRING("graph", graph, M_OPT_MIN, .min = 1),
|
||||
OPT_STRING("graph", graph, 0),
|
||||
OPT_FLAG("fix-pts", fix_pts, 0),
|
||||
OPT_KEYVALUELIST("o", avopts, 0),
|
||||
{0}
|
||||
@ -1110,7 +1110,7 @@ const struct mp_user_filter_entry af_lavfi_bridge = {
|
||||
.name = "lavfi-bridge",
|
||||
.priv_size = sizeof(OPT_BASE_STRUCT),
|
||||
.options = (const m_option_t[]){
|
||||
OPT_STRING("name", filter_name, M_OPT_MIN, .min = 1),
|
||||
OPT_STRING("name", filter_name, 0),
|
||||
OPT_KEYVALUELIST("opts", filter_opts, 0),
|
||||
OPT_KEYVALUELIST("o", avopts, 0),
|
||||
{0}
|
||||
@ -1130,7 +1130,7 @@ const struct mp_user_filter_entry vf_lavfi = {
|
||||
.name = "lavfi",
|
||||
.priv_size = sizeof(OPT_BASE_STRUCT),
|
||||
.options = (const m_option_t[]){
|
||||
OPT_STRING("graph", graph, M_OPT_MIN, .min = 1),
|
||||
OPT_STRING("graph", graph, 0),
|
||||
OPT_KEYVALUELIST("o", avopts, 0),
|
||||
{0}
|
||||
},
|
||||
@ -1148,7 +1148,7 @@ const struct mp_user_filter_entry vf_lavfi_bridge = {
|
||||
.name = "lavfi-bridge",
|
||||
.priv_size = sizeof(OPT_BASE_STRUCT),
|
||||
.options = (const m_option_t[]){
|
||||
OPT_STRING("name", filter_name, M_OPT_MIN, .min = 1),
|
||||
OPT_STRING("name", filter_name, 0),
|
||||
OPT_KEYVALUELIST("opts", filter_opts, 0),
|
||||
OPT_KEYVALUELIST("o", avopts, 0),
|
||||
{0}
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user