X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/67d7fe00ac6f08655e924300e88ccbb8329b1894..706c03583a47e43c6d78fa613814c7bc363a0c58:/usr/src/bin/ls/print.c diff --git a/usr/src/bin/ls/print.c b/usr/src/bin/ls/print.c index 59188e5bcd..f8b947832f 100644 --- a/usr/src/bin/ls/print.c +++ b/usr/src/bin/ls/print.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Michael Fischbein. @@ -9,22 +9,25 @@ */ #ifndef lint -static char sccsid[] = "@(#)print.c 5.34 (Berkeley) %G%"; +static char sccsid[] = "@(#)print.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include -#include + +#include #include +#include #include #include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include + #include "ls.h" #include "extern.h" @@ -39,7 +42,7 @@ void printscol(dp) DISPLAY *dp; { - register FTSENT *p; + FTSENT *p; for (p = dp->list; p; p = p->fts_link) { if (IS_NOPRINT(p)) @@ -53,8 +56,8 @@ void printlong(dp) DISPLAY *dp; { - register FTSENT *p; - register struct stat *sp; + struct stat *sp; + FTSENT *p; NAMES *np; char buf[20]; @@ -68,7 +71,7 @@ printlong(dp) if (f_inode) (void)printf("%*lu ", dp->s_inode, sp->st_ino); if (f_size) - (void)printf("%*ld ", + (void)printf("%*qd ", dp->s_block, howmany(sp->st_blocks, blocksize)); (void)strmode(sp->st_mode, buf); np = p->fts_pointer; @@ -80,6 +83,9 @@ printlong(dp) if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode)) (void)printf("%3d, %3d ", major(sp->st_rdev), minor(sp->st_rdev)); + else if (dp->bcfile) + (void)printf("%*s%*qd ", + 8 - dp->s_size, "", dp->s_size, sp->st_size); else (void)printf("%*qd ", dp->s_size, sp->st_size); if (f_accesstime) @@ -106,8 +112,8 @@ printcol(dp) extern int termwidth; static FTSENT **array; static int lastentries = -1; - register FTSENT *p; - register int base, chcnt, cnt, col, colwidth, num; + FTSENT *p; + int base, chcnt, cnt, col, colwidth, num; int endcol, numcols, numrows, row; /* @@ -118,7 +124,7 @@ printcol(dp) lastentries = dp->entries; if ((array = realloc(array, dp->entries * sizeof(FTSENT *))) == NULL) { - err(0, "%s", strerror(errno)); + warn(NULL); printscol(dp); } } @@ -170,7 +176,7 @@ printcol(dp) */ static int printaname(p, inodefield, sizefield) - register FTSENT *p; + FTSENT *p; u_long sizefield, inodefield; { struct stat *sp; @@ -179,10 +185,10 @@ printaname(p, inodefield, sizefield) sp = p->fts_statp; chcnt = 0; if (f_inode) - chcnt += printf("%*lu ", inodefield, sp->st_ino); + chcnt += printf("%*lu ", (int)inodefield, sp->st_ino); if (f_size) - chcnt += printf("%*ld ", - sizefield, howmany(sp->st_blocks, blocksize)); + chcnt += printf("%*qd ", + (int)sizefield, howmany(sp->st_blocks, blocksize)); chcnt += printf("%s", p->fts_name); if (f_type) chcnt += printtype(sp->st_mode); @@ -246,11 +252,10 @@ printlink(p) if (p->fts_level == FTS_ROOTLEVEL) (void)snprintf(name, sizeof(name), "%s", p->fts_name); - else + else (void)snprintf(name, sizeof(name), - "%s/%s", p->fts_parent->fts_name, p->fts_name); - - if ((lnklen = readlink(name, path, sizeof(name) - 1)) == -1) { + "%s/%s", p->fts_parent->fts_accpath, p->fts_name); + if ((lnklen = readlink(name, path, sizeof(path) - 1)) == -1) { (void)fprintf(stderr, "\nls: %s: %s\n", name, strerror(errno)); return; }