From 8686cb3d3d275462d345200adc47010935c7b31a Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 5 Jun 2016 21:42:27 +0200
Subject: [PATCH] chars: measure invalid sequences and unassigned codepoints
 more quickly

Invalid multibyte sequences get depicted with the Replacement Character,
and unassigned codepoints are shown as if they were a space.  Both have
a width of one.
---
 src/chars.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/chars.c b/src/chars.c
index 61fa6e69..7f3cf608 100644
--- a/src/chars.c
+++ b/src/chars.c
@@ -280,15 +280,13 @@ int mbwidth(const char *c)
 
 	if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
 	    mbtowc_reset();
-	    wc = bad_wchar;
+	    return 1;
 	}
 
 	width = wcwidth(wc);
 
-	if (width == -1) {
-	    wc = bad_wchar;
-	    width = wcwidth(wc);
-	}
+	if (width == -1)
+	    return 1;
 
 	return width;
     } else
-- 
GitLab