From 10b99d8ac0f85e23c88ddb860bb5c76682178713 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 6 Jan 2021 20:01:55 +0100 Subject: [PATCH] chars: short-circuit determining the width of characters under U+0300 The combining characters (that are zero-width) start at U+0300. After that it's pretty much chaos, width-wise. The mbwidth() function is not called for control characters (whose representation takes up two columns), as they are handled separately. The calls of mbwidth() that *can* happen with a control character as argument are only to determine whether the character is zero-width, and then it doesn't matter whether the exact width is 1 or 2. --- src/chars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chars.c b/src/chars.c index 3c7e18f7..99554551 100644 --- a/src/chars.c +++ b/src/chars.c @@ -179,8 +179,8 @@ char control_mbrep(const char *c, bool isdata) /* Return the width in columns of the given (multibyte) character. */ int mbwidth(const char *c) { - /* Ask for the width only when the character isn't plain ASCII. */ - if ((unsigned char)*c > 0xC1) { + /* Only characters beyond U+02FF can be other than one column wide. */ + if ((unsigned char)*c > 0xCB) { wchar_t wc; int width;