summaryrefslogtreecommitdiffstats
path: root/bin/ls/print.c
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-05-19 02:51:36 +0000
committertjr <tjr@FreeBSD.org>2002-05-19 02:51:36 +0000
commit18037eb7abbc88a96356f5301de4264b7e15e365 (patch)
tree28b290e569abcd5762e812b539f2164dfff413d9 /bin/ls/print.c
parent1f1f792674c9b3099aaa76909c7265fd5b213123 (diff)
downloadFreeBSD-src-18037eb7abbc88a96356f5301de4264b7e15e365.zip
FreeBSD-src-18037eb7abbc88a96356f5301de4264b7e15e365.tar.gz
Add missing options required by SUSv3:
-m List files across the page, separated by commas. -p Print a slash after directory names -x Same as -C but sort across the columns rather than down Submitted by: Kyle Martin <mkm@ieee.org>
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r--bin/ls/print.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c
index 5887b70..5068419 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -223,6 +223,31 @@ printlong(DISPLAY *dp)
}
void
+printstream(DISPLAY *dp)
+{
+ FTSENT *p;
+ extern int termwidth;
+ int chcnt;
+
+ for (p = dp->list, chcnt = 0; p; p = p->fts_link) {
+ if (p->fts_number == NO_PRINT)
+ continue;
+ if (strlen(p->fts_name) + chcnt +
+ (p->fts_link ? 2 : 0) >= (unsigned)termwidth) {
+ putchar('\n');
+ chcnt = 0;
+ }
+ chcnt += printaname(p, dp->s_inode, dp->s_block);
+ if (p->fts_link) {
+ printf(", ");
+ chcnt += 2;
+ }
+ }
+ if (chcnt)
+ putchar('\n');
+}
+
+void
printcol(DISPLAY *dp)
{
extern int termwidth;
@@ -282,15 +307,26 @@ printcol(DISPLAY *dp)
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
(void)printf("total %lu\n", howmany(dp->btotal, blocksize));
+
+ if (f_sortacross)
+ base = 0;
for (row = 0; row < numrows; ++row) {
endcol = colwidth;
- for (base = row, chcnt = col = 0; col < numcols; ++col) {
+ if (!f_sortacross)
+ base = row;
+ for (col = 0, chcnt = 0; col < numcols; ++col) {
chcnt += printaname(array[base], dp->s_inode,
dp->s_block);
- if ((base += numrows) >= num)
+ if (f_sortacross)
+ base++;
+ else
+ base += numrows;
+ if (base >= num)
break;
while ((cnt = ((chcnt + tabwidth) & ~(tabwidth - 1)))
<= endcol) {
+ if (f_sortacross && col + 1 >= numcols)
+ break;
(void)putchar(f_notabs ? ' ' : '\t');
chcnt = cnt;
}
@@ -364,6 +400,15 @@ printtime(time_t ftime)
static int
printtype(u_int mode)
{
+
+ if (f_slash) {
+ if ((mode & S_IFMT) == S_IFDIR) {
+ (void)putchar('/');
+ return (1);
+ }
+ return (0);
+ }
+
switch (mode & S_IFMT) {
case S_IFDIR:
(void)putchar('/');
OpenPOWER on IntegriCloud