From 25789e916f6ee1102ff4ebeeae92a1536ea128b9 Mon Sep 17 00:00:00 2001 From: jkoshy Date: Thu, 21 May 1998 08:46:48 +0000 Subject: Cosmetic fix. Compute header field widths from UT_{HOST,LINE,NAME}SIZE instead of hardcoding header line. PR: 6325 --- usr.bin/w/w.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 9ef076f..f822281 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94"; #endif static const char rcsid[] = - "$Id: w.c,v 1.25 1998/04/19 18:32:01 phk Exp $"; + "$Id: w.c,v 1.26 1998/05/14 10:13:24 jkoshy Exp $"; #endif /* not lint */ /* @@ -246,9 +246,18 @@ main(argc, argv) if (wcmd == 0) exit (0); -#define HEADER "USER TTY FROM LOGIN@ IDLE WHAT\n" -#define WUSED (sizeof (HEADER) - sizeof ("WHAT\n")) - (void)printf(HEADER); +#define HEADER_USER "USER" +#define HEADER_TTY "TTY" +#define HEADER_FROM "FROM" +#define HEADER_LOGIN_IDLE "LOGIN@ IDLE " +#define HEADER_WHAT "WHAT\n" +#define WUSED (UT_NAMESIZE + UT_LINESIZE + UT_HOSTSIZE + \ + sizeof(HEADER_LOGIN_IDLE) + 3) /* header width incl. spaces */ + (void)printf("%-*.*s %-*.*s %-*.*s %s", + UT_NAMESIZE, UT_NAMESIZE, HEADER_USER, + UT_LINESIZE, UT_LINESIZE, HEADER_TTY, + UT_HOSTSIZE, UT_HOSTSIZE, HEADER_FROM, + HEADER_LOGIN_IDLE HEADER_WHAT); } if ((kp = kvm_getprocs(kd, KERN_PROC_ALL, 0, &nentries)) == NULL) -- cgit v1.1