1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-14 02:51:26 +00:00

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.
This commit is contained in:
wm4 2013-11-29 23:06:25 +01:00
parent 924c4c1fa5
commit 5fe5fb02b4

View File

@ -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);