Date: Sat, 5 Jul 1997 12:01:32 +0200 (MET DST) From: Wolfram Schneider <wosch@apfel.de> To: current@freebsd.org Subject: long usernames in top Message-ID: <199707051001.MAA00736@panke.panke.de>
next in thread | raw e-mail | index | archive | help
The long usernames in top(1) looks not well. In most cases the usernames are less than 8 chars. Top reserves 16 chars for the username in the output string. Here is a workaround. Top should print only the first 10 characters. If the username is longer than 10 characters, the 10th character will be replaces with an asterisk ('*'). An other alternative would be to use the uid instead the long username. Index: contrib/top/username.c =================================================================== RCS file: /usr/cvs/src/contrib/top/username.c,v retrieving revision 1.2 diff -u -r1.2 username.c --- username.c 1997/04/21 13:52:29 1.2 +++ username.c 1997/07/04 22:49:35 @@ -126,7 +126,9 @@ /* empty or wrong slot -- fill it with new value */ hash_table[hashindex].uid = uid; - (void) strncpy(hash_table[hashindex].name, name, UT_NAMESIZE); + (void) strncpy(hash_table[hashindex].name, name, 10); + if (strlen(name) > 10) + *(hash_table[hashindex].name + 9) = '*'; return(hashindex); } Index: usr.bin/top/machine.c =================================================================== RCS file: /usr/cvs/src/usr.bin/top/machine.c,v retrieving revision 1.3 diff -u -r1.3 machine.c --- machine.c 1997/04/21 13:53:47 1.3 +++ machine.c 1997/07/04 10:21:54 @@ -122,22 +122,22 @@ #ifdef P_IDLEPROC /* FreeBSD SMP kernel */ static char header[] = - " PID X PRI NICE SIZE RES STATE C TIME WCPU CPU COMMAND"; + " PID X PRI NICE SIZE RES STATE C TIME WCPU CPU COMMAND"; /* 0123456 -- field to fill in starts at header+6 */ #define UNAME_START 6 #define Proc_format \ - "%5d %-16.16s%3d%3d%7s %6s %-6.6s%1x%7s %5.2f%% %5.2f%% %.6s" + "%5d %-10.10s%3d%3d%7s %6s %-6.6s%1x%7s %5.2f%% %5.2f%% %.6s" #else /* Standard kernel */ static char header[] = - " PID X PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND"; + " PID X PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND"; /* 0123456 -- field to fill in starts at header+6 */ #define UNAME_START 6 #define Proc_format \ - "%5d %-16.16s%3d %3d%7s %6s %-6.6s%7s %5.2f%% %5.2f%% %.6s" + "%5d %-10.10s%3d %3d%7s %6s %-6.6s%7s %5.2f%% %5.2f%% %.6s" #endif -- Wolfram Schneider <wosch@apfel.de> http://www.apfel.de/~wosch/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707051001.MAA00736>