]> granicus.if.org Git - procps-ng/commitdiff
top: provide for zero length character in utf8 support
authorJim Warner <james.warner@comcast.net>
Fri, 19 Jun 2020 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Tue, 23 Jun 2020 09:05:03 +0000 (19:05 +1000)
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>
top/top.c

index 9ac3a454ead5482a0272011cb93e67b428e3035d..cc6f4f0c618f54c0804ceb29a2d33e2a6504c5d7 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -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