Date: Tue, 15 Jun 1999 13:38:29 -0400 From: "Sam Stephenson" <sam@conio.net> To: <freebsd-stable@freebsd.org>, <freebsd-current@freebsd.org> Subject: 'w' patch Message-ID: <NCBBIGFCFJBOEIOPOAKPGECECAAA.sam@conio.net>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] There seem to be two problems (not even problems; more like annoyances) that exist in the 'w' command, both which involve unnecessary spacing that limits the size of the WHAT field. I have attached a patch to /usr/src/usr.bin/w/w.c which corrects the following: - The size of the USER field is now dynamically allocated as the length of the longest username, with a minimum of 5 spaces. In FreeBSD 2.2.x and lower, before long usernames existed, the field size was 8. It was enlarged to 16 to provide long username support, but on systems with shorter usernames, the wasted space can be bothersome. - UT_LINESIZE is redefined to 3; it was originally 5 because 'who' output shows the entire device name (e.g. ttyp0). Since 'w' only shows the 'p0' part, there are two unnecessary spaces. Please have a look at this patch, and consider implementing it into the source tree. --Sam Stephenson sam@conio.net [-- Attachment #2 --] 104a105,114 > * UT_LINESIZE is 5 for who output, because the entire terminal device name > * is shown (e.g. ttyp0). Since we only show the 'p0' in w, we'll redefine > * this to 3 to save space. > */ > #ifdef UT_LINESIZE > #undef UT_LINESIZE > #endif > #define UT_LINESIZE 3 > > /* 138c148 < int ch, i, nentries, nusers, wcmd, longidle; --- > int ch, i, nentries, nusers, wcmd, longidle, maxnamelen=5; 217a228,238 > > /* > * Calculate the maximum number of spaces needed for > * each username. Previously 16; in 2.2.x and lower, > * when long usernames did not exist, 8 spaces were > * used. To avoid wasted space we will now do this > * dynamically. > */ > if (strlen(utmp.ut_name) > maxnamelen) > maxnamelen = strlen(utmp.ut_name); > 252c273 < #define WUSED (UT_NAMESIZE + UT_LINESIZE + UT_HOSTSIZE + \ --- > #define WUSED (maxnamelen + UT_LINESIZE + UT_HOSTSIZE + \ 255c276 < UT_NAMESIZE, UT_NAMESIZE, HEADER_USER, --- > maxnamelen, maxnamelen, HEADER_USER, 382c403 < UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name, --- > maxnamelen, maxnamelen, ep->utmp.ut_name,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?NCBBIGFCFJBOEIOPOAKPGECECAAA.sam>
