Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/w PR/28751: Ed Ravin: Limit host field output by def...



details:   https://anonhg.NetBSD.org/src/rev/244ed2ba6973
branches:  trunk
changeset: 572153:244ed2ba6973
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Dec 22 17:16:07 2004 +0000

description:
PR/28751: Ed Ravin: Limit host field output by default to 35 characters so
that things don't wrap. Add -w flag to enable full output. Delete mention
of the old and not supported flags. This was 11 years ago, and very few
people even remember what these flags did.

diffstat:

 usr.bin/w/w.1 |  17 ++++++-----------
 usr.bin/w/w.c |  24 ++++++++++++++++--------
 2 files changed, 22 insertions(+), 19 deletions(-)

diffs (138 lines):

diff -r 3fa3b06e2592 -r 244ed2ba6973 usr.bin/w/w.1
--- a/usr.bin/w/w.1     Wed Dec 22 05:11:24 2004 +0000
+++ b/usr.bin/w/w.1     Wed Dec 22 17:16:07 2004 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: w.1,v 1.13 2003/08/07 11:17:13 agc Exp $
+.\"    $NetBSD: w.1,v 1.14 2004/12/22 17:16:07 christos Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)w.1        8.1 (Berkeley) 6/6/93
 .\"
-.Dd June 6, 1993
+.Dd December 22, 2004
 .Dt W 1
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nd "who present users are and what they are doing"
 .Sh SYNOPSIS
 .Nm
-.Op Fl hin
+.Op Fl hinw
 .Op Fl M Ar core
 .Op Fl N Ar system
 .Op Ar user
@@ -75,6 +75,9 @@
 Show network addresses as numbers (normally
 .Nm
 interprets addresses and attempts to display them symbolically).
+.It Fl w
+Show wide output without truncating any fields. Normally the host field
+is truncated to 35 characters.
 .El
 .Pp
 If a
@@ -90,14 +93,6 @@
 .Xr ps 1 ,
 .Xr uptime 1 ,
 .Xr who 1
-.Sh COMPATIBILITY
-The
-.Fl f ,
-.Fl l ,
-.Fl s ,
-and
-.Fl w
-flags are no longer supported.
 .Sh HISTORY
 The
 .Nm
diff -r 3fa3b06e2592 -r 244ed2ba6973 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Wed Dec 22 05:11:24 2004 +0000
+++ b/usr.bin/w/w.c     Wed Dec 22 17:16:07 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.64 2004/11/19 13:17:06 christos Exp $  */
+/*     $NetBSD: w.c,v 1.65 2004/12/22 17:16:08 christos Exp $  */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)w.c        8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.64 2004/11/19 13:17:06 christos Exp $");
+__RCSID("$NetBSD: w.c,v 1.65 2004/12/22 17:16:08 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -96,11 +96,13 @@
 int            argwidth;       /* width of tty left to print process args */
 int            header = 1;     /* true if -h flag: don't print heading */
 int            nflag;          /* true if -n flag: don't convert addrs */
+int            wflag;          /* true if -w flag: wide printout */
 int            sortidle;       /* sort bu idle time */
 char          *sel_user;       /* login of particular user selected */
 char           domain[MAXHOSTNAMELEN + 1];
 int maxname = 8, maxline = 3, maxhost = 16;
 
+#define HOSTWIDTH 35
 /*
  * One of these per active utmp entry.
  */
@@ -137,6 +139,7 @@
        int ch, i, nentries, nusers, wcmd;
        char *memf, *nlistf, *p, *x;
        time_t then;
+       int hostwidth;
 #ifdef SUPPORT_UTMP
        struct utmp *ut;
 #endif
@@ -155,7 +158,7 @@
                p = "";
        } else {
                wcmd = 1;
-               p = "hiflM:N:nsuw";
+               p = "hiM:N:nw";
        }
 
        memf = nlistf = NULL;
@@ -177,9 +180,9 @@
                case 'n':
                        nflag = 1;
                        break;
-               case 'f': case 'l': case 's': case 'u': case 'w':
-                       warnx("[-flsuw] no longer supported");
-                       /* FALLTHROUGH */
+               case 'w':
+                       wflag = 1;
+                       break;
                case '?':
                default:
                        usage(wcmd);
@@ -311,8 +314,13 @@
                }
        }
 
+       if (wflag || maxhost < HOSTWIDTH)
+               hostwidth = maxhost;
+       else
+               hostwidth = HOSTWIDTH;
+
        argwidth = printf("%-*s TTY     %-*s %*s  IDLE WHAT\n",
-           maxname, "USER", maxhost, "FROM",
+           maxname, "USER", hostwidth, "FROM",
            7 /* "dddhhXm" */, "LOGIN@");
        argwidth -= sizeof("WHAT\n") - 1 /* NUL */;
 
@@ -411,7 +419,7 @@
                }
                (void)printf("%-*s %-7.7s %-*.*s ",
                    maxname, kp->p_login, ep->line,
-                   maxhost, maxhost, *p ? p : "-");
+                   hostwidth, hostwidth, *p ? p : "-");
                then = (time_t)ep->tv.tv_sec;
                pr_attime(&then, &now);
                pr_idle(ep->idle);



Home | Main Index | Thread Index | Old Index