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

in help_init(), make sure we have enough memory in all cases when

displaying the shortcut and toggle lists; and wrap the shortcut list
help text, for consistency with the toggle help text


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3668 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 18 additions and 16 deletions
+18 -16
...@@ -262,6 +262,10 @@ CVS code - ...@@ -262,6 +262,10 @@ CVS code -
- If one of the help strings ends in newlines followed by a - If one of the help strings ends in newlines followed by a
space, move the space to the next help string to make it space, move the space to the next help string to make it
easier for translators to see. (Benno Schulenberg) easier for translators to see. (Benno Schulenberg)
- Make sure we have enough memory in all cases when displaying
the shortcut and toggle lists. (DLR)
- Wrap the shortcut list help text, for consistency with the
toggle help text. (DLR, suggested by Benno Schulenberg)
parse_help_input() parse_help_input()
- Add Space and - as aliases for PageDown and PageUp, for - Add Space and - as aliases for PageDown and PageUp, for
consistency with the file browser. (DLR, suggested by Benno consistency with the file browser. (DLR, suggested by Benno
......
...@@ -383,22 +383,26 @@ void help_init(void) ...@@ -383,22 +383,26 @@ void help_init(void)
if (htx[2] != NULL) if (htx[2] != NULL)
allocsize += strlen(htx[2]); allocsize += strlen(htx[2]);
/* The space needed for the shortcut lists, at most COLS characters, /* Count the shortcut help text. Each entry has up to three keys,
* plus one or two '\n's. */ * which fill 24 columns, plus translated text, plus one or two
allocsize += (COLS < 24 ? (24 * mb_cur_max()) : * \n's. Note that the translated text is left out if there are 24
((COLS + 2) * mb_cur_max())) * length_of_list(currshortcut); * or fewer columns. */
for (s = currshortcut; s != NULL; s = s->next) {
allocsize += (24 * mb_cur_max()) + 1;
if (COLS >= 24)
allocsize += strlen(s->help) + 1;
}
#ifndef NANO_TINY #ifndef NANO_TINY
/* 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.
* Each entry has "M-%c\t\t\t", which fills 24 columns, plus a * Each entry has "M-%c\t\t\t", which fills 24 columns, plus a
* space, plus translated text, plus one or two '\n's. */ * space, plus translated text, plus one or two '\n's. */
if (currshortcut == main_list) { if (currshortcut == main_list) {
size_t endis_len = strlen(_("enable/disable")); size_t endis_len = strlen(_("enable/disable")) + 1;
for (t = toggles; t != NULL; t = t->next) for (t = toggles; t != NULL; t = t->next)
if (t->val != TOGGLE_NO_KEY) allocsize += (24 * mb_cur_max()) + strlen(t->desc) +
allocsize += strlen(t->desc) + endis_len + 8; endis_len + 2;
allocsize++;
} }
#endif #endif
...@@ -526,14 +530,8 @@ void help_init(void) ...@@ -526,14 +530,8 @@ void help_init(void)
} }
} }
if (COLS > 24) { if (COLS > 24)
char *help_ptr = display_string(s->help, 0, COLS - 24, ptr += sprintf(ptr, "%s", s->help);
FALSE);
ptr += sprintf(ptr, help_ptr);
free(help_ptr);
}
ptr += sprintf(ptr, "\n"); ptr += sprintf(ptr, "\n");
......
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