From 6fcde577487867131c179f173622fc1d6d1dbd32 Mon Sep 17 00:00:00 2001 From: Imre Vadasz Date: Wed, 28 May 2014 22:07:11 +0200 Subject: [PATCH] top: Fix the interactive command 'U'. * 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 | 11 +++++++++++ contrib/top/top.c | 7 ------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/contrib/top/commands.c b/contrib/top/commands.c index 1374fac48c..4718dfd559 100644 --- a/contrib/top/commands.c +++ b/contrib/top/commands.c @@ -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; } diff --git a/contrib/top/top.c b/contrib/top/top.c index b7e6563467..4f1783a597 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -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 */ -- 2.41.0