diff options
author | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2020-12-28 15:58:38 +0200 |
---|---|---|
committer | Avi Halachmi (:avih) <avihpit@yahoo.com> | 2020-12-31 12:54:33 +0200 |
commit | 4f129a3eca7f8e1d6e3407c0689cbe313debf301 (patch) | |
tree | 84208ce103e7108e450f445373913986f85e0186 /input/cmd.c | |
parent | bb439efe0df3e90be25613745a544c75a97127dd (diff) | |
download | mpv-4f129a3eca7f8e1d6e3407c0689cbe313debf301.tar.bz2 mpv-4f129a3eca7f8e1d6e3407c0689cbe313debf301.tar.xz |
input.conf syntax: support custom quotes !XstringX!
Where X is any ASCII char chosen by the user. An argument is only
interpreted as custom-quoted if it starts with '!' and the line doesn't
end right after it. Custom quotes don't interpret backslash-escape.
This change only affects command arguments which mpv parses (not array
commands), and not tokens before the arguments (where applicable - key
name, input section, command prefixes, command name).
Diffstat (limited to 'input/cmd.c')
-rw-r--r-- | input/cmd.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/input/cmd.c b/input/cmd.c index 692b9f5ad5..3d3b7c6587 100644 --- a/input/cmd.c +++ b/input/cmd.c @@ -341,6 +341,19 @@ static int pctx_read_token(struct parse_ctx *ctx, bstr *out) } return 1; } + if (ctx->start.len > 1 && bstr_eatstart0(&ctx->str, "!")) { + char endquote[2] = {ctx->str.start[0], '!'}; + ctx->str = bstr_cut(ctx->str, 1); + int next = bstr_find(ctx->str, (bstr){endquote, 2}); + if (next < 0) { + MP_ERR(ctx, "Unterminated custom quote: ...>%.*s<.\n", BSTR_P(start)); + return -1; + } + *out = bstr_splice(ctx->str, 0, next); + ctx->str = bstr_cut(ctx->str, next+2); + return 1; + } + return read_token(ctx->str, &ctx->str, out) ? 1 : 0; } |