diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2019-02-05 07:39:21 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-02-11 10:15:00 -0500 |
commit | 41e10db0de243c903e28ae8f0b669ff681974e69 (patch) | |
tree | 0fadf790dd0f3e283e6c429fa94c85e74895f54e /sway/ipc-server.c | |
parent | Fix quote stripping (diff) | |
download | sway-41e10db0de243c903e28ae8f0b669ff681974e69.tar.gz sway-41e10db0de243c903e28ae8f0b669ff681974e69.tar.zst sway-41e10db0de243c903e28ae8f0b669ff681974e69.zip |
IPC_COMMAND: split on newline
This splits commands given in IPC_COMMAND on newline to match i3's
behavior.
Diffstat (limited to 'sway/ipc-server.c')
-rw-r--r-- | sway/ipc-server.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index d1920cfd..eb6f159d 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -595,6 +595,16 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
595 | switch (client->current_command) { | 595 | switch (client->current_command) { |
596 | case IPC_COMMAND: | 596 | case IPC_COMMAND: |
597 | { | 597 | { |
598 | char *line = strtok(buf, "\n"); | ||
599 | while (line) { | ||
600 | size_t line_length = strlen(line); | ||
601 | if (line + line_length >= buf + client->payload_length) { | ||
602 | break; | ||
603 | } | ||
604 | line[line_length] = ';'; | ||
605 | line = strtok(NULL, "\n"); | ||
606 | } | ||
607 | |||
598 | list_t *res_list = execute_command(buf, NULL, NULL); | 608 | list_t *res_list = execute_command(buf, NULL, NULL); |
599 | transaction_commit_dirty(); | 609 | transaction_commit_dirty(); |
600 | char *json = cmd_results_to_json(res_list); | 610 | char *json = cmd_results_to_json(res_list); |