diff options
| author | Peter Wemm <peter@FreeBSD.org> | 1999-01-10 15:28:37 +0000 |
|---|---|---|
| committer | Peter Wemm <peter@FreeBSD.org> | 1999-01-10 15:28:37 +0000 |
| commit | 69b41093b5e335a9d938be3ea703f53887ab1201 (patch) | |
| tree | 6dbf8d9ccfb816dc544767a3a11b4ed91197a6ea | |
| parent | c03fa7f977282b20757a4d0ebf197bb220cfd306 (diff) | |
Notes
| -rw-r--r-- | usr.bin/w/pr_time.c | 9 | ||||
| -rw-r--r-- | usr.bin/w/w.c | 19 |
2 files changed, 15 insertions, 13 deletions
diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c index 0b53586c304c..5b38b58dd126 100644 --- a/usr.bin/w/pr_time.c +++ b/usr.bin/w/pr_time.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)pr_time.c 8.2 (Berkeley) 4/4/94"; #endif static const char rcsid[] = - "$Id: pr_time.c,v 1.10 1997/08/26 06:59:34 charnier Exp $"; + "$Id: pr_time.c,v 1.11 1997/12/28 17:50:10 alex Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -88,6 +88,7 @@ pr_attime(started, now) /* * pr_idle -- * Display the idle time. + * Returns number of excess characters that were used for long idle time. */ int pr_idle(idle) @@ -97,8 +98,10 @@ pr_idle(idle) if (idle >= 36 * 3600) { int days = idle / 86400; (void)printf(" %dday%s ", days, days > 1 ? "s" : " " ); + if (days >= 100) + return (2); if (days >= 10) - return(1); + return (1); } /* If idle more than an hour, print as HH:MM. */ @@ -113,5 +116,5 @@ pr_idle(idle) else (void)printf(" %2d ", (int)(idle / 60)); - return(0); /* not idle longer than 9 days */ + return (0); /* not idle longer than 9 days */ } diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 299b0d6560da..18e43c061941 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.30 1998/12/24 18:20:58 steve Exp $"; + "$Id: w.c,v 1.31 1998/12/24 23:27:33 dillon Exp $"; #endif /* not lint */ /* @@ -97,7 +97,7 @@ int argwidth; /* width of tty */ int header = 1; /* true if -h flag: don't print heading */ int nflag; /* true if -n flag: don't convert addrs */ int dflag; /* true if -d flag: output debug info */ -int sortidle; /* sort bu idle time */ +int sortidle; /* sort by idle time */ char *sel_user; /* login of particular user selected */ char domain[MAXHOSTNAMELEN]; @@ -287,7 +287,7 @@ main(argc, argv) */ dkp = ep->dkp; ep->dkp = kp; - *((struct kinfo_proc **)(&kp->kp_eproc.e_spare[ 0])) = dkp; + *((struct kinfo_proc **)(&kp->kp_eproc.e_spare[0])) = dkp; } } } @@ -352,7 +352,8 @@ main(argc, argv) } p = hp->h_name; } - if (nflag && *p && strcmp(p, "-") && inet_addr(p) == INADDR_NONE) { + if (nflag && *p && strcmp(p, "-") && + inet_addr(p) == INADDR_NONE) { hp = gethostbyname(p); if (hp != NULL) { @@ -367,8 +368,8 @@ main(argc, argv) ep->utmp.ut_host + UT_HOSTSIZE - x, x); p = buf; } - if( dflag) { - for( dkp = ep->dkp; dkp != NULL; dkp = *((struct kinfo_proc **)(&dkp->kp_eproc.e_spare[ 0]))) { + if (dflag) { + for (dkp = ep->dkp; dkp != NULL; dkp = *((struct kinfo_proc **)(&dkp->kp_eproc.e_spare[0]))) { char *p; p = fmt_argv(kvm_getargv(kd, dkp, argwidth), dkp->kp_proc.p_comm, MAXCOMLEN); @@ -385,10 +386,8 @@ 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); - longidle=pr_idle(ep->idle); - if (longidle) - argwidth--; - (void)printf("%.*s\n", argwidth, ep->args); + longidle = pr_idle(ep->idle); + (void)printf("%.*s\n", argwidth - longidle, ep->args); } exit(0); } |
