From 9c212a7e77eaf031399ab9e0f26d4940264615c9 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 23 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/top/top.c b/top/top.c index 8deeefaa..7da896b0 100644 --- a/top/top.c +++ b/top/top.c @@ -5919,21 +5919,21 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) { case EU_USN: // PIDS_ID_SUSER cp = make_str_utf8(rSv(i, str), W, Js, i); break; - /* str, make_str with varialbe width */ + /* str, make_str_utf8 with varialbe width */ case EU_CGN: // PIDS_CGNAME case EU_CGR: // PIDS_CGROUP case EU_ENV: // PIDS_ENVIRON case EU_EXE: // PIDS_EXE - case EU_SGD: // PIDS_SUPGIDS - makeVAR(rSv(i, str)); - break; - /* str, make_str_utf8 with varialbe width */ case EU_SGN: // PIDS_SUPGROUPS - varUTF8(rSv(EU_SGN, str)); + varUTF8(rSv(i, str)); + break; + /* str, make_str with varialbe width */ + case EU_SGD: // PIDS_SUPGIDS + makeVAR(rSv(EU_SGD, str)); break; /* str, make_str with varialbe width + additional decoration */ case EU_CMD: // PIDS_CMD or PIDS_CMDLINE - makeVAR(forest_colour(q, p)); + varUTF8(forest_colour(q, p)); break; default: // keep gcc happy continue;