(1) fixup getbsize() calls
(2) convert to use err(), warn(), and warnx(), as appropriate.
This commit is contained in:
parent
6ea371cbd3
commit
006b4ddd7f
|
@ -31,7 +31,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)extern.h 5.3 (Berkeley) 3/13/92
|
||||
* $Id: extern.h,v 1.2 1993/12/05 21:35:22 mycroft Exp $
|
||||
* $Id: extern.h,v 1.3 1994/01/25 20:44:48 cgd Exp $
|
||||
*/
|
||||
|
||||
int acccmp __P((const FTSENT *, const FTSENT *));
|
||||
|
@ -45,7 +45,6 @@ int revstatcmp __P((const FTSENT *, const FTSENT *));
|
|||
int sizecmp __P((const FTSENT *, const FTSENT *));
|
||||
int revsizecmp __P((const FTSENT *, const FTSENT *));
|
||||
|
||||
void err __P((int, const char *, ...));
|
||||
void prcopy __P((char *, char *, int));
|
||||
void printcol __P((DISPLAY *));
|
||||
void printlong __P((DISPLAY *));
|
||||
|
|
20
bin/ls/ls.c
20
bin/ls/ls.c
|
@ -42,7 +42,7 @@ static char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)ls.c 5.69 (Berkeley) 10/17/92";*/
|
||||
static char rcsid[] = "$Id: ls.c,v 1.8 1993/12/05 21:35:27 mycroft Exp $";
|
||||
static char rcsid[] = "$Id: ls.c,v 1.9 1994/01/25 20:44:58 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -55,10 +55,10 @@ static char rcsid[] = "$Id: ls.c,v 1.8 1993/12/05 21:35:27 mycroft Exp $";
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <err.h>
|
||||
#include "ls.h"
|
||||
#include "extern.h"
|
||||
|
||||
char *getbsize __P((char *, int *, long *, int));
|
||||
char *group_from_gid __P((u_int, int));
|
||||
char *user_from_uid __P((u_int, int));
|
||||
|
||||
|
@ -233,7 +233,8 @@ main(argc, argv)
|
|||
|
||||
/* If -l or -s, figure out block size. */
|
||||
if (f_longform || f_size) {
|
||||
(void)getbsize("ls", ¬used, &blocksize, kflag);
|
||||
if (!kflag)
|
||||
(void)getbsize(¬used, &blocksize);
|
||||
blocksize /= 512;
|
||||
}
|
||||
|
||||
|
@ -308,7 +309,7 @@ traverse(argc, argv, options)
|
|||
|
||||
if ((ftsp =
|
||||
fts_open(argv, options, f_nosort ? NULL : mastercmp)) == NULL)
|
||||
err(1, "%s", strerror(errno));
|
||||
err(1, NULL);
|
||||
|
||||
display(NULL, fts_children(ftsp, 0));
|
||||
if (f_listdir)
|
||||
|
@ -323,12 +324,11 @@ traverse(argc, argv, options)
|
|||
while (p = fts_read(ftsp))
|
||||
switch(p->fts_info) {
|
||||
case FTS_DC:
|
||||
err(0, "%s: directory causes a cycle", p->fts_name);
|
||||
warnx("%s: directory causes a cycle", p->fts_name);
|
||||
break;
|
||||
case FTS_DNR:
|
||||
case FTS_ERR:
|
||||
err(0, "%s: %s",
|
||||
p->fts_name, strerror(p->fts_errno));
|
||||
warnx("%s: %s", p->fts_name, strerror(p->fts_errno));
|
||||
break;
|
||||
case FTS_D:
|
||||
if (p->fts_level != FTS_ROOTLEVEL &&
|
||||
|
@ -398,8 +398,8 @@ display(p, list)
|
|||
maxsize = 0;
|
||||
for (cur = list, entries = 0; cur; cur = cur->fts_link) {
|
||||
if (cur->fts_info == FTS_ERR || cur->fts_info == FTS_NS) {
|
||||
err(0, "%s: %s",
|
||||
cur->fts_name, strerror(cur->fts_errno));
|
||||
warnx("%s: %s", cur->fts_name,
|
||||
strerror(cur->fts_errno));
|
||||
cur->fts_number = NO_PRINT;
|
||||
continue;
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ display(p, list)
|
|||
|
||||
if ((np = malloc(sizeof(NAMES) +
|
||||
ulen + glen + flen + 3)) == NULL)
|
||||
err(1, "%s", strerror(errno));
|
||||
err(1, NULL);
|
||||
|
||||
np->user = &np->data[0];
|
||||
(void)strcpy(np->user, user);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)print.c 5.37 (Berkeley) 7/20/92";*/
|
||||
static char rcsid[] = "$Id: print.c,v 1.7 1994/01/13 21:50:41 jtc Exp $";
|
||||
static char rcsid[] = "$Id: print.c,v 1.8 1994/01/25 20:45:08 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -52,6 +52,7 @@ static char rcsid[] = "$Id: print.c,v 1.7 1994/01/13 21:50:41 jtc Exp $";
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include "ls.h"
|
||||
#include "extern.h"
|
||||
|
||||
|
@ -160,7 +161,7 @@ printcol(dp)
|
|||
lastentries = dp->entries;
|
||||
if ((array =
|
||||
realloc(array, dp->entries * sizeof(FTSENT *))) == NULL) {
|
||||
err(0, "%s", strerror(errno));
|
||||
warn(NULL);
|
||||
printscol(dp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)util.c 5.12 (Berkeley) 3/9/92";*/
|
||||
static char rcsid[] = "$Id: util.c,v 1.6 1993/12/05 21:35:28 mycroft Exp $";
|
||||
static char rcsid[] = "$Id: util.c,v 1.7 1994/01/25 20:45:17 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -70,33 +70,3 @@ usage()
|
|||
"usage: ls [-1ACFLRSTacdfiklqrstu] [file ...]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(int fatal, const char *fmt, ...)
|
||||
#else
|
||||
err(fatal, fmt, va_alist)
|
||||
int fatal;
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "ls: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
if (fatal)
|
||||
exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue