summaryrefslogtreecommitdiffstats
path: root/usr.bin/w
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>1998-05-21 08:46:48 +0000
committerjkoshy <jkoshy@FreeBSD.org>1998-05-21 08:46:48 +0000
commit25789e916f6ee1102ff4ebeeae92a1536ea128b9 (patch)
treee8a538d63b2847031f802a16afc70b13d7d85b98 /usr.bin/w
parentd26bce6481da9a31a8c8f3681d9808a35e47dd6b (diff)
downloadFreeBSD-src-25789e916f6ee1102ff4ebeeae92a1536ea128b9.zip
FreeBSD-src-25789e916f6ee1102ff4ebeeae92a1536ea128b9.tar.gz
Cosmetic fix. Compute header field widths from UT_{HOST,LINE,NAME}SIZE
instead of hardcoding header line. PR: 6325
Diffstat (limited to 'usr.bin/w')
-rw-r--r--usr.bin/w/w.c17
1 files 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)
OpenPOWER on IntegriCloud