Deleted Added
full compact
ls.c (46684) ls.c (49373)
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

--- 31 unchanged lines hidden (view full) ---

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
46#else
47static 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

--- 31 unchanged lines hidden (view full) ---

40 The Regents of the University of California. All rights reserved.\n";
41#endif /* not lint */
42
43#ifndef lint
44#if 0
45static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
46#else
47static const char rcsid[] =
48 "$Id: ls.c,v 1.23 1998/08/02 22:47:11 hoek Exp $";
48 "$Id: ls.c,v 1.24 1999/05/08 10:20:30 kris Exp $";
49#endif
50#endif /* not lint */
51
52#include <sys/types.h>
53#include <sys/stat.h>
54#include <sys/ioctl.h>
55
56#include <dirent.h>

--- 26 unchanged lines hidden (view full) ---

83int f_flags; /* show flags associated with a file */
84int f_inode; /* print inode */
85int f_kblocks; /* print size in kilobytes */
86int f_listdir; /* list actual directory, not contents */
87int f_listdot; /* list files beginning with . */
88int f_longform; /* long listing format */
89int f_nonprint; /* show unprintables as ? */
90int f_nosort; /* don't sort output */
49#endif
50#endif /* not lint */
51
52#include <sys/types.h>
53#include <sys/stat.h>
54#include <sys/ioctl.h>
55
56#include <dirent.h>

--- 26 unchanged lines hidden (view full) ---

83int f_flags; /* show flags associated with a file */
84int f_inode; /* print inode */
85int f_kblocks; /* print size in kilobytes */
86int f_listdir; /* list actual directory, not contents */
87int f_listdot; /* list files beginning with . */
88int f_longform; /* long listing format */
89int f_nonprint; /* show unprintables as ? */
90int f_nosort; /* don't sort output */
91int f_numericonly; /* don't convert uid/gid to name */
91int f_octal; /* show unprintables as \xxx */
92int f_octal_escape; /* like f_octal but use C escapes if possible */
93int f_recursive; /* ls subdirectories also */
94int f_reversesort; /* reverse whatever sort is used */
95int f_sectime; /* print the real time for all files */
96int f_singlecol; /* use single column output */
97int f_size; /* list size in short listing */
98int f_statustime; /* use time of last mode change */

--- 33 unchanged lines hidden (view full) ---

132 termwidth = atoi(p);
133 }
134
135 /* Root is -A automatically. */
136 if (!getuid())
137 f_listdot = 1;
138
139 fts_options = FTS_PHYSICAL;
92int f_octal; /* show unprintables as \xxx */
93int f_octal_escape; /* like f_octal but use C escapes if possible */
94int f_recursive; /* ls subdirectories also */
95int f_reversesort; /* reverse whatever sort is used */
96int f_sectime; /* print the real time for all files */
97int f_singlecol; /* use single column output */
98int f_size; /* list size in short listing */
99int f_statustime; /* use time of last mode change */

--- 33 unchanged lines hidden (view full) ---

