commit 8686cb3d3d275462d345200adc47010935c7b31a
parent 91fff2a2c8756f842cfafa3138ea0af45522e0af
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sun, 5 Jun 2016 21:42:27 +0200
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.
Diffstat:
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git 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