PERFORCE change 44593 for review
Chris Vance
cvance at FreeBSD.org
Wed Dec 31 15:49:51 GMT 2003
http://perforce.freebsd.org/chv.cgi?CH=44593
Change 44593 by cvance at 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)
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list