Merge branch 'Dennis_CCS'

This commit is contained in:
Dennis Boekholtz 2024-04-14 21:10:48 +02:00
commit 92eb70f4b5
2 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,7 @@
#include <limits.h> #include <limits.h>
// #include <config.h> // #include <config.h>
#define HISTORY 1
#include "../FIFOBuff/FIFOBuffChar.h" #include "../FIFOBuff/FIFOBuffChar.h"
#ifdef HISTORY #ifdef HISTORY
@ -95,9 +96,10 @@ void CLI_PrintHistory()
{ {
char** historyList; char** historyList;
int ret = History_getFullHistory(History, &historyList); int ret = History_getFullHistory(History, &historyList);
int i;
if (ret >= 0) if (ret >= 0)
{ {
for (int i=0; *(historyList + i) != NULL; i++) for (i=0; *(historyList + i) != NULL; i++)
{ {
printf("%03i: %s\n", i, *(historyList + i)); printf("%03i: %s\n", i, *(historyList + i));
} }
@ -262,6 +264,7 @@ bool CLI_charIn(char c)
FIFOBuffChar_delete(fifo); FIFOBuffChar_delete(fifo);
break; break;
case 8:
case 127: // backspace case 127: // backspace
if (FIFOBuffChar_pop(FIFO)) if (FIFOBuffChar_pop(FIFO))
{ // pop something of the buffer { // pop something of the buffer

View File

@ -4,6 +4,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
int i = 0;
History_t* History_init() History_t* History_init()
{ {
History_t* history = malloc(sizeof(History_t)); History_t* history = malloc(sizeof(History_t));
@ -149,7 +151,7 @@ int History_getFullHistory(History_t* history, char*** list)
*list = malloc(sizeof(char**) * (History_getSize(history) + 1)); *list = malloc(sizeof(char**) * (History_getSize(history) + 1));
History_element_t* el = history->FirstEl_p; History_element_t* el = history->FirstEl_p;
for (int i = 0; (i < History_getSize(history)-1) && (retCode >= 0); i++) for (i = 0; (i < History_getSize(history)-1) && (retCode >= 0); i++)
{ {
*((*list) + i) = el->line; *((*list) + i) = el->line;
if (el->nextEl_p == NULL) if (el->nextEl_p == NULL)
@ -178,7 +180,7 @@ int History_getCurrPos(History_t* history)
if (history->CurrEl_p != NULL) if (history->CurrEl_p != NULL)
{ {
History_element_t* el = history->FirstEl_p; History_element_t* el = history->FirstEl_p;
for (int i = 0; (el != history->CurrEl_p) && (retCode >= 0); i++) for (i = 0; (el != history->CurrEl_p) && (retCode >= 0); i++)
{ {
if (el->nextEl_p == NULL) if (el->nextEl_p == NULL)
{ {