From 512abe64f44add7f20cef33442578012869efe72 Mon Sep 17 00:00:00 2001 From: Michael Rose Date: Tue, 20 Aug 2013 13:40:15 +0200 Subject: [PATCH] fixed space handling in commands (issue #495) --- prompt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/prompt.c b/prompt.c index 473633d..81f00bc 100644 --- a/prompt.c +++ b/prompt.c @@ -363,6 +363,11 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd) if (cmd[i] == ' ') { cmd[i] = '\0'; + + int j = i; + while (++j < MAX_STR_SIZE && isspace(cmd[j])); + i = j - 1; + numargs++; } } @@ -380,6 +385,9 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd) for (i = 0; i < 5; i++) { cmdargs[i] = cmd + pos; pos += strlen(cmdargs[i]) + 1; + + while (isspace(cmd[pos]) && pos < MAX_STR_SIZE) + ++pos; } /* no input */