in nanogetstr(), fix a misplaced break and some indentation
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2458 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
fc0ebe982d
commit
c504dffa39
|
@ -75,6 +75,8 @@ CVS code -
|
||||||
regexec_safe()
|
regexec_safe()
|
||||||
- Rename to safe_regexec() for consistency. (DLR)
|
- Rename to safe_regexec() for consistency. (DLR)
|
||||||
- winio.c:
|
- winio.c:
|
||||||
|
nanogetstr()
|
||||||
|
- Fix misplaced break. (DLR)
|
||||||
statusq()
|
statusq()
|
||||||
- Make sure that the vsnprintf(foo) call and foo's subsequent
|
- Make sure that the vsnprintf(foo) call and foo's subsequent
|
||||||
null termination both take the proper number of bytes when
|
null termination both take the proper number of bytes when
|
||||||
|
|
81
src/winio.c
81
src/winio.c
|
@ -2506,10 +2506,11 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||||
switch (kbinput) {
|
switch (kbinput) {
|
||||||
case NANO_TAB_KEY:
|
case NANO_TAB_KEY:
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* tab history completion */
|
/* Tab history completion. */
|
||||||
if (history_list != NULL) {
|
if (history_list != NULL) {
|
||||||
if (!complete || last_kbinput != NANO_TAB_KEY) {
|
if (!complete || last_kbinput != NANO_TAB_KEY) {
|
||||||
history_list->current = (historytype *)history_list;
|
history_list->current =
|
||||||
|
(historytype *)history_list;
|
||||||
history_list->len = strlen(answer);
|
history_list->len = strlen(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2527,33 +2528,34 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
if (allow_tabs) {
|
if (allow_tabs) {
|
||||||
answer = input_tab(answer, &statusbar_x, &tabbed, list);
|
answer = input_tab(answer, &statusbar_x, &tabbed,
|
||||||
|
list);
|
||||||
answer_len = strlen(answer);
|
answer_len = strlen(answer);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
case NANO_PREVLINE_KEY:
|
case NANO_PREVLINE_KEY:
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (history_list != NULL) {
|
if (history_list != NULL) {
|
||||||
|
/* If currentbuf is NULL, or if use_cb is 1,
|
||||||
/* if currentbuf is NULL, or if use_cb is 1, currentbuf
|
* currentbuf isn't NULL, and currentbuf is
|
||||||
isn't NULL, and currentbuf is different from answer,
|
* different from answer, it means that we're
|
||||||
it means that we're scrolling up at the top of the
|
* scrolling up at the top of the search history,
|
||||||
search history, and we need to save the current
|
* and we need to save the current answer in
|
||||||
answer in currentbuf; do this and reset use_cb to
|
* currentbuf. Do this and reset use_cb to 0. */
|
||||||
0 */
|
|
||||||
if (currentbuf == NULL || (use_cb == 1 &&
|
if (currentbuf == NULL || (use_cb == 1 &&
|
||||||
strcmp(currentbuf, answer) != 0)) {
|
strcmp(currentbuf, answer) != 0)) {
|
||||||
currentbuf = mallocstrcpy(currentbuf, answer);
|
currentbuf = mallocstrcpy(currentbuf, answer);
|
||||||
use_cb = 0;
|
use_cb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if currentbuf isn't NULL, use_cb is 2, and currentbuf
|
/* If currentbuf isn't NULL, use_cb is 2, and
|
||||||
is different from answer, it means that we're
|
* currentbuf is different from answer, it means
|
||||||
scrolling up at the bottom of the search history, and
|
* that we're scrolling up at the bottom of the
|
||||||
we need to make the string in currentbuf the current
|
* search history, and we need to make the string in
|
||||||
answer; do this, blow away currentbuf since we don't
|
* currentbuf the current answer. Do this, blow
|
||||||
need it anymore, and reset use_cb to 0 */
|
* away currentbuf since we don't need it anymore,
|
||||||
|
* and reset use_cb to 0. */
|
||||||
if (currentbuf != NULL && use_cb == 2 &&
|
if (currentbuf != NULL && use_cb == 2 &&
|
||||||
strcmp(currentbuf, answer) != 0) {
|
strcmp(currentbuf, answer) != 0) {
|
||||||
answer = mallocstrcpy(answer, currentbuf);
|
answer = mallocstrcpy(answer, currentbuf);
|
||||||
|
@ -2562,9 +2564,9 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||||
answer_len = strlen(answer);
|
answer_len = strlen(answer);
|
||||||
use_cb = 0;
|
use_cb = 0;
|
||||||
|
|
||||||
/* else get older search from the history list and save
|
/* Otherwise, get the older search from the history
|
||||||
it in answer; if there is no older search, blank out
|
* list and save it in answer. If there is no older
|
||||||
answer */
|
* search, blank out answer. */
|
||||||
} else if ((history =
|
} else if ((history =
|
||||||
get_history_older(history_list)) != NULL) {
|
get_history_older(history_list)) != NULL) {
|
||||||
answer = mallocstrcpy(answer, history);
|
answer = mallocstrcpy(answer, history);
|
||||||
|
@ -2580,37 +2582,34 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||||
case NANO_NEXTLINE_KEY:
|
case NANO_NEXTLINE_KEY:
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (history_list != NULL) {
|
if (history_list != NULL) {
|
||||||
|
/* Get the newer search from the history list and
|
||||||
/* get newer search from the history list and save it
|
* save it in answer. */
|
||||||
in answer */
|
if ((history =
|
||||||
if ((history = get_history_newer(history_list)) != NULL) {
|
get_history_newer(history_list)) != NULL) {
|
||||||
answer = mallocstrcpy(answer, history);
|
answer = mallocstrcpy(answer, history);
|
||||||
answer_len = strlen(history);
|
answer_len = strlen(history);
|
||||||
|
/* If currentbuf isn't NULL and use_cb isn't 2, it
|
||||||
/* if there is no newer search, we're here */
|
* means that we're scrolling down at the bottom of
|
||||||
|
* the search history and we need to make the string
|
||||||
/* if currentbuf isn't NULL and use_cb isn't 2, it means
|
* in currentbuf the current answer; do this, blow
|
||||||
that we're scrolling down at the bottom of the search
|
* away currentbuf since we don't need it anymore,
|
||||||
history and we need to make the string in currentbuf
|
* and set use_cb to 1. */
|
||||||
the current answer; do this, blow away currentbuf
|
|
||||||
since we don't need it anymore, and set use_cb to
|
|
||||||
1 */
|
|
||||||
} else if (currentbuf != NULL && use_cb != 2) {
|
} else if (currentbuf != NULL && use_cb != 2) {
|
||||||
answer = mallocstrcpy(answer, currentbuf);
|
answer = mallocstrcpy(answer, currentbuf);
|
||||||
answer_len = strlen(answer);
|
answer_len = strlen(answer);
|
||||||
free(currentbuf);
|
free(currentbuf);
|
||||||
currentbuf = NULL;
|
currentbuf = NULL;
|
||||||
use_cb = 1;
|
use_cb = 1;
|
||||||
|
/* Itherwise, if currentbuf is NULL and use_cb isn't
|
||||||
/* otherwise, if currentbuf is NULL and use_cb isn't 2,
|
* 2, it means that we're scrolling down at the
|
||||||
it means that we're scrolling down at the bottom of
|
* bottom of the search history and the current
|
||||||
the search history and the current answer (if it's
|
* answer (if it's not blank) needs to be saved in
|
||||||
not blank) needs to be saved in currentbuf; do this,
|
* currentbuf. Do this, blank out answer (if
|
||||||
blank out answer (if necessary), and set use_cb to
|
* necessary), and set use_cb to 2. */
|
||||||
2 */
|
|
||||||
} else if (use_cb != 2) {
|
} else if (use_cb != 2) {
|
||||||
if (answer[0] != '\0') {
|
if (answer[0] != '\0') {
|
||||||
currentbuf = mallocstrcpy(currentbuf, answer);
|
currentbuf = mallocstrcpy(currentbuf,
|
||||||
|
answer);
|
||||||
answer = mallocstrcpy(answer, "");
|
answer = mallocstrcpy(answer, "");
|
||||||
}
|
}
|
||||||
answer_len = 0;
|
answer_len = 0;
|
||||||
|
|
Loading…
Reference in New Issue