Date: Thu, 24 Mar 2011 17:20:24 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r219967 - head/bin/ps Message-ID: <201103241720.p2OHKOUd052306@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Thu Mar 24 17:20:24 2011 New Revision: 219967 URL: http://svn.freebsd.org/changeset/base/219967 Log: Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space. Modified: head/bin/ps/extern.h head/bin/ps/keyword.c head/bin/ps/print.c Modified: head/bin/ps/extern.h ============================================================================== --- head/bin/ps/extern.h Thu Mar 24 17:09:37 2011 (r219966) +++ head/bin/ps/extern.h Thu Mar 24 17:20:24 2011 (r219967) @@ -75,6 +75,8 @@ void runame(KINFO *, VARENT *); void rvar(KINFO *, VARENT *); int s_comm(KINFO *); int s_label(KINFO *); +int s_loginclass(KINFO *); +int s_logname(KINFO *); int s_rgroupname(KINFO *); int s_runame(KINFO *); int s_uname(KINFO *); Modified: head/bin/ps/keyword.c ============================================================================== --- head/bin/ps/keyword.c Thu Mar 24 17:09:37 2011 (r219966) +++ head/bin/ps/keyword.c Thu Mar 24 17:20:24 2011 (r219967) @@ -79,8 +79,8 @@ static VAR var[] = { CHAR, NULL, 0}, {"blocked", "", "sigmask", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, {"caught", "", "sigcatch", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, - {"class", "CLASS", NULL, LJUST, loginclass, NULL, MAXLOGNAME-1, 0, - CHAR, NULL, 0}, + {"class", "CLASS", NULL, LJUST|DSIZ, loginclass, s_loginclass, + MAXLOGNAME-1, 0, CHAR, NULL, 0}, {"comm", "COMMAND", NULL, LJUST|DSIZ, ucomm, s_comm, COMMLEN + OCOMMLEN + 1, 0, CHAR, NULL, 0}, {"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16, 0, @@ -108,8 +108,8 @@ static VAR var[] = { {"lim", "LIM", NULL, 0, maxrss, NULL, 5, 0, CHAR, NULL, 0}, {"lockname", "LOCK", NULL, LJUST, lockname, NULL, 6, 0, CHAR, NULL, 0}, - {"login", "LOGIN", NULL, LJUST, logname, NULL, MAXLOGNAME-1, 0, CHAR, - NULL, 0}, + {"login", "LOGIN", NULL, LJUST|DSIZ, logname, s_logname, MAXLOGNAME-1, + 0, CHAR, NULL, 0}, {"logname", "", "login", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, {"lstart", "STARTED", NULL, LJUST|USER, lstarted, NULL, 28, 0, CHAR, NULL, 0}, Modified: head/bin/ps/print.c ============================================================================== --- head/bin/ps/print.c Thu Mar 24 17:09:37 2011 (r219966) +++ head/bin/ps/print.c Thu Mar 24 17:20:24 2011 (r219967) @@ -908,7 +908,7 @@ loginclass(KINFO *k, VARENT *ve) * and limits don't apply to system processes. */ if (k->ki_p->ki_flag & P_SYSTEM) { - (void)printf("%-*s", v->width, " -"); + (void)printf("%-*s", v->width, "-"); return; } s = k->ki_p->ki_loginclass; @@ -948,3 +948,30 @@ s_label(KINFO *k) mac_free(proclabel); return (size); } + +int +s_loginclass(KINFO *k) +{ + char *s; + + if (k->ki_p->ki_flag & P_SYSTEM) + return (1); + + s = k->ki_p->ki_loginclass; + if (s == NULL) + return (1); + + return (strlen(s)); +} + +int +s_logname(KINFO *k) +{ + char *s; + + s = k->ki_p->ki_login; + if (s == NULL) + return (1); + + return (strlen(s)); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103241720.p2OHKOUd052306>