Commit c4daf5d4 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

in help_init(), when calculating allocsize, take multibyte characters

into account, and keep the column number limits consistent


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2416 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 7 additions and 4 deletions
+7 -4
...@@ -7,6 +7,9 @@ CVS code - ...@@ -7,6 +7,9 @@ CVS code -
do_browser() do_browser()
- Rename variable lineno to fileline to avoid confusion. (DLR) - Rename variable lineno to fileline to avoid confusion. (DLR)
- nano.c: - nano.c:
help_init()
- When calculating allocsize, take multibyte characters into
account, and keep the column number limits consistent. (DLR)
print1opt() print1opt()
- Don't include longflag if HAVE_GETOPT_LONG isn't defined. - Don't include longflag if HAVE_GETOPT_LONG isn't defined.
Rename this function to print1opt_full(), leave out the Rename this function to print1opt_full(), leave out the
......
...@@ -264,7 +264,7 @@ void mouse_init(void) ...@@ -264,7 +264,7 @@ void mouse_init(void)
* help_text should be NULL initially. */ * help_text should be NULL initially. */
void help_init(void) 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. */ const char *htx; /* Untranslated help message. */
char *ptr; char *ptr;
const shortcut *s; const shortcut *s;
...@@ -391,8 +391,8 @@ void help_init(void) ...@@ -391,8 +391,8 @@ void help_init(void)
/* The space needed for the shortcut lists, at most COLS characters, /* The space needed for the shortcut lists, at most COLS characters,
* plus '\n'. */ * plus '\n'. */
allocsize += (COLS < 21 ? 21 : COLS + 1) * allocsize += (COLS < 24 ? (24 * mb_cur_max()) :
length_of_list(currshortcut); ((COLS + 1) * mb_cur_max())) * length_of_list(currshortcut);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* If we're on the main list, we also count the toggle help text. /* If we're on the main list, we also count the toggle help text.
...@@ -411,7 +411,7 @@ void help_init(void) ...@@ -411,7 +411,7 @@ void help_init(void)
free(help_text); free(help_text);
/* Allocate space for the help text. */ /* Allocate space for the help text. */
help_text = charalloc(allocsize); help_text = charalloc(allocsize + 1);
/* Now add the text we want. */ /* Now add the text we want. */
strcpy(help_text, htx); strcpy(help_text, htx);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment