From b7f8d4819b75bed0ae54608549384ee50d75ae9c Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 22 Mar 2018 19:54:20 +0100
Subject: [PATCH] tweaks: frob some comments plus miscellaneous other stuff

---
 src/files.c  |  4 ++--
 src/global.c | 12 +++++++-----
 src/nano.c   |  5 ++---
 src/prompt.c | 16 +++++++---------
 4 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/src/files.c b/src/files.c
index 39678d6e..10e2f624 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2420,8 +2420,8 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
 
 /* We consider the first buf_len characters of buf for filename tab
  * completion. */
-char **cwd_tab_completion(const char *buf, bool allow_files, size_t
-		*num_matches, size_t buf_len)
+char **cwd_tab_completion(const char *buf, bool allow_files,
+		size_t *num_matches, size_t buf_len)
 {
 	char *dirname = mallocstrcpy(NULL, buf);
 	char *slash, *filename;
diff --git a/src/global.c b/src/global.c
index e80a94e4..1bf5c261 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1013,8 +1013,7 @@ void shortcut_init(void)
 			N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
 	}
 
-	/* If we're using restricted mode, file insertion is disabled, and
-	 * thus command execution and the multibuffer toggle have no place. */
+	/* Command execution is only available when not in restricted mode. */
 	if (!ISSET(RESTRICTED)) {
 		add_to_funcs(flip_execute, MINSERTFILE,
 			N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
@@ -1024,12 +1023,14 @@ void shortcut_init(void)
 	}
 #endif /* !NANO_TINY */
 #ifdef ENABLE_MULTIBUFFER
+	/* Multiple buffers are only available when not in restricted mode. */
 	if (!ISSET(RESTRICTED))
 		add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
 			N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
 #endif
 
 #ifdef ENABLE_BROWSER
+	/* The file browser is only available when not in restricted mode. */
 	if (!ISSET(RESTRICTED))
 		add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
 			N_("To Files"), WITHORSANS(tofiles_gist), TOGETHER, VIEW);
@@ -1311,8 +1312,8 @@ void shortcut_init(void)
 #ifndef NANO_TINY
 	add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
 	add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
-	/* In restricted mode, don't allow Appending, Prepending, nor making
-	 * backups, nor executing a command, nor opening a new buffer. */
+	/* Only when not in restricted mode, allow Appending, Prepending,
+	 * making backups, and executing a command. */
 	if (!ISSET(RESTRICTED)) {
 		add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
 		add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
@@ -1321,11 +1322,12 @@ void shortcut_init(void)
 	}
 #endif
 #ifdef ENABLE_MULTIBUFFER
+	/* Only when not in restricted mode, allow multiple buffers. */
 	if (!ISSET(RESTRICTED))
 		add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
 #endif
 #ifdef ENABLE_BROWSER
-	/* In restricted mode, don't allow entering the file browser. */
+	/* Only when not in restricted mode, allow entering the file browser. */
 	if (!ISSET(RESTRICTED))
 		add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
 #endif
diff --git a/src/nano.c b/src/nano.c
index e7157e6f..7f593a3d 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -69,8 +69,7 @@ static struct sigaction act;
 static bool input_was_aborted = FALSE;
 		/* Whether reading from standard input was aborted via ^C. */
 
-/* Create a new linestruct node.  Note that we do not set prevnode->next
- * to the new line. */
+/* Create a new linestruct node.  Note that we do not set prevnode->next. */
 filestruct *make_new_node(filestruct *prevnode)
 {
 	filestruct *newnode = nmalloc(sizeof(filestruct));
@@ -1647,7 +1646,7 @@ bool okay_for_view(const sc *shortcut)
 {
 	const subnfunc *func = sctofunc(shortcut);
 
-	return (func && func->viewok);
+	return (func != NULL && func->viewok);
 }
 
 /* Read in a keystroke.  Act on the keystroke if it is a shortcut or a toggle;
diff --git a/src/prompt.c b/src/prompt.c
index acadecb8..ff0d638b 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -187,27 +187,25 @@ void do_statusbar_output(int *the_input, size_t input_len,
 {
 	char *output = charalloc(input_len + 1);
 	char onechar[MAXCHARLEN];
-	size_t char_len, i;
+	size_t char_len, i, j = 0;
 
 	/* Copy the typed stuff so it can be treated. */
 	for (i = 0; i < input_len; i++)
 		output[i] = (char)the_input[i];
 	output[i] = '\0';
 
-	i = 0;
-
-	while (i < input_len) {
+	while (j < input_len) {
 		/* Encode any NUL byte as 0x0A. */
-		if (output[i] == '\0')
-			output[i] = '\n';
+		if (output[j] == '\0')
+			output[j] = '\n';
 
 		/* Interpret the next multibyte character. */
-		char_len = parse_mbchar(output + i, onechar, NULL);
+		char_len = parse_mbchar(output + j, onechar, NULL);
 
-		i += char_len;
+		j += char_len;
 
 		/* When filtering, skip any ASCII control character. */
-		if (filtering && is_ascii_cntrl_char(*(output + i - char_len)))
+		if (filtering && is_ascii_cntrl_char(*(output + j - char_len)))
 			continue;
 
 		/* Insert the typed character into the existing answer string. */
-- 
GitLab