summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-29 23:06:25 +0100
committerwm4 <wm4@nowhere>2013-11-30 01:08:22 +0100
commit5fe5fb02b49eb2c5dbea507b5e4fa914751debf1 (patch)
treec9d386e6dd9e0b7240d65a4de61bc6083a7189cd
parent924c4c1fa551b7c7268fd69a67d0796883a7aa18 (diff)
downloadmpv-5fe5fb02b49eb2c5dbea507b5e4fa914751debf1.tar.bz2
mpv-5fe5fb02b49eb2c5dbea507b5e4fa914751debf1.tar.xz
input: require space before '#' comments
So e.g. show_text abc#def will now print "abc#def" instead of "#def". It's simpler, more consistent with how ";" and other things are handled, and also possibly avoids bothering the user with extra escaping.
-rw-r--r--mpvcore/input/input.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 959d2aad3b..658f82f764 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -861,14 +861,11 @@ static int parse_cycle_dir(const struct m_option *opt, struct bstr name,
static bool read_token(bstr str, bstr *out_rest, bstr *out_token)
{
bstr t = bstr_lstrip(str);
- // Command separator
- if (t.len && t.start[0] == ';')
- return false;
- int next = bstrcspn(t, WHITESPACE "#");
- // Handle comments
- if (t.len && next < t.len && t.start[next] == '#')
- t = bstr_splice(t, 0, next);
- if (!t.len)
+ char nextc = t.len > 0 ? t.start[0] : 0;
+ if (nextc == '#' || nextc == ';')
+ return false; // comment or command separator
+ int next = bstrcspn(t, WHITESPACE);
+ if (!next)
return false;
*out_token = bstr_splice(t, 0, next);
*out_rest = bstr_cut(t, next);