top: Fix the interactive command 'U'.
authorImre Vadasz <imre@vdsz.com>
Wed, 28 May 2014 20:07:11 +0000 (22:07 +0200)
committerImre Vadasz <imre@vdsz.com>
Wed, 28 May 2014 21:20:04 +0000 (23:20 +0200)
* The gstate->header_text and gstate->get_userid variables need to be
  updated when toggling between displaying of UIDs and usernames.

* Removing the unnecessary HAVE_FORMAT_PROCESS_HEADER checks.

contrib/top/commands.c
contrib/top/top.c

index 1374fac..4718dfd 100644 (file)
@@ -864,6 +864,17 @@ cmd_useruid(globalstate *gstate)
 
 {
     gstate->pselect.usernames = !gstate->pselect.usernames;
+    /* set constants for username/uid display */
+    if (gstate->pselect.usernames)
+    {
+        gstate->header_text = format_header("USERNAME");
+        gstate->get_userid = username;
+    }
+    else
+    {
+        gstate->header_text = format_header("   UID  ");
+        gstate->get_userid = itoa7;
+    }
     display_header(2);
     return CMD_REFRESH;
 }
index b7e6563..4f1783a 100644 (file)
@@ -523,12 +523,7 @@ do_display(globalstate *gstate)
        active_procs = 0;
     }
 
-#ifdef HAVE_FORMAT_PROCESS_HEADER
-    /* get the process header to use */
-    hdr = format_process_header(&(gstate->pselect), processes, active_procs);
-#else
     hdr = gstate->header_text;
-#endif
 
     /* full screen or update? */
     if (gstate->fulldraw)
@@ -863,7 +858,6 @@ main(int argc, char *argv[])
        need_mini = 0;
     }
 
-#ifndef HAVE_FORMAT_PROCESS_HEADER
     /* set constants for username/uid display */
     if (gstate->show_usernames)
     {
@@ -875,7 +869,6 @@ main(int argc, char *argv[])
        gstate->header_text = format_header("   UID  ");
        gstate->get_userid = itoa7;
     }
-#endif
     gstate->pselect.usernames = gstate->show_usernames;
 
     /* initialize display */