133 termwidth = atoi(p);
134 }
135
136 /* Root is -A automatically. */
137 if (!getuid())
138 f_listdot = 1;
139
140 fts_options = FTS_PHYSICAL;
140 while ((ch = getopt(argc, argv, "1ABCFHLPRTWabcdfgikloqrstu")) != -1) {
141 while ((ch = getopt(argc, argv, "1ABCFHLPRTWabcdfgiklnoqrstu")) != -1) {
141 switch (ch) {
142 /*
143 * The -1, -C and -l options all override each other so shell
144 * aliasing works right.
145 */
146 case '1':
147 f_singlecol = 1;
148 f_column = f_longform = 0;

--- 55 unchanged lines hidden (view full) ---

204 case 'g': /* Compatibility with 4.3BSD. */
205 break;
206 case 'i':
207 f_inode = 1;
208 break;
209 case 'k':
210 f_kblocks = 1;
211 break;
142 switch (ch) {
143 /*
144 * The -1, -C and -l options all override each other so shell
145 * aliasing works right.
146 */
147 case '1':
148 f_singlecol = 1;
149 f_column = f_longform = 0;

--- 55 unchanged lines hidden (view full) ---

205 case 'g': /* Compatibility with 4.3BSD. */
206 break;
207 case 'i':
208 f_inode = 1;
209 break;
210 case 'k':
211 f_kblocks = 1;
212 break;
213 case 'n':
214 f_numericonly = 1;
215 break;
212 case 'o':
213 f_flags = 1;
214 break;
215 case 'q':
216 f_nonprint = 1;
217 f_octal = 0;
218 f_octal_escape = 0;
219 break;

--- 175 unchanged lines hidden (view full) ---

395 DISPLAY d;
396 FTSENT *cur;
397 NAMES *np;
398 u_quad_t maxsize;
399 u_long btotal, maxblock, maxinode, maxlen, maxnlink;
400 int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser;
401 char *initmax;
402 int entries, needstats;
216 case 'o':
217 f_flags = 1;
218 break;
219 case 'q':
220 f_nonprint = 1;
221 f_octal = 0;
222 f_octal_escape = 0;
223 break;

--- 175 unchanged lines hidden (view full) ---

399 DISPLAY d;
400 FTSENT *cur;
401 NAMES *np;
402 u_quad_t maxsize;
403 u_long btotal, maxblock, maxinode, maxlen, maxnlink;
404 int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser;
405 char *initmax;
406 int entries, needstats;
403 char *user, *group, *flags, buf[20]; /* 32 bits == 10 digits */
407 char *user, *group, *flags;
408 char nuser[12], ngroup[12], buf[21]; /* 32 bits == 10 digits */
404
405 /*
406 * If list is NULL there are two possibilities: that the parent
407 * directory p has no children, or that fts_children() returned an
408 * error. We ignore the error case since it will be replicated
409 * on the next call to fts_read() on the post-order visit to the
410 * directory p, and will be signaled in traverse().
411 */

--- 95 unchanged lines hidden (view full) ---

507 maxinode = sp->st_ino;
508 if (sp->st_nlink > maxnlink)
509 maxnlink = sp->st_nlink;
510 if (sp->st_size > maxsize)
511 maxsize = sp->st_size;
512
513 btotal += sp->st_blocks;
514 if (f_longform) {
409
410 /*
411 * If list is NULL there are two possibilities: that the parent
412 * directory p has no children, or that fts_children() returned an
413 * error. We ignore the error case since it will be replicated
414 * on the next call to fts_read() on the post-order visit to the
415 * directory p, and will be signaled in traverse().
416 */

--- 95 unchanged lines hidden (view full) ---

512 maxinode = sp->st_ino;
513 if (sp->st_nlink > maxnlink)
514 maxnlink = sp->st_nlink;
515 if (sp->st_size > maxsize)
516 maxsize = sp->st_size;
517
518 btotal += sp->st_blocks;
519 if (f_longform) {
515 user = user_from_uid(sp->st_uid, 0);
520 if (f_numericonly) {
521 (void)snprintf(nuser, sizeof(nuser),
522 "%u", sp->st_uid);
523 (void)snprintf(ngroup, sizeof(ngroup),
524 "%u", sp->st_gid);
525 user = nuser;
526 group = ngroup;
527 } else {
528 user = user_from_uid(sp->st_uid, 0);
529 group = group_from_gid(sp->st_gid, 0);
530 }
516 if ((ulen = strlen(user)) > maxuser)
517 maxuser = ulen;
531 if ((ulen = strlen(user)) > maxuser)
532 maxuser = ulen;
518 group = group_from_gid(sp->st_gid, 0);
519 if ((glen = strlen(group)) > maxgroup)
520 maxgroup = glen;
521 if (f_flags) {
522 flags =
523 flags_to_string(sp->st_flags, "-");
524 if ((flen = strlen(flags)) > maxflags)
525 maxflags = flen;
526 } else

--- 106 unchanged lines hidden ---
533 if ((glen = strlen(group)) > maxgroup)
534 maxgroup = glen;
535 if (f_flags) {
536 flags =
537 flags_to_string(sp->st_flags, "-");
538 if ((flen = strlen(flags)) > maxflags)
539 maxflags = flen;
540 } else

--- 106 unchanged lines hidden ---