From owner-p4-projects@FreeBSD.ORG Wed Dec 31 07:49:53 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B1F5E16A4D0; Wed, 31 Dec 2003 07:49:53 -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 7426F16A4CE for ; Wed, 31 Dec 2003 07:49:53 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0DB5843D2D for ; Wed, 31 Dec 2003 07:49:52 -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 hBVFnp0B020034 for ; Wed, 31 Dec 2003 07:49:51 -0800 (PST) (envelope-from cvance@nailabs.com) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id hBVFnpT3020031 for perforce@freebsd.org; Wed, 31 Dec 2003 07:49:51 -0800 (PST) (envelope-from cvance@nailabs.com) Date: Wed, 31 Dec 2003 07:49:51 -0800 (PST) Message-Id: <200312311549.hBVFnpT3020031@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 44593 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: Wed, 31 Dec 2003 15:49:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=44593 Change 44593 by cvance@cvance_sony on 2003/12/31 07:49:30 Test out some changes to allow -Z to print MAC labels without requiring long format Affected files ... .. //depot/projects/trustedbsd/sebsd/bin/ls/ls.c#4 edit .. //depot/projects/trustedbsd/sebsd/bin/ls/print.c#5 edit Differences ... ==== //depot/projects/trustedbsd/sebsd/bin/ls/ls.c#4 (text+ko) ==== @@ -367,7 +367,7 @@ * information, unless in color mode in which case we do * need this to determine which colors to display. */ - if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type + if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type && !f_label #ifdef COLORLS && !f_color #endif @@ -420,7 +420,7 @@ } /* Select a print function. */ - if (f_singlecol) + if (f_singlecol || (f_label && !f_longform)) printfcn = printscol; else if (f_longform) printfcn = printlong; @@ -546,7 +546,7 @@ if (list == NULL) return; - needstats = f_inode || f_longform || f_size; + needstats = f_inode || f_longform || f_size || f_label; flen = 0; btotal = 0; initmax = getenv("LS_COLWIDTHS"); @@ -672,7 +672,7 @@ maxsize = sp->st_size; btotal += sp->st_blocks; - if (f_longform) { + if (f_longform || f_label) { if (f_numericonly) { (void)snprintf(nuser, sizeof(nuser), "%u", sp->st_uid); @@ -811,7 +811,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/sebsd/bin/ls/print.c#5 (text+ko) ==== @@ -65,7 +65,7 @@ #include "ls.h" #include "extern.h" -static int printaname(const FTSENT *, u_long, u_long); +static int printaname(const FTSENT *, u_long, u_long, u_long); static void printlink(const FTSENT *); static void printtime(time_t); static int printtype(u_int); @@ -135,7 +135,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'); } } @@ -248,7 +248,7 @@ putchar('\n'); chcnt = 0; } - chcnt += printaname(p, dp->s_inode, dp->s_block); + chcnt += printaname(p, dp->s_label, dp->s_inode, dp->s_block); if (p->fts_link) { printf(", "); chcnt += 2; @@ -327,8 +327,8 @@ if (!f_sortacross) base = row; for (col = 0, chcnt = 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 (f_sortacross) base++; else @@ -353,9 +353,11 @@ * return # of characters printed, no trailing characters. */ static int -printaname(const FTSENT *p, u_long inodefield, u_long sizefield) +printaname(const FTSENT *p, u_long labelfield, u_long inodefield, + u_long sizefield) { struct stat *sp; + NAMES *np; int chcnt; #ifdef COLORLS int color_printed = 0; @@ -363,6 +365,10 @@ 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("%*lu ", (int)inodefield, (u_long)sp->st_ino); if (f_size)