mirror of
git://git.sv.gnu.org/nano.git
synced 2025-01-16 14:29:21 +03:00
tweaks: reshuffle two conditions, re-indent, and rewrap a line
If all is programmed well, then the functions 'get_older_item' and 'get_newer_item' will only occur when a history list is passed to acquire_an_answer(). But let's keep it certain we don't dereference a NULL pointer.
This commit is contained in:
parent
9a9714fe0c
commit
30abc02277
11
src/prompt.c
11
src/prompt.c
@ -501,8 +501,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
} else
|
||||
#endif /* ENABLE_TABCOMP */
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (func == get_older_item) {
|
||||
if (history_list != NULL) {
|
||||
if (func == get_older_item && history_list != NULL) {
|
||||
/* If this is the first step into history, start at the bottom. */
|
||||
if (stored_string == NULL)
|
||||
reset_history_pointer_for(*history_list);
|
||||
@ -517,9 +516,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
answer = mallocstrcpy(answer, (*history_list)->data);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
}
|
||||
} else if (func == get_newer_item) {
|
||||
if (history_list != NULL) {
|
||||
} else if (func == get_newer_item && history_list != NULL) {
|
||||
/* If there is a newer item, move to it and copy its string. */
|
||||
if ((*history_list)->next != NULL) {
|
||||
*history_list = (*history_list)->next;
|
||||
@ -528,12 +525,10 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
|
||||
}
|
||||
|
||||
/* When at the bottom of the history list, restore the old answer. */
|
||||
if ((*history_list)->next == NULL &&
|
||||
*answer == '\0' && stored_string != NULL) {
|
||||
if ((*history_list)->next == NULL && stored_string && *answer == '\0') {
|
||||
answer = mallocstrcpy(answer, stored_string);
|
||||
typing_x = strlen(answer);
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif /* ENABLE_HISTORIES */
|
||||
/* If we ran a function that should not exit from the prompt... */
|
||||
|
Loading…
Reference in New Issue
Block a user