Skip site navigation (1)Skip section navigation (2)
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
This is a multi-part message in MIME format.

------=_NextPart_000_0000_01BEB734.5AA5A4A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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

------=_NextPart_000_0000_01BEB734.5AA5A4A0
Content-Type: application/octet-stream;
	name="w.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="w.patch"

104a105,114=0A=
>  * UT_LINESIZE is 5 for who output, because the entire terminal device =
name=0A=
>  * is shown (e.g. ttyp0).  Since we only show the 'p0' in w, we'll =
redefine=0A=
>  * this to 3 to save space.=0A=
>  */=0A=
> #ifdef UT_LINESIZE=0A=
> #undef UT_LINESIZE=0A=
> #endif=0A=
> #define UT_LINESIZE 3=0A=
> =0A=
> /*=0A=
138c148=0A=
< 	int ch, i, nentries, nusers, wcmd, longidle;=0A=
---=0A=
> 	int ch, i, nentries, nusers, wcmd, longidle, maxnamelen=3D5;=0A=
217a228,238=0A=
> =0A=
> 		/*=0A=
> 		 * Calculate the maximum number of spaces needed for=0A=
> 		 * each username.  Previously 16; in 2.2.x and lower,=0A=
> 		 * when long usernames did not exist, 8 spaces were=0A=
> 		 * used.  To avoid wasted space we will now do this=0A=
> 		 * dynamically.=0A=
> 		 */=0A=
> 		if (strlen(utmp.ut_name) > maxnamelen)=0A=
> 			maxnamelen =3D strlen(utmp.ut_name);=0A=
> 		 =0A=
252c273=0A=
< #define WUSED  (UT_NAMESIZE + UT_LINESIZE + UT_HOSTSIZE + \=0A=
---=0A=
> #define WUSED  (maxnamelen + UT_LINESIZE + UT_HOSTSIZE + \=0A=
255c276=0A=
< 				UT_NAMESIZE, UT_NAMESIZE, HEADER_USER,=0A=
---=0A=
> 				maxnamelen, maxnamelen, HEADER_USER,=0A=
382c403=0A=
< 		    UT_NAMESIZE, UT_NAMESIZE, ep->utmp.ut_name,=0A=
---=0A=
> 		    maxnamelen, maxnamelen, ep->utmp.ut_name,=0A=

------=_NextPart_000_0000_01BEB734.5AA5A4A0--



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?NCBBIGFCFJBOEIOPOAKPGECECAAA.sam>