From 2774726c651da56091bcb14500c1903387f7b9d1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Mon, 12 Jul 2021 18:10:25 +0200 Subject: [PATCH] Blank line in history --- src/cli.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli.c b/src/cli.c index 892b174..45f63b3 100644 --- a/src/cli.c +++ b/src/cli.c @@ -86,7 +86,7 @@ void connectedCommunication(int sockfd) char sendBuff[SEND_BUFFER_SIZE] = {0}; char receiveBuff[RECEIVE_BUFFER_SIZE] = {0}; - char historyBuff[SEND_BUFFER_SIZE * NHISTORY] = {0}; + char historyBuff[SEND_BUFFER_SIZE * NHISTORY + 1] = {0}; int historyIndex = 0, historyModifier; char curChar; @@ -136,7 +136,7 @@ void connectedCommunication(int sockfd) if (historyIndex <= 0) break; historyModifier = (historyModifier + 1) - % (historyIndex); + % (historyIndex + 1); printf("\33[2K\r%s%s", promptString, &historyBuff[ @@ -155,8 +155,8 @@ void connectedCommunication(int sockfd) if (historyIndex <= 0) break; - historyModifier = (historyModifier + historyIndex - 1) - % (historyIndex); + historyModifier = (historyModifier + historyIndex) + % (historyIndex + 1); printf("\33[2K\r%s%s", promptString, &historyBuff[