From c76144ead1cb2e10267751f0434f617e03084a91 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Thu, 24 Dec 2020 00:00:00 -0600 Subject: [PATCH] top: added utf8 multibyte support to additional fields When any process' command line contains multibyte utf8 characters, two separate display problems could arise. 1. If that COMMAND column is not displayed as the very last field, then field(s) to the right are misaligned. 2. Even when last, should utf8 string length (not that display length) exceed allowable screen width, it will nonetheless suffer from improper premature truncation. Number 1 is less of a concern since the cmdline column is likely to always be the last field to be displayed, if only to enable right and left scrolling provisions. Number 2 is much more likely to occur, especially with additional fields which might be shown before COMMAND. Or, forest view child tasks can yield the same effect. So, this commit will permit the correct utf8 multibyte display regardless of field position or string length. And, we'll bring top into line with the ps program for additional fields potentially subject to utf8 display. Signed-off-by: Jim Warner --- top/top.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/top/top.c b/top/top.c index 8a61d6ae..b07ea284 100644 --- a/top/top.c +++ b/top/top.c @@ -6185,13 +6185,13 @@ static const char *task_show (const WIN_t *q, const int idx) { break; #endif case EU_CGN: - makeVAR(p->cgname); + varUTF8(p->cgname); break; case EU_CGR: - makeVAR(p->cgroup[0]); + varUTF8(p->cgroup[0]); break; case EU_CMD: - makeVAR(forest_display(q, p)); + varUTF8(forest_display(q, p)); break; case EU_COD: cp = scale_mem(S, pages2K(p->trs), W, Jn); @@ -6225,7 +6225,7 @@ static const char *task_show (const WIN_t *q, const int idx) { cp = scale_num(p->dt, W, Jn); break; case EU_ENV: - makeVAR(p->environ[0]); + varUTF8(p->environ[0]); break; case EU_FL1: cp = scale_num(p->maj_flt, W, Jn);