1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-19 21:31:52 +00:00

options: fix failure to parse trailing ',' in string list

A trailing separator in string list options was ignored after recent
commit e873d703e9 ("options: change option parsing to use bstr"),
which broke uses such as "-vo vdpau,". Fix.
This commit is contained in:
Uoti Urpala 2011-07-31 20:25:22 +03:00
parent 9d25699c58
commit ce112e0789
2 changed files with 5 additions and 4 deletions

3
bstr.c
View File

@ -129,8 +129,7 @@ struct bstr bstr_splice(struct bstr str, int start, int end)
end += str.len; end += str.len;
end = FFMIN(end, str.len); end = FFMIN(end, str.len);
start = FFMAX(start, 0); start = FFMAX(start, 0);
if (start >= end) end = FFMAX(end, start);
return (struct bstr){NULL, 0};
str.start += start; str.start += start;
str.len = end - start; str.len = end - start;
return str; return str;

View File

@ -717,11 +717,13 @@ static int parse_str_list(const m_option_t *opt, struct bstr name,
char *ptr = str.start; char *ptr = str.start;
n = 0; n = 0;
while (str.len) { while (1) {
struct bstr el = get_nextsep(&str, separator, 1); struct bstr el = get_nextsep(&str, separator, 1);
res[n] = bstrdup0(NULL, el); res[n] = bstrdup0(NULL, el);
str = bstr_cut(str, 1);
n++; n++;
if (!str.len)
break;
str = bstr_cut(str, 1);
} }
res[n] = NULL; res[n] = NULL;
talloc_free(ptr); talloc_free(ptr);