[tin 1.7.x] online help fix

Urs Janßen <[email protected]>
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
below is a fix for
| o  the decription in the online 'h'elp for is dublicated (in
|    all levels) if the "same" key is mapped to the same function twice
|    (e.g: GroupReadBasenote      ^J      ^M)
|    | Group/thread/article operations
|    | -------------------------------
|    | <CR>      read chosen group
|    | <CR>      read chosen group

--- help.c.o	2005-04-19 16:00:08.000000000 +0200
+++ help.c	2005-04-19 16:03:06.000000000 +0200
@@ -443,19 +443,21 @@
 	const t_help_page *helppage,
 	const struct keylist keys)
 {
-	char *buf;
+	char *buf = my_malloc(LEN);
+	char *last = my_malloc(LEN);
 	char key[MAXKEYLEN];
 	/*
 	 * length is only needed to pass it to expand_ctrl_chars()
 	 * we have no need for the value
 	 */
 	int length;
-
-	buf = my_malloc(LEN);
+	size_t i;
 
 	if (!helppage)
 		return;
 
+	last[0] = '\0';
+
 	while (helppage->helptext) {
 		if (helppage->func == NOT_ASSIGNED) {
 			/*
@@ -464,23 +466,24 @@
 			 */
 			buf = my_realloc(buf, LEN);
 
-			if (!strlen(helppage->helptext))	/* avoid empty string translations */
-				snprintf(buf, LEN, "%s", helppage->helptext);
+			if (!strlen(helppage->helptext))	/* avoid translation of empty strings */
+				snprintf(buf, LEN, "\n");
 			else
 				snprintf(buf, LEN, "%s", _(helppage->helptext));
 			buf[LEN - 1] = '\0';
 			expand_ctrl_chars(&buf, &length, 8);
 			fprintf(fp, "%s", buf);
 		} else {
-			size_t i;
-
 			for (i = 0; i < keys.used; i++) {
 				if (keys.list[i].function == helppage->func) {
 					buf = my_realloc(buf, LEN);
 					snprintf(buf, LEN, "%s\t  %s", printascii(key, keys.list[i].key), _(helppage->helptext));
 					buf[LEN - 1] = '\0';
 					expand_ctrl_chars(&buf, &length, 8);
-					fprintf(fp, "%s", buf);
+					if (strcmp(last, buf)) {
+						fprintf(fp, "%s", buf);
+						strncpy(last, buf, LEN);
+					}
 				}
 			}
 		}
@@ -488,6 +491,7 @@
 	}
 
 	free(buf);
+	free(last);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.