do_browser()
- Rename variable lineno to fileline to avoid confusion. (DLR)
- nano.c:
+ help_init()
+ - When calculating allocsize, take multibyte characters into
+ account, and keep the column number limits consistent. (DLR)
print1opt()
- Don't include longflag if HAVE_GETOPT_LONG isn't defined.
Rename this function to print1opt_full(), leave out the
* help_text should be NULL initially. */
void help_init(void)
{
- size_t allocsize = 1; /* Space needed for help_text. */
+ size_t allocsize = 0; /* Space needed for help_text. */
const char *htx; /* Untranslated help message. */
char *ptr;
const shortcut *s;
/* The space needed for the shortcut lists, at most COLS characters,
* plus '\n'. */
- allocsize += (COLS < 21 ? 21 : COLS + 1) *
- length_of_list(currshortcut);
+ allocsize += (COLS < 24 ? (24 * mb_cur_max()) :
+ ((COLS + 1) * mb_cur_max())) * length_of_list(currshortcut);
#ifndef NANO_SMALL
/* If we're on the main list, we also count the toggle help text.
free(help_text);
/* Allocate space for the help text. */
- help_text = charalloc(allocsize);
+ help_text = charalloc(allocsize + 1);
/* Now add the text we want. */
strcpy(help_text, htx);