summaryrefslogtreecommitdiffstats
path: root/usr.bin/w
diff options
context:
space:
mode:
authordanny <danny@FreeBSD.org>1997-02-11 10:49:25 +0000
committerdanny <danny@FreeBSD.org>1997-02-11 10:49:25 +0000
commitda4de4acb65bfed166f7a0fd06df1913df30bcd5 (patch)
tree71160423a76f8263422fcef347686d8905551417 /usr.bin/w
parentb139405b95e14f555208343662a3a4686060b95d (diff)
downloadFreeBSD-src-da4de4acb65bfed166f7a0fd06df1913df30bcd5.zip
FreeBSD-src-da4de4acb65bfed166f7a0fd06df1913df30bcd5.tar.gz
Reduce the command field width by one when idle time is > 9 days, to
eliminate unsightly blank line. Possibly a 2.2 candidate.
Diffstat (limited to 'usr.bin/w')
-rw-r--r--usr.bin/w/extern.h2
-rw-r--r--usr.bin/w/pr_time.c6
-rw-r--r--usr.bin/w/w.c6
3 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/w/extern.h b/usr.bin/w/extern.h
index 1ee237c..7cb4ed0 100644
--- a/usr.bin/w/extern.h
+++ b/usr.bin/w/extern.h
@@ -35,5 +35,5 @@
struct proc;
void pr_attime __P((time_t *, time_t *));
-void pr_idle __P((time_t));
+int pr_idle __P((time_t));
int proc_compare __P((struct proc *, struct proc *));
diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c
index dfbe154..6faf6db 100644
--- a/usr.bin/w/pr_time.c
+++ b/usr.bin/w/pr_time.c
@@ -84,7 +84,7 @@ pr_attime(started, now)
* pr_idle --
* Display the idle time.
*/
-void
+int
pr_idle(idle)
time_t idle;
{
@@ -92,6 +92,8 @@ pr_idle(idle)
if (idle >= 36 * 3600) {
int days = idle / 86400;
(void)printf(" %dday%s ", days, days > 1 ? "s" : " " );
+ if (days >= 10)
+ return(1);
}
/* If idle more than an hour, print as HH:MM. */
@@ -105,4 +107,6 @@ pr_idle(idle)
/* Else print the minutes idle. */
else
(void)printf(" %2d ", idle / 60);
+
+ return(0); /* not idle longer than 9 days */
}
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index b9c2a63..c615430 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -127,7 +127,7 @@ main(argc, argv)
FILE *ut;
u_long l;
size_t arglen;
- int ch, i, nentries, nusers, wcmd;
+ int ch, i, nentries, nusers, wcmd, longidle;
char *memf, *nlistf, *p, *vis_args, *x;
char buf[MAXHOSTNAMELEN], errbuf[256];
@@ -345,7 +345,9 @@ main(argc, argv)
ep->utmp.ut_line : ep->utmp.ut_line + 3,
UT_HOSTSIZE, UT_HOSTSIZE, *p ? p : "-");
pr_attime(&ep->utmp.ut_time, &now);
- pr_idle(ep->idle);
+ longidle=pr_idle(ep->idle);
+ if (longidle)
+ argwidth--;
if (ep->args != NULL) {
arglen = strlen(ep->args);
strvisx(vis_args, ep->args,
OpenPOWER on IntegriCloud