diff --git a/src/history.c b/src/history.c index 0f80fbae..bfcb183c 100644 --- a/src/history.c +++ b/src/history.c @@ -145,30 +145,6 @@ void update_history(linestruct **item, const char *text) *item = *hbot; } -/* Move h to the string in the history list just before it, and return - * that string. If there isn't one, don't move h and return NULL. */ -char *get_history_older(linestruct **h) -{ - if ((*h)->prev == NULL) - return NULL; - - *h = (*h)->prev; - - return (*h)->data; -} - -/* Move h to the string in the history list just after it, and return - * that string. If there isn't one, don't move h and return NULL. */ -char *get_history_newer(linestruct **h) -{ - if ((*h)->next == NULL) - return NULL; - - *h = (*h)->next; - - return (*h)->data; -} - /* Two empty placeholder functions. */ void get_history_older_void(void) { diff --git a/src/prompt.c b/src/prompt.c index 04c606d6..ec50e18f 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -446,8 +446,6 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, bool finished; functionptrtype func; #ifdef ENABLE_HISTORIES - char *history = NULL; - /* The current history string. */ char *magichistory = NULL; /* The (partial) answer that was typed at the prompt, if any. */ #ifdef ENABLE_TABCOMP @@ -515,8 +513,9 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, /* Get the older search from the history list and save it in * answer. If there is no older search, don't do anything. */ - if ((history = get_history_older(history_list)) != NULL) { - answer = mallocstrcpy(answer, history); + if ((*history_list)->prev != NULL) { + *history_list = (*history_list)->prev; + answer = mallocstrcpy(answer, (*history_list)->data); typing_x = strlen(answer); } } @@ -524,8 +523,9 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, if (history_list != NULL) { /* Get the newer search from the history list and save it in * answer. If there is no newer search, don't do anything. */ - if ((history = get_history_newer(history_list)) != NULL) { - answer = mallocstrcpy(answer, history); + if ((*history_list)->next != NULL) { + *history_list = (*history_list)->next; + answer = mallocstrcpy(answer, (*history_list)->data); typing_x = strlen(answer); } diff --git a/src/prototypes.h b/src/prototypes.h index adf2e78c..1b749142 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -336,8 +336,6 @@ void do_help(void); void history_init(void); void history_reset(const linestruct *list); void update_history(linestruct **item, const char *text); -char *get_history_older(linestruct **h); -char *get_history_newer(linestruct **h); void get_history_older_void(void); void get_history_newer_void(void); #ifdef ENABLE_TABCOMP