From 79a731991faf1e0a8ecc5a20c7e624fdeb0c419d Mon Sep 17 00:00:00 2001 From: Nominate Date: Tue, 6 Aug 2013 11:20:11 +0100 Subject: [PATCH] Update prompt.c --- prompt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prompt.c b/prompt.c index 742b35f..3006b8a 100644 --- a/prompt.c +++ b/prompt.c @@ -44,12 +44,12 @@ static int prompt_buf_pos=0; static void execute(ToxWindow* self, char* u_cmd) { int i; int newlines = 0; - char cmd[256] = {0}; + char cmd[256] = {0}; for(i = 0; i < strlen(prompt_buf); i++) { if (u_cmd[i] == '\n') - ++newlines; - else + ++newlines; + else cmd[i - newlines] = u_cmd[i]; } @@ -276,7 +276,7 @@ static void execute(ToxWindow* self, char* u_cmd) { static void prompt_onKey(ToxWindow* self, int key) { // PRINTABLE characters: Add to line. if(isprint(key)) { - if (prompt_buf_pos == 255){ + if (prompt_buf_pos == (sizeof(prompt_buf) - 1)){ wprintw(self->window, "\nToo Long.\n"); prompt_buf_pos = 0; prompt_buf[0] = 0;