From 155823e7ce4309dfaff303777772369b4ea7fcf2 Mon Sep 17 00:00:00 2001 From: Sanket Parmar Date: Wed, 21 Aug 2013 23:24:11 +0530 Subject: [PATCH] Fixed segfault and added support for single quotes in toxic --- testing/toxic/prompt.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c index e194a90e..6c762c86 100644 --- a/testing/toxic/prompt.c +++ b/testing/toxic/prompt.c @@ -358,8 +358,16 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd) int numargs = 0; for (i = 0; i < MAX_STR_SIZE; i++) { - if (cmd[i] == '\"') - while (cmd[++i] != '\"'); /* skip over strings */ + char quote_chr; + if (cmd[i] == '\"' || cmd[i] == '\'') { + quote_chr = cmd[i]; + while (cmd[++i] != quote_chr && i < MAX_STR_SIZE); /* skip over strings */ + /* Check if got qoute character */ + if (cmd[i] != quote_chr) { + wprintw(self->window, "Missing terminating %c character\n", quote_chr); + return; + } + } if (cmd[i] == ' ') { cmd[i] = '\0';