From owner-p4-projects@FreeBSD.ORG Tue Feb 24 09:37:08 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5321916A4D0; Tue, 24 Feb 2004 09:37:08 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2959D16A4CE for ; Tue, 24 Feb 2004 09:37:08 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E18C43D2F for ; Tue, 24 Feb 2004 09:37:08 -0800 (PST) (envelope-from cvance@nailabs.com) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i1OHb7Ge007966 for ; Tue, 24 Feb 2004 09:37:07 -0800 (PST) (envelope-from cvance@nailabs.com) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i1OHb7L2007963 for perforce@freebsd.org; Tue, 24 Feb 2004 09:37:07 -0800 (PST) (envelope-from cvance@nailabs.com) Date: Tue, 24 Feb 2004 09:37:07 -0800 (PST) Message-Id: <200402241737.i1OHb7L2007963@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to cvance@nailabs.com using -f From: Chris Vance To: Perforce Change Reviews Subject: PERFORCE change 47577 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2004 17:37:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=47577 Change 47577 by cvance@cvance_osx_laptop on 2004/02/24 09:36:47 Integrate the changes that allow you to use -Z without requiring long format. Affected files ... .. //depot/projects/trustedbsd/sedarwin/apsl/file_cmds/ls/ls.c#3 edit .. //depot/projects/trustedbsd/sedarwin/apsl/file_cmds/ls/print.c#3 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin/apsl/file_cmds/ls/ls.c#3 (text+ko) ==== @@ -246,7 +246,7 @@ * information. */ if (!f_inode && !f_longform && !f_size && !f_type && - sortkey == BY_NAME) + sortkey == BY_NAME && !f_label) fts_options |= FTS_NOSTAT; /* @@ -309,7 +309,7 @@ } /* Select a print function. */ - if (f_singlecol) + if (f_singlecol || (f_label && !f_longform)) printfcn = printscol; else if (f_columnacross) printfcn = printacol; @@ -356,7 +356,8 @@ * If not recursing down this tree and don't need stat info, just get * the names. */ - ch_options = !f_recursive && options & FTS_NOSTAT ? FTS_NAMEONLY : 0; + ch_options = !f_recursive && !f_label && + options & FTS_NOSTAT ? FTS_NAMEONLY : 0; while ((p = fts_read(ftsp)) != NULL) switch (p->fts_info) { @@ -439,7 +440,7 @@ if (list == NULL) return; - needstats = f_inode || f_longform || f_size; + needstats = f_inode || f_longform || f_size || f_label; flen = 0; maxinode = maxnlink = 0; bcfile = 0; @@ -492,7 +493,7 @@ } btotal += sp->st_blocks; - if (f_longform) { + if (f_longform || f_label) { if (f_numericonly) { (void)snprintf(nuser, sizeof(nuser), "%u", sp->st_uid); @@ -645,7 +646,7 @@ printfcn(&d); output = 1; - if (f_longform) + if (f_longform || f_label) for (cur = list; cur; cur = cur->fts_link) free(cur->fts_pointer); } ==== //depot/projects/trustedbsd/sedarwin/apsl/file_cmds/ls/print.c#3 (text+ko) ==== @@ -64,7 +64,7 @@ #include "ls.h" #include "extern.h" -static int printaname __P((FTSENT *, int, int)); +static int printaname __P((FTSENT *, int, int, int)); static void printlink __P((FTSENT *)); static void printtime __P((time_t)); static int printtype __P((u_int)); @@ -82,7 +82,7 @@ for (p = dp->list; p; p = p->fts_link) { if (IS_NOPRINT(p)) continue; - (void)printaname(p, dp->s_inode, dp->s_block); + (void)printaname(p, dp->s_label, dp->s_inode, dp->s_block); (void)putchar('\n'); } } @@ -201,8 +201,8 @@ (long long)(howmany(dp->btotal, blocksize))); for (row = 0; row < numrows; ++row) { for (base = row, chcnt = col = 0; col < numcols; ++col) { - chcnt = printaname(array[base], dp->s_inode, - dp->s_block); + chcnt = printaname(array[base], dp->s_label, + dp->s_inode, dp->s_block); if ((base += numrows) >= num) break; while (chcnt++ < colwidth) @@ -250,7 +250,7 @@ chcnt = col = 0; (void)putchar('\n'); } - chcnt = printaname(p, dp->s_inode, dp->s_block); + chcnt = printaname(p, dp->s_label, dp->s_inode, dp->s_block); while (chcnt++ < colwidth) (void)putchar(' '); col++; @@ -263,16 +263,21 @@ * return # of characters printed, no trailing characters. */ static int -printaname(p, inodefield, sizefield) +printaname(p, labelfield, inodefield, sizefield) FTSENT *p; - int sizefield, inodefield; + int labelfield, sizefield, inodefield; { struct stat *sp; int chcnt; + NAMES *np; char nbuf[MAXPATHLEN + 1], *name; sp = p->fts_statp; chcnt = 0; + if (f_label) { + np = p->fts_pointer; + chcnt += printf("%-*s ", (int)labelfield, np->label); + } if (f_inode) chcnt += printf("%*u ", inodefield, sp->st_ino); if (f_size)