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