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 <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-12-24 00:00:00 -06:00 committed by Craig Small
parent be22291257
commit c76144ead1

View File

@ -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);