From owner-freebsd-current@FreeBSD.ORG Wed Nov 17 07:27:00 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 842301065674 for ; Wed, 17 Nov 2010 07:27:00 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3A9F18FC1B for ; Wed, 17 Nov 2010 07:26:59 +0000 (UTC) Received: by gwj20 with SMTP id 20so971132gwj.13 for ; Tue, 16 Nov 2010 23:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:message-id:user-agent:mime-version:content-type; bh=YrRaEkGsSmo0ipD05FlGCpv3i1VUtXy+UDx2vi4bsFU=; b=xXDe+wcZwEpGGxSmS7nevRrk7OAMm9EsSlpyalwZmqvrUirMqosT5OA3Q+a64s9UIo UgV+vgv0frs6fFzN2uux5ma+xw/Jo8iApQnGlVsSwncP1JKWF++w5D/IUYCZNqBTFZRv bdSX19N4wxrLpu13lYYbkZaWc9QUNr2XlstYY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:message-id:user-agent :mime-version:content-type; b=stGtOXJ+GYeMGy1XTVGFPDhY1E3AVe5oRp6n9YFgRI1vhqt8GZg7YCoiB4GFyHsfLE PFcmO+ZcHomjdD2Mb3P9vq/glOI0NlIxCDCxQtvoRlRapxzdKD4lFR870Ez28Mo8OqFe 7IsE+iqXBmyrH0tDAuU0+QFPirrpT9HcteoGo= Received: by 10.150.190.20 with SMTP id n20mr13440437ybf.275.1289978819468; Tue, 16 Nov 2010 23:26:59 -0800 (PST) Received: from localhost ([85.17.254.135]) by mx.google.com with ESMTPS id o10sm1410124yha.27.2010.11.16.23.26.53 (version=SSLv3 cipher=RC4-MD5); Tue, 16 Nov 2010 23:26:58 -0800 (PST) From: Anonymous To: Xin LI References: <4CC62413.50703@delphij.net> Date: Wed, 17 Nov 2010 10:26:38 +0300 Message-ID: <861v6kwgup.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Cc: FreeBSD Current Subject: Re: [PATCH] top(1) inverse display of table header X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2010 07:27:00 -0000 --=-=-= Content-Type: text/plain Xin LI writes: > Hi, > > Here is a patch that makes top(1) to inverse its table header (PID > USERNAME THR, etc). > That MAX_COLS change in it makes `top -b' produce too much extra whitespace that's not trimmed and spans several lines, e.g. $ stty -a | sed 1q speed 38400 baud; 57 rows; 79 columns; $ top -b last pid: 54799; load averages: 1.90, 2.16, 2.16 up 0+04:28:34 10:18:15 91 processes: 4 running, 85 sleeping, 2 stopped Mem: 540M Active, 243M Inact, 2934M Wired, 79M Cache, 417M Buf, 136M Free Swap: 4097M Total, 8856K Used, 4088M Free PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND 1730 holo 14 46 0 358M 197M ucond 1 1:24 0.00% firefox-bin FYI, using inverse color for header line can also be achieved on top-3.8b1 without touching source at all $ export TOPCOLORS='header=,#7' edwin@ planned to update top(1) but stalled, not sure why. http://docs.freebsd.org/cgi/mid.cgi?20080928054620.GA80250 And I for one still use his branch with below diff. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=top-3.8b1.diff Content-Description: local hacks for top-3.8b1 against svn://svn.freebsd.org/base/user/edwin/top/top-3.8b1 - cherry-pick changes from /head (r189626, r200979, r211419) - report realtime priority like /head - lower min_screenwidth for FLG field, for 80 col tty sake - use int type for counter - fix amd64/i386 cross-compilation - remove `-g', prefer DEBUG_FLAGS - abbreviate Kern/Kernel row like Mem/Memory - adjust whitespace --- Index: contrib/top/display.c =================================================================== --- contrib/top/display.c (revision 215416) +++ contrib/top/display.c (working copy) @@ -993,7 +993,6 @@ if (*bt != -1) { uptime = *tod - *bt; - uptime += 30; uptime_days = uptime / 86400; tm = gmtime(&uptime); @@ -1312,7 +1311,7 @@ } /* - * *_kernel(stats) - print "Kernel: " followed by the kernel summary string + * *_kernel(stats) - print "Kern: " followed by the kernel summary string * * Assumptions: cursor is on "lastline", the previous line */ @@ -1323,7 +1322,7 @@ { if (num_kernel > 0) { - display_write(0, y_kernel, 0, 0, "Kernel: "); + display_write(0, y_kernel, 0, 0, "Kern: "); /* format and print the kernel summary */ summary_format(x_kernel, y_kernel, stats, kernel_names, kernel_cidx); Index: contrib/top/username.c =================================================================== --- contrib/top/username.c (revision 215416) +++ contrib/top/username.c (working copy) @@ -53,7 +53,6 @@ #include #include -#include #include "top.h" #include "utils.h" @@ -72,7 +71,7 @@ struct hash_data { int uid; - char name[UT_NAMESIZE + 1]; /* big enough? */ + char name[MAXLOGNAME]; /* big enough? */ time_t expire; }; @@ -120,7 +119,7 @@ { if ((pw = getpwuid(uid)) != NULL) { - strncpy(data->name, pw->pw_name, UT_NAMESIZE); + strncpy(data->name, pw->pw_name, MAXLOGNAME - 1); data->expire = now + EXPIRETIME; dprintf("username: updating %d with %s, expires %d\n", data->uid, data->name, data->expire); Index: contrib/top/hash.c =================================================================== --- contrib/top/hash.c (revision 215416) +++ contrib/top/hash.c (working copy) @@ -99,7 +99,7 @@ next_prime(int x) { - double i, j; + int i, j; int f; i = x; @@ -108,7 +108,7 @@ f=1; for (j=2; j ${.TARGET} CLEANFILES+= config.h -CPU!= uname -m config.h: config.h.in @${ECHO} Making ${.TARGET} from ${.ALLSRC:T} sed \ @@ -55,7 +55,7 @@ -e 's/@DEFAULT_DELAY@/2/' \ -e 's/@HAVE_GETOPT_LONG@/1/' \ -e 's/@ENABLE_KILL@/1/' \ - -e "s/@CPU@/${CPU}/" \ + -e "s/@CPU@/${MACHINE}/" \ < ${.ALLSRC} > ${.TARGET} CLEANFILES+= top.1.local --=-=-=--