don't core dump on filenames larger than the terminal window
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 24 Feb 1990 06:50:22 +0000 (22:50 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 24 Feb 1990 06:50:22 +0000 (22:50 -0800)
SCCS-vsn: bin/ls/print.c 5.17

usr/src/bin/ls/print.c

index b7814a6..0c65614 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.16 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    5.17 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -99,7 +99,12 @@ printcol(stats, num)
                colwidth += 5;
        if (f_type)
                colwidth += 1;
                colwidth += 5;
        if (f_type)
                colwidth += 1;
+
        colwidth = (colwidth + TAB) & ~(TAB - 1);
        colwidth = (colwidth + TAB) & ~(TAB - 1);
+       if (termwidth < 2 * colwidth) {
+               printscol(stats, num);
+               return;
+       }
 
        numcols = termwidth / colwidth;
        numrows = num / numcols;
 
        numcols = termwidth / colwidth;
        numrows = num / numcols;