diff options
Diffstat (limited to 'bin/ls/print.c')
-rw-r--r-- | bin/ls/print.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/bin/ls/print.c b/bin/ls/print.c index 3587d81eac6..aacf602beb2 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -1,5 +1,5 @@ -/* $OpenBSD: print.c,v 1.5 1996/12/17 18:52:52 tholo Exp $ */ -/* $NetBSD: print.c,v 1.14 1995/09/07 06:43:00 jtc Exp $ */ +/* $OpenBSD: print.c,v 1.6 1997/01/03 22:36:08 millert Exp $ */ +/* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.5 1996/12/17 18:52:52 tholo Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.6 1997/01/03 22:36:08 millert Exp $"; #endif #endif /* not lint */ @@ -59,6 +59,7 @@ static char rcsid[] = "$OpenBSD: print.c,v 1.5 1996/12/17 18:52:52 tholo Exp $"; #include <time.h> #include <tzfile.h> #include <unistd.h> +#include <utmp.h> #include "ls.h" #include "extern.h" @@ -135,8 +136,6 @@ printlong(dp) } } -#define TAB 8 - void printcol(dp) DISPLAY *dp; @@ -145,8 +144,8 @@ printcol(dp) static FTSENT **array; static int lastentries = -1; FTSENT *p; - int base, chcnt, cnt, col, colwidth, num; - int endcol, numcols, numrows, row; + int base, chcnt, col, colwidth, num; + int numcols, numrows, row; /* * Have to do random access in the linked list -- build a table @@ -172,13 +171,15 @@ printcol(dp) if (f_type) colwidth += 1; - colwidth = (colwidth + TAB) & ~(TAB - 1); + colwidth += 1; + if (termwidth < 2 * colwidth) { printscol(dp); return; } numcols = termwidth / colwidth; + colwidth = termwidth / numcols; /* spread out if possible */ numrows = num / numcols; if (num % numcols) ++numrows; @@ -186,17 +187,12 @@ printcol(dp) if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size)) (void)printf("total %lu\n", howmany(dp->btotal, blocksize)); for (row = 0; row < numrows; ++row) { - endcol = colwidth; 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_inode, dp->s_block); if ((base += numrows) >= num) break; - while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol) { - (void)putchar('\t'); - chcnt = cnt; - } - endcol += colwidth; + while (chcnt++ < colwidth) + putchar(' '); } (void)putchar('\n'); } |