From 40ea2a2ea085bef9732252dccc9f6861b0ce6bb8 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Wed, 16 Mar 2005 16:32:33 +0000
Subject: [PATCH] actually, we can swallow non-ASCII control characters if
 we're not in UTF-8 mode

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2379 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 src/chars.c |  2 +-
 src/nano.c  | 14 +++++++++-----
 src/winio.c | 14 +++++++++-----
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/chars.c b/src/chars.c
index 9e39bf9f..456d18be 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -79,7 +79,6 @@ bool is_alnum_wchar(wchar_t wc)
 {
     return iswalnum(wc);
 }
-#endif
 
 /* This function is equivalent to isascii(). */
 bool is_ascii_char(int c)
@@ -92,6 +91,7 @@ bool is_ascii_char(int c)
 #endif
 	;
 }
+#endif
 
 /* This function is equivalent to isblank(). */
 bool is_blank_char(int c)
diff --git a/src/nano.c b/src/nano.c
index 220c35b1..6cdf7bfe 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -3616,11 +3616,15 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
 
     if (allow_funcs) {
 	/* If we got a character, and it isn't a shortcut, toggle, or
-	 * ASCII control character, it's a normal text character.
-	 * Display the warning if we're in view mode, or add the
-	 * character to the input buffer if we're not. */
-	if (input != ERR && *s_or_t == FALSE &&
-		(!is_ascii_char(input) || !is_cntrl_char(input))) {
+	 * control character, it's a normal text character.  Display the
+	 * warning if we're in view mode, or add the character to the
+	 * input buffer if we're not. */
+	if (input != ERR && *s_or_t == FALSE && (
+#ifdef NANO_WIDE
+		/* Keep non-ASCII control characters in UTF-8 mode. */
+		(!ISSET(NO_UTF8) && !is_ascii_char(input)) ||
+#endif
+		!is_cntrl_char(input))) {
 	    if (ISSET(VIEW_MODE))
 		print_view_warning();
 	    else {
diff --git a/src/winio.c b/src/winio.c
index 78ba2f7a..eb656a74 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1677,11 +1677,15 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
 
     if (allow_funcs) {
 	/* If we got a character, and it isn't a shortcut, toggle, or
-	 * ASCII control character, it's a normal text character.
-	 * Display the warning if we're in view mode, or add the
-	 * character to the input buffer if we're not. */
-	if (input != ERR && *s_or_t == FALSE &&
-		(!is_ascii_char(input) || !is_cntrl_char(input))) {
+	 * control character, it's a normal text character.  Display the
+	 * warning if we're in view mode, or add the character to the
+	 * input buffer if we're not. */
+	if (input != ERR && *s_or_t == FALSE && (
+#ifdef NANO_WIDE
+		/* Keep non-ASCII control characters in UTF-8 mode. */
+		(!ISSET(NO_UTF8) && !is_ascii_char(input)) ||
+#endif
+		!is_cntrl_char(input))) {
 	    /* If we're using restricted mode, the filename isn't blank,
 	     * and we're at the "Write File" prompt, disable text
 	     * input. */
-- 
GitLab