checkpoint formatting code
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 26 Jun 1989 00:44:09 +0000 (16:44 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 26 Jun 1989 00:44:09 +0000 (16:44 -0800)
SCCS-vsn: bin/ls/print.c 5.6

usr/src/bin/ls/print.c

index b083601..164bb41 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    5.6 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -92,17 +92,15 @@ printcol(stats, num)
        int chcnt;              /* character count printed */
 
        maxlen = stats[0].lstat.st_flags;
        int chcnt;              /* character count printed */
 
        maxlen = stats[0].lstat.st_flags;
-
-       /* add fudge factors to max name length */
        if (f_inode)
                maxlen += 6;
        if (f_size)
                maxlen += 5;
        if (f_type)
                maxlen += 1;
        if (f_inode)
                maxlen += 6;
        if (f_size)
                maxlen += 5;
        if (f_type)
                maxlen += 1;
-       /* one tab after maxlen */
-       colwidth = (maxlen + 9) & ~0x7;
-       numcols = (80 + colwidth - maxlen) / colwidth;
+#define        TAB     8
+       colwidth = maxlen + TAB + 1 & ~(TAB - 1);
+       numcols = (termwidth + colwidth - maxlen) / colwidth;
        collength = (int)((float)num / (float)numcols + 0.999);
 
        for (base = 0; base < collength; base++) {
        collength = (int)((float)num / (float)numcols + 0.999);
 
        for (base = 0; base < collength; base++) {