Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Feb 2004 09:37:07 -0800 (PST)
From:      Chris Vance <cvance@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 47577 for review
Message-ID:  <200402241737.i1OHb7L2007963@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



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