From 220ba692e6341e942ca273b6c9114a96cfc17ff9 Mon Sep 17 00:00:00 2001
From: Chris Allegretta <chrisa@asty.org>
Date: Mon, 18 Dec 2000 03:40:00 +0000
Subject: [PATCH]  help_init():  - Fix off by one error that was making ^G help
 in normal mode and ^_ in pico mode not be displayed in the help.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@412 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog | 3 +++
 nano.c    | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 79c51c55..79ceeab0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,9 @@ General
 	  modify_control_key.  Removed #ifdef _POSIX_VDISABLE check
 	  around Control-S,Q,Z handlers because we need it now for
 	  the Alt-Alt-x code.
+  help_init()
+	- Fix off by one error that was making ^G help in normal mode and
+	  ^_ in pico mode not be displayed in the help.
 - nano.1, nano.1.html:
 	- Updated man page for -b, -e, -f and expanded explanation for -p.
 - utils.c:
diff --git a/nano.c b/nano.c
index 890293bc..8033fb65 100644
--- a/nano.c
+++ b/nano.c
@@ -1912,11 +1912,11 @@ void help_init(void)
 {
     int i, sofar = 0;
     long allocsize = 1;		/* How much space we're gonna need for the help text */
-    char buf[BUFSIZ];
+    char buf[BUFSIZ] = "";
 
     /* Compute the space needed for the shortcut lists - we add 15 to
        have room for the shortcut abbrev and its possible alternate keys */
-    for (i = 0; i < MAIN_LIST_LEN; i++)
+    for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
 	if (main_list[i].help != NULL)
 	    allocsize += strlen(main_list[i].help) + 15;
 
@@ -1937,7 +1937,7 @@ void help_init(void)
     strcpy(help_text, help_text_init);
 
     /* Now add our shortcut info */
-    for (i = 0; i < MAIN_LIST_LEN - 1; i++) {
+    for (i = 0; i <= MAIN_LIST_LEN - 1; i++) {
 	sofar = snprintf(buf, BUFSIZ, "^%c	", main_list[i].val + 64);
 
 	if (main_list[i].misc1 > KEY_F0 && main_list[i].misc1 <= KEY_F(64))
-- 
GitLab