From owner-freebsd-bugs@FreeBSD.ORG Wed Jul 23 08:50:14 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 008A137B40F for ; Wed, 23 Jul 2003 08:50:14 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 854AB43F93 for ; Wed, 23 Jul 2003 08:50:12 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6NFoCUp025923 for ; Wed, 23 Jul 2003 08:50:12 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6NFoCOS025922; Wed, 23 Jul 2003 08:50:12 -0700 (PDT) Resent-Date: Wed, 23 Jul 2003 08:50:12 -0700 (PDT) Resent-Message-Id: <200307231550.h6NFoCOS025922@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, andyf@speednet.com.au Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 98E9637B401 for ; Wed, 23 Jul 2003 08:41:40 -0700 (PDT) Received: from johnny.speednet.com.au (johnny.speednet.com.au [203.57.65.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id C753E43F3F for ; Wed, 23 Jul 2003 08:41:39 -0700 (PDT) (envelope-from andyf@johnny.speednet.com.au) Received: from johnny.speednet.com.au (localhost [127.0.0.1]) h6NFfcZH051672 for ; Thu, 24 Jul 2003 01:41:38 +1000 (EST) (envelope-from andyf@johnny.speednet.com.au) Received: (from root@localhost) by johnny.speednet.com.au (8.12.8p1/8.12.8/Submit) id h6NFfcai051671; Thu, 24 Jul 2003 01:41:38 +1000 (EST) Message-Id: <200307231541.h6NFfcai051671@johnny.speednet.com.au> Date: Thu, 24 Jul 2003 01:41:38 +1000 (EST) From: andyf@speednet.com.au To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/54784: find -ls wastes space X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2003 15:50:14 -0000 >Number: 54784 >Category: bin >Synopsis: find -ls wastes space >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jul 23 08:50:11 PDT 2003 >Closed-Date: >Last-Modified: >Originator: andyf@speednet.com.au >Release: FreeBSD 4.8-RELEASE i386 >Organization: >Environment: >Description: When using the -ls option of find(1) the username and groupname are formatted into a fixed length field of UT_NAMESIZE (MAXLOGNAME on -current). This patch does what top(1) does and scans for the long- est username, then formats the field to this dynamic value. The patches to operater.c fix compile warnings. >How-To-Repeat: find . -ls >Fix: diff -u ./extern.h ./new/extern.h --- ./extern.h Sun May 6 19:53:22 2001 +++ ./new/extern.h Thu Jul 24 00:58:54 2003 @@ -111,5 +111,5 @@ exec_f f_user; extern int ftsoptions, isdeprecated, isdepth, isoutput, issort, isxargs; -extern int mindepth, maxdepth; +extern int namelength, mindepth, maxdepth; extern int regexp_flags; diff -u ./function.c ./new/function.c --- ./function.c Fri Nov 15 21:38:15 2002 +++ ./new/function.c Thu Jul 24 00:02:45 2003 @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -926,8 +927,17 @@ OPTION *option; char ***argvp; { + struct passwd *pw; + ftsoptions &= ~FTS_NOSTAT; isoutput = 1; + + while ((pw = getpwent()) != NULL) { + if (strlen(pw->pw_name) > namelength) + namelength = strlen(pw->pw_name); + } + if (namelength < 8) + namelength = 8; return palloc(option); } diff -u ./ls.c ./new/ls.c --- ./ls.c Wed Mar 13 05:34:50 2002 +++ ./new/ls.c Thu Jul 24 00:12:57 2003 @@ -52,6 +52,8 @@ #include #include +extern int namelength; + /* Derived from the print routines in the ls(1) source code. */ static void printlink __P((char *)); @@ -67,9 +69,9 @@ (void)printf("%6lu %4qd ", (u_long) sb->st_ino, sb->st_blocks); (void)strmode(sb->st_mode, modep); - (void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, UT_NAMESIZE, - user_from_uid(sb->st_uid, 0), UT_NAMESIZE, - group_from_gid(sb->st_gid, 0)); + (void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, + namelength, user_from_uid(sb->st_uid, 0), + namelength, group_from_gid(sb->st_gid, 0)); if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode)) (void)printf("%3d, %3d ", major(sb->st_rdev), diff -u ./main.c ./new/main.c --- ./main.c Mon Feb 26 07:56:59 2001 +++ ./new/main.c Thu Jul 24 00:10:57 2003 @@ -74,6 +74,7 @@ int issort; /* do hierarchies in lexicographical order */ int isxargs; /* don't permit xargs delimiting chars */ int mindepth = -1, maxdepth = -1; /* minimum and maximum depth */ +int namelength; /* longest username */ int regexp_flags = REG_BASIC; /* use the "basic" regexp by default*/ static void usage __P((void)); diff -u ./operator.c ./new/operator.c --- ./operator.c Sun May 6 19:53:22 2001 +++ ./new/operator.c Mon Jul 21 22:19:03 2003 @@ -37,7 +37,9 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)operator.c 8.1 (Berkeley) 6/6/93"; +#endif #endif /* not lint */ #include @@ -173,7 +175,7 @@ tail = result = NULL; - while (next = yanknode(&plan)) { + while ((next = yanknode(&plan)) != NULL) { /* * if we encounter a ( expression ) then look for nots in * the expr subplan. >Release-Note: >Audit-Trail: >Unformatted: