From 5fe5fb02b49eb2c5dbea507b5e4fa914751debf1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 29 Nov 2013 23:06:25 +0100 Subject: 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. --- mpvcore/input/input.c | 13 +++++-------- 1 file 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); -- cgit v1.2.3