]> granicus.if.org Git - procps-ng/commitdiff
top: added utf8 multibyte support to additional fields
authorJim Warner <james.warner@comcast.net>
Thu, 24 Dec 2020 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@dropbear.xyz>
Mon, 28 Dec 2020 21:42:28 +0000 (08:42 +1100)
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>
top/top.c

index 8a61d6aeda759f19087cfb87dd62eaeb9f99c2d6..b07ea2845e043173f3518bd3b93a02c4b2697c82 100644 (file)
--- 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);