]> granicus.if.org Git - procps-ng/commitdiff
top: do not co-mingle strings/numbers under namespaces
authorJim Warner <james.warner@comcast.net>
Thu, 22 Oct 2015 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Wed, 28 Oct 2015 10:01:23 +0000 (21:01 +1100)
Craig's recent commit under that newlib branch dealing
with namespace support has prompted me to review top's
handling of those fields. Currently, when such a field
is zero, top displays a dash ('-'). This will mean the
justification toggles ('j/J') will behave incorrectly.

This patch simply allows the potential zero to display
or be suppressed with the already existing '0' toggle.

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

index c01b9834a5c0252bfe2cbbe36dcbecf89870a641..7f18ff18bd3b5fb760892214b9709d301b91a348 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -5390,8 +5390,8 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
          case EU_NS5:  // USERNS
          case EU_NS6:  // UTSNS
          {  long ino = p->ns[i - EU_NS1];
-            if (ino > 0) cp = make_num(ino, W, Jn, i);
-            else cp = make_str("-", W, Js, i);
+            if (Rc.zero_suppress && 0 >= ino) cp = make_str("", W, Js, i);
+            else cp = make_num(ino, W, Jn, i);
          }
             break;
 #ifdef OOMEM_ENABLE