From 4f129a3eca7f8e1d6e3407c0689cbe313debf301 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Mon, 28 Dec 2020 15:58:38 +0200 Subject: 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). --- input/cmd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'input') 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; } -- cgit v1.2.3