print totals for -s flag, as well as -l
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 27 Jun 1989 03:45:53 +0000 (19:45 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 27 Jun 1989 03:45:53 +0000 (19:45 -0800)
SCCS-vsn: bin/ls/ls.h 5.6
SCCS-vsn: bin/ls/print.c 5.11

usr/src/bin/ls/ls.h
usr/src/bin/ls/print.c

index 38caa06..b92ea0e 100644 (file)
@@ -17,7 +17,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)ls.h        5.5 (Berkeley) %G%
+ *     @(#)ls.h        5.6 (Berkeley) %G%
  */
 
 typedef struct _lsstruct {
  */
 
 typedef struct _lsstruct {
@@ -26,6 +26,15 @@ typedef struct _lsstruct {
        struct stat lstat;              /* lstat(2) for file */
 } LS;
 
        struct stat lstat;              /* lstat(2) for file */
 } LS;
 
+/*
+ * overload -- we probably have to save blocks and/or maxlen with the lstat
+ * array, so tabdir() stuffs it into unused fields in the first stat structure.
+ * If there's ever a type larger than u_long, fix this.  Any calls to qsort
+ * must save and restore the values.
+ */
+#define        st_btotal       st_flags
+#define        st_maxlen       st_gen
+
 extern int errno;
 
 extern int f_accesstime;       /* use time of last access */
 extern int errno;
 
 extern int f_accesstime;       /* use time of last access */
index efa92fe..3069701 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    5.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -45,7 +45,7 @@ printlong(stats, num)
        LS *stats;
        register int num;
 {
        LS *stats;
        register int num;
 {
-       (void)printf("total %lu\n", stats[0].lstat.st_flags);
+       (void)printf("total %lu\n", stats[0].lstat.st_btotal);
        for (; num--; ++stats) {
                if (f_inode)
                        (void)printf("%6lu ", stats->lstat.st_ino);
        for (; num--; ++stats) {
                if (f_inode)
                        (void)printf("%6lu ", stats->lstat.st_ino);
@@ -87,7 +87,7 @@ printcol(stats, num)
        register int base, chcnt, cnt, col, colwidth;
        int endcol, numcols, numrows, row;
 
        register int base, chcnt, cnt, col, colwidth;
        int endcol, numcols, numrows, row;
 
-       colwidth = stats[0].lstat.st_flags;
+       colwidth = stats[0].lstat.st_maxlen;
        if (f_inode)
                colwidth += 6;
        if (f_size)
        if (f_inode)
                colwidth += 6;
        if (f_size)
@@ -101,6 +101,8 @@ printcol(stats, num)
        if (num % numcols)
                ++numrows;
 
        if (num % numcols)
                ++numrows;
 
+       if (f_size)
+               (void)printf("total %lu\n", stats[0].lstat.st_btotal);
        for (row = 0; row < numrows; ++row) {
                endcol = colwidth;
                for (base = row, chcnt = col = 0; col < numcols; ++col) {
        for (row = 0; row < numrows; ++row) {
                endcol = colwidth;
                for (base = row, chcnt = col = 0; col < numcols; ++col) {