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.
This commit is contained in:
Benno Schulenberg 2021-01-06 20:01:55 +01:00
parent 0693d6974a
commit 10b99d8ac0
1 changed files with 2 additions and 2 deletions

View File

@ -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;