From b32a7b2294fff9f5ef0f5027e4e2ce1f01adc221 Mon Sep 17 00:00:00 2001 From: ptrasd Date: Wed, 7 Aug 2013 02:10:46 -0400 Subject: [PATCH 1/2] testing/toxic/prompt.c: changed execute() to skip whitespace at start of command --- testing/toxic/prompt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index 89c87d8f..a96c07bb 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -52,6 +52,11 @@ static void execute(ToxWindow *self, char *u_cmd) cmd[i - newlines] = u_cmd[i]; } + int leading_spc = 0; + for (i = 0; i < 256 && isspace(cmd[i]); ++i) + leading_spc++; + memmove(cmd, cmd + leading_spc, 256 - leading_spc); + if (!strcmp(cmd, "quit") || !strcmp(cmd, "exit") || !strcmp(cmd, "q")) { endwin(); exit(0); From caa75b52c37b16aa00f1cb692cc533444c5d716d Mon Sep 17 00:00:00 2001 From: ptrasd Date: Wed, 7 Aug 2013 02:25:20 -0400 Subject: [PATCH 2/2] testing/toxic/prompt.c: changed execute() to ignore whitespace at end of commands --- testing/toxic/prompt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index a96c07bb..b0e21c64 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -57,6 +57,12 @@ static void execute(ToxWindow *self, char *u_cmd) leading_spc++; memmove(cmd, cmd + leading_spc, 256 - leading_spc); + int cmd_end = strlen(cmd); + while (cmd_end > 0 && cmd_end--) + if (!isspace(cmd[cmd_end])) + break; + cmd[cmd_end + 1] = '\0'; + if (!strcmp(cmd, "quit") || !strcmp(cmd, "exit") || !strcmp(cmd, "q")) { endwin(); exit(0);