]> granicus.if.org Git - procps-ng/commitdiff
top: show that truncation indicator ('+') consistently
authorJim Warner <james.warner@comcast.net>
Wed, 28 Feb 2018 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Sat, 3 Mar 2018 06:53:10 +0000 (17:53 +1100)
With a little luck, this should be the final tweak for
our support of extra wide characters. Currently, those
characters don't always display the '+' indicator when
they've been truncated. Now, it should always be seen.

[ plus it's done a tad more efficiently via snprintf ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 617c67abc746d5d058df0f9408a2063e6d59ccc3..bb2789c93372ab2732457481dd71680f2034273d 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -1471,9 +1471,8 @@ static inline const char *make_str_utf8 (const char *str, int width, int justr,
    int delta = utf8_delta(str);
 
    if (width + delta < snprintf(buf, sizeof(buf), "%s", str)) {
-      snprintf(buf, sizeof(buf), "%.*s", utf8_embody(str, width - 1), str);
+      snprintf(buf, sizeof(buf), "%.*s%c", utf8_embody(str, width-1), str, COLPLUSCH);
       delta = utf8_delta(buf);
-      buf[width + delta - 1] = COLPLUSCH;
       AUTOX_COL(col);
    }
    return justify_pad(buf, width + delta, justr);