summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-19 15:31:17 +0200
committerwm4 <wm4@nowhere>2015-04-19 15:31:17 +0200
commit8e0cf9d878cd25977d0de312c5746117fe33c6a9 (patch)
tree0428c1d3b72be064932a9db00df16dcdec2f1d69 /options/m_option.c
parentc96404d8243ffaea958b6d1ab16e73dd0aaf9276 (diff)
downloadmpv-8e0cf9d878cd25977d0de312c5746117fe33c6a9.tar.bz2
mpv-8e0cf9d878cd25977d0de312c5746117fe33c6a9.tar.xz
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.
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/options/m_option.c b/options/m_option.c
index b5c865b8b4..bd8e3357b9 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -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)) {