nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 10b99d8ac0f85e23c88ddb860bb5c76682178713
parent 0693d6974a86ce8b3eeb4d475bc7556de6a41a71
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  6 Jan 2021 20:01:55 +0100

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.

Diffstat:
Msrc/chars.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 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;