mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 15:52:25 +00:00
options: change [...] to balanced quotes
Useful for dealing with libavfilter's terrible graph syntax. Not strictly backwards compatible (for example "[a[b]" fails now - the "[" within the quote is interpreted now). But hopefully it's obscure enough not to warrant any kind of compatibility hacks.
This commit is contained in:
parent
c96404d824
commit
8e0cf9d878
@ -278,7 +278,9 @@ quotes.
|
||||
|
||||
The ``[...]`` from of quotes wraps everything between ``[`` and ``]``. It's
|
||||
useful with shells that don't interpret these characters in the middle of
|
||||
an argument (like bash).
|
||||
an argument (like bash). These quotes are balanced (since mpv 0.9.0): the ``[``
|
||||
and ``]`` nest, and the quote terminates on the last ``]`` that has no matching
|
||||
``[`` within the string. (For example, ``[a[b]c]`` results in ``a[b]c``.)
|
||||
|
||||
The fixed-length quoting syntax is intended for use with external
|
||||
scripts and programs.
|
||||
|
@ -1736,11 +1736,22 @@ static int read_subparam(struct mp_log *log, bstr optname,
|
||||
}
|
||||
p = bstr_cut(p, 1);
|
||||
} else if (bstr_eatstart0(&p, "[")) {
|
||||
if (!bstr_split_tok(p, "]", &subparam, &p)) {
|
||||
bstr s = p;
|
||||
int balance = 1;
|
||||
while (p.len && balance > 0) {
|
||||
if (p.start[0] == '[') {
|
||||
balance++;
|
||||
} else if (p.start[0] == ']') {
|
||||
balance--;
|
||||
}
|
||||
p = bstr_cut(p, 1);
|
||||
}
|
||||
if (balance != 0) {
|
||||
mp_err(log, "Terminating ']' missing for '%.*s'\n",
|
||||
BSTR_P(optname));
|
||||
return M_OPT_INVALID;
|
||||
}
|
||||
subparam = bstr_splice(s, 0, s.len - p.len - 1);
|
||||
} else if (bstr_eatstart0(&p, "%")) {
|
||||
int optlen = bstrtoll(p, &p, 0);
|
||||
if (!bstr_startswith0(p, "%") || (optlen > p.len - 1)) {
|
||||
|
Loading…
Reference in New Issue
Block a user