print.c (35417) | print.c (37932) |
---|---|
1/* 2 * Copyright (c) 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Michael Fischbein. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94"; 40#else 41static const char rcsid[] = | 1/* 2 * Copyright (c) 1989, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Michael Fischbein. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94"; 40#else 41static const char rcsid[] = |
42 "$Id: print.c,v 1.15 1998/04/21 22:02:01 des Exp $"; | 42 "$Id: print.c,v 1.16 1998/04/24 07:49:50 des Exp $"; |
43#endif 44#endif /* not lint */ 45 46#include <sys/param.h> 47#include <sys/stat.h> 48 49#include <err.h> 50#include <errno.h> --- 81 unchanged lines hidden (view full) --- 132 if (f_type) 133 (void)printtype(sp->st_mode); 134 if (S_ISLNK(sp->st_mode)) 135 printlink(p); 136 (void)putchar('\n'); 137 } 138} 139 | 43#endif 44#endif /* not lint */ 45 46#include <sys/param.h> 47#include <sys/stat.h> 48 49#include <err.h> 50#include <errno.h> --- 81 unchanged lines hidden (view full) --- 132 if (f_type) 133 (void)printtype(sp->st_mode); 134 if (S_ISLNK(sp->st_mode)) 135 printlink(p); 136 (void)putchar('\n'); 137 } 138} 139 |
140#define TAB 8 141 | |
142void 143printcol(dp) 144 DISPLAY *dp; 145{ 146 extern int termwidth; 147 static FTSENT **array; 148 static int lastentries = -1; 149 FTSENT *p; 150 int base, chcnt, cnt, col, colwidth, num; 151 int endcol, numcols, numrows, row; | 140void 141printcol(dp) 142 DISPLAY *dp; 143{ 144 extern int termwidth; 145 static FTSENT **array; 146 static int lastentries = -1; 147 FTSENT *p; 148 int base, chcnt, cnt, col, colwidth, num; 149 int endcol, numcols, numrows, row; |
150 int tabwidth; |
|
152 | 151 |
152 if (f_notabs) 153 tabwidth = 1; 154 else 155 tabwidth = 8; 156 |
|
153 /* 154 * Have to do random access in the linked list -- build a table 155 * of pointers. 156 */ 157 if (dp->entries > lastentries) { 158 lastentries = dp->entries; 159 if ((array = 160 realloc(array, dp->entries * sizeof(FTSENT *))) == NULL) { --- 8 unchanged lines hidden (view full) --- 169 colwidth = dp->maxlen; 170 if (f_inode) 171 colwidth += dp->s_inode + 1; 172 if (f_size) 173 colwidth += dp->s_block + 1; 174 if (f_type) 175 colwidth += 1; 176 | 157 /* 158 * Have to do random access in the linked list -- build a table 159 * of pointers. 160 */ 161 if (dp->entries > lastentries) { 162 lastentries = dp->entries; 163 if ((array = 164 realloc(array, dp->entries * sizeof(FTSENT *))) == NULL) { --- 8 unchanged lines hidden (view full) --- 173 colwidth = dp->maxlen; 174 if (f_inode) 175 colwidth += dp->s_inode + 1; 176 if (f_size) 177 colwidth += dp->s_block + 1; 178 if (f_type) 179 colwidth += 1; 180 |
177 colwidth = (colwidth + TAB) & ~(TAB - 1); | 181 colwidth = (colwidth + tabwidth) & ~(tabwidth - 1); |
178 if (termwidth < 2 * colwidth) { 179 printscol(dp); 180 return; 181 } 182 183 numcols = termwidth / colwidth; 184 numrows = num / numcols; 185 if (num % numcols) 186 ++numrows; 187 188 if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size)) 189 (void)printf("total %lu\n", howmany(dp->btotal, blocksize)); 190 for (row = 0; row < numrows; ++row) { 191 endcol = colwidth; 192 for (base = row, chcnt = col = 0; col < numcols; ++col) { 193 chcnt += printaname(array[base], dp->s_inode, 194 dp->s_block); 195 if ((base += numrows) >= num) 196 break; | 182 if (termwidth < 2 * colwidth) { 183 printscol(dp); 184 return; 185 } 186 187 numcols = termwidth / colwidth; 188 numrows = num / numcols; 189 if (num % numcols) 190 ++numrows; 191 192 if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size)) 193 (void)printf("total %lu\n", howmany(dp->btotal, blocksize)); 194 for (row = 0; row < numrows; ++row) { 195 endcol = colwidth; 196 for (base = row, chcnt = col = 0; col < numcols; ++col) { 197 chcnt += printaname(array[base], dp->s_inode, 198 dp->s_block); 199 if ((base += numrows) >= num) 200 break; |
197 while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){ 198 (void)putchar('\t'); | 201 while ((cnt = ((chcnt + tabwidth) & ~(tabwidth - 1))) 202 <= endcol){ 203 (void)putchar(f_notabs ? ' ' : '\t'); |
199 chcnt = cnt; 200 } 201 endcol += colwidth; 202 } 203 (void)putchar('\n'); 204 } 205} 206 --- 107 unchanged lines hidden --- | 204 chcnt = cnt; 205 } 206 endcol += colwidth; 207 } 208 (void)putchar('\n'); 209 } 210} 211 --- 107 unchanged lines hidden --- |