From d089772b69807b0a66e56f6501d2ecf3d70e0114 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 19 Oct 2014 21:43:08 +0200 Subject: ipc: skip empty and commented lines --- DOCS/man/ipc.rst | 6 +++++- input/ipc.c | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DOCS/man/ipc.rst b/DOCS/man/ipc.rst index f0c6004006..e377e2e881 100644 --- a/DOCS/man/ipc.rst +++ b/DOCS/man/ipc.rst @@ -49,7 +49,11 @@ can also be present. See `List of events`_ for a list of all supported events. If the first character (after skipping whitespace) is not ``{``, the command will be interpreted as non-JSON text command, as they are used in input.conf -(or ``mpv_command_string()`` in the client API). +(or ``mpv_command_string()`` in the client API). Additionally, line starting +with ``#`` and empty lines are ignored. + +Currently, embedded 0 bytes terminate the current line, but you should not +rely on this. Commands -------- diff --git a/input/ipc.c b/input/ipc.c index 64c4bac87b..a64be27de3 100644 --- a/input/ipc.c +++ b/input/ipc.c @@ -557,8 +557,10 @@ static void *client_thread(void *p) json_skip_whitespace(&line0); - char *reply_msg; - if (line0[0] == '{') { + char *reply_msg = NULL; + if (line0[0] == '\0' || line0[0] == '#') { + // skip + } else if (line0[0] == '{') { reply_msg = json_execute_command(arg, tmp, line0); } else { reply_msg = text_execute_command(arg, tmp, line0); -- cgit v1.2.3