Date: Thu, 12 Nov 1998 04:03:00 -0600 (CST) From: fullermd@futuresouth.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/8662: w (-stable) has hardwired sizes Message-ID: <199811121003.EAA29366@mortis.futuresouth.com>
next in thread | raw e-mail | index | archive | help
>Number: 8662
>Category: bin
>Synopsis: w (-stable) has hardwired sizes
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Nov 12 02:10:00 PST 1998
>Last-Modified:
>Originator: Matthew Fuller
>Organization:
FutureSouth Communications
>Release: FreeBSD 2.2.7-STABLE i386
>Environment:
Various fairly bland -STABLE machines
>Description:
w(1) has fixed sizes for field widths on the output. This causes
problems when running with >8 char usernames.
Below patch is the one applied to -current in rev 1.27.
Applies cleanly, looks to be working fine from this end. Further
testing couldn't, of course, hurt. It shouldn't cause any problems
for 8 char usernames (the default case), but makes migrating to
different lengths easier.
>How-To-Repeat:
See description.
>Fix:
Index: w.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/w/w.c,v
retrieving revision 1.16.2.7
diff -u -r1.16.2.7 w.c
--- w.c 1998/05/22 09:09:29 1.16.2.7
+++ w.c 1998/11/12 07:58:14
@@ -246,9 +246,18 @@
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)
@@ -372,8 +381,9 @@
(void)printf( "\t\t%-9d %s\n", dkp->kp_proc.p_pid, p);
}
}
- (void)printf("%-*.*s %-3.3s %-*.*s ",
+ (void)printf("%-*.*s %-*.*s %-*.*s ",
UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name,
+ UT_LINESIZE, UT_LINESIZE,
strncmp(ep->utmp.ut_line, "tty", 3) &&
strncmp(ep->utmp.ut_line, "cua", 3) ?
ep->utmp.ut_line : ep->utmp.ut_line + 3,
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811121003.EAA29366>
