#include <config.h>
#endif
+#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "proto.h"
* questions. */
static size_t statusbar_x = (size_t)-1;
/* The cursor position in answer. */
-static bool resetstatuspos = FALSE;
+static bool reset_statusbar_x = FALSE;
/* Should we reset the cursor position
* at the statusbar prompt? */
/* We can click in the statusbar window text to move the
* cursor. */
if (wenclose(bottomwin, mouse_y, mouse_x)) {
- size_t start_col = strlenpt(prompt) + 1;
+ size_t start_col;
+
+ assert(prompt != NULL);
+
+ start_col = strlenpt(prompt) + 1;
/* Subtract out the sizes of topwin and edit. */
mouse_y -= (2 - no_more_space()) + editwinrows;
size_t start_col, xpt, page_start;
char *expanded;
- assert(x <= strlen(buf));
+ assert(prompt != NULL && x <= strlen(buf);
start_col = strlenpt(prompt) + 1;
xpt = strnlenpt(buf, x);
wattroff(bottomwin, A_REVERSE);
}
-/* Get the input from the keyboard; this should only be called from
+/* Get the input from the keyboard. This should only be called from
* statusq(). */
int nanogetstr(bool allow_tabs, const char *curranswer,
#ifndef NANO_SMALL
/* Only put statusbar_x at the end of the string if it's
* uninitialized, if it would be past the end of curranswer, or if
- * resetstatuspos is TRUE. Otherwise, leave it alone. This is so
- * the cursor position stays at the same place if a prompt-changing
- * toggle is pressed. */
+ * reset_statusbar_x is TRUE. Otherwise, leave it alone. This is
+ * so the cursor position stays at the same place if a
+ * prompt-changing toggle is pressed. */
if (statusbar_x == (size_t)-1 || statusbar_x > curranswer_len ||
- resetstatuspos)
+ reset_statusbar_x)
statusbar_x = curranswer_len;
currshortcut = s;
bool list = FALSE;
#endif
- prompt = charealloc(prompt, ((COLS - 4) * mb_cur_max()) + 1);
+ assert(prompt == NULL);
+
+ prompt = charalloc(prompt, ((COLS - 4) * mb_cur_max()) + 1);
bottombars(s);
#endif
);
- resetstatuspos = FALSE;
+ free(prompt);
+ prompt = NULL;
+
+ reset_statusbar_x = FALSE;
switch (retval) {
case NANO_CANCEL_KEY:
retval = -1;
- resetstatuspos = TRUE;
+ reset_statusbar_x = TRUE;
break;
case NANO_ENTER_KEY:
retval = (answer[0] == '\0') ? -2 : 0;
- resetstatuspos = TRUE;
+ reset_statusbar_x = TRUE;
break;
}
void statusq_abort(void)
{
- resetstatuspos = TRUE;
+ reset_statusbar_x = TRUE;
}