top: provide for zero length character in utf8 support

This commit is prompted by the preceding change to the
library's escape.c module which, in turn, was prompted
by that issue shown below (with thanks to Konstantin).

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/176

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner authored and Craig Small committed 2020-06-23 19:05:03 +10:00
1 parent bb1a79f2c8
commit c509d9bcbb
1 file changed
+2 -1
+2 -1
View File
@@ -710,7 +710,8 @@ static inline int utf8_cols (const unsigned char *p, int n) {
if (n > 1) {
(void)mbtowc(&wc, (const char *)p, n);
if ((n = wcwidth(wc)) < 1) n = 1;
// allow a zero as valid, as with a 'combining acute accent'
if ((n = wcwidth(wc)) < 0) n = 1;
}
return n;
#else