From: Jan-Simon Pendry Date: Fri, 1 Apr 1994 20:20:35 +0000 (-0800) Subject: prettyness police X-Git-Tag: BSD-4_4_Lite1-Snapshot-Development~29 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/706c03583a47e43c6d78fa613814c7bc363a0c58 prettyness police SCCS-vsn: bin/ls/util.c 8.2 SCCS-vsn: bin/ls/print.c 8.2 SCCS-vsn: bin/ls/ls.c 8.2 SCCS-vsn: bin/pwd/pwd.c 8.3 SCCS-vsn: bin/rm/rm.c 8.3 SCCS-vsn: bin/rmdir/rmdir.c 8.2 SCCS-vsn: bin/sleep/sleep.c 8.2 SCCS-vsn: bin/stty/stty.c 8.2 SCCS-vsn: bin/stty/key.c 8.2 SCCS-vsn: bin/stty/cchar.c 8.4 SCCS-vsn: bin/stty/gfmt.c 8.5 SCCS-vsn: bin/stty/modes.c 8.2 SCCS-vsn: bin/stty/print.c 8.4 SCCS-vsn: bin/stty/util.c 8.2 SCCS-vsn: bin/test/test.c 8.2 SCCS-vsn: bin/test/operators.c 8.2 SCCS-vsn: bin/test/operators.h 8.2 SCCS-vsn: usr.bin/apropos/apropos.c 8.6 SCCS-vsn: usr.bin/ar/misc.c 8.2 SCCS-vsn: usr.bin/ar/print.c 8.2 SCCS-vsn: usr.bin/ar/archive.h 8.2 SCCS-vsn: usr.bin/ar/contents.c 8.2 SCCS-vsn: usr.bin/ar/move.c 8.2 SCCS-vsn: usr.bin/ar/delete.c 8.2 SCCS-vsn: usr.bin/ar/extract.c 8.2 SCCS-vsn: usr.bin/ar/ar.c 8.2 SCCS-vsn: usr.bin/ar/append.c 8.2 SCCS-vsn: usr.bin/ar/archive.c 8.2 SCCS-vsn: usr.bin/ar/replace.c 8.2 SCCS-vsn: usr.bin/ar/extern.h 8.2 SCCS-vsn: usr.bin/banner/banner.c 8.2 SCCS-vsn: usr.bin/basename/basename.c 8.2 --- diff --git a/usr/src/bin/ls/ls.c b/usr/src/bin/ls/ls.c index fd3ae6a3a3..0c49aa4561 100644 --- a/usr/src/bin/ls/ls.c +++ b/usr/src/bin/ls/ls.c @@ -15,7 +15,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)ls.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)ls.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -79,7 +79,7 @@ main(argc, argv) if (isatty(STDOUT_FILENO)) { if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 || !win.ws_col) { - if (p = getenv("COLUMNS")) + if ((p = getenv("COLUMNS")) != NULL) termwidth = atoi(p); } else @@ -246,8 +246,8 @@ traverse(argc, argv, options) int argc, options; char *argv[]; { - register FTS *ftsp; - register FTSENT *p, *chp; + FTS *ftsp; + FTSENT *p, *chp; int ch_options; if ((ftsp = @@ -264,7 +264,7 @@ traverse(argc, argv, options) */ ch_options = !f_recursive && options & FTS_NOSTAT ? FTS_NAMEONLY : 0; - while (p = fts_read(ftsp)) + while ((p = fts_read(ftsp)) != NULL) switch (p->fts_info) { case FTS_DC: warnx("%s: directory causes a cycle", p->fts_name); @@ -308,15 +308,14 @@ traverse(argc, argv, options) */ static void display(p, list) - register FTSENT *p; - FTSENT *list; + FTSENT *p, *list; { - register FTSENT *cur; struct stat *sp; DISPLAY d; + FTSENT *cur; NAMES *np; - u_long btotal, maxblock, maxinode, maxlen, maxnlink; u_quad_t maxsize; + u_long btotal, maxblock, maxinode, maxlen, maxnlink; int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser; int entries, needstats; char *user, *group, *flags, buf[20]; /* 32 bits == 10 digits */ @@ -456,7 +455,7 @@ static int mastercmp(a, b) const FTSENT **a, **b; { - register int a_info, b_info; + int a_info, b_info; a_info = (*a)->fts_info; if (a_info == FTS_ERR) diff --git a/usr/src/bin/ls/print.c b/usr/src/bin/ls/print.c index 2d7cfc0be9..f8b947832f 100644 --- a/usr/src/bin/ls/print.c +++ b/usr/src/bin/ls/print.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)print.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)print.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -42,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)) @@ -56,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]; @@ -112,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; /* @@ -176,7 +176,7 @@ printcol(dp) */ static int printaname(p, inodefield, sizefield) - register FTSENT *p; + FTSENT *p; u_long sizefield, inodefield; { struct stat *sp; diff --git a/usr/src/bin/ls/util.c b/usr/src/bin/ls/util.c index a8846b3ca8..4ad8bc57fc 100644 --- a/usr/src/bin/ls/util.c +++ b/usr/src/bin/ls/util.c @@ -9,7 +9,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)util.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)util.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -26,12 +26,12 @@ static char sccsid[] = "@(#)util.c 8.1 (Berkeley) %G%"; void prcopy(src, dest, len) - register char *src, *dest; - register int len; + char *src, *dest; + int len; { - register int ch; + int ch; - while(len--) { + while (len--) { ch = *src++; *dest++ = isprint(ch) ? ch : '?'; } diff --git a/usr/src/bin/pwd/pwd.c b/usr/src/bin/pwd/pwd.c index 33a5eae26b..bf45019cfd 100644 --- a/usr/src/bin/pwd/pwd.c +++ b/usr/src/bin/pwd/pwd.c @@ -12,16 +12,12 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)pwd.c 8.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)pwd.c 8.3 (Berkeley) %G%"; #endif /* not lint */ -#include - #include -#include #include #include -#include #include void usage __P((void)); @@ -64,6 +60,7 @@ main(argc, argv) void usage() { + (void)fprintf(stderr, "usage: pwd\n"); exit(1); } diff --git a/usr/src/bin/rm/rm.c b/usr/src/bin/rm/rm.c index 0f7e90b5ef..24b4eb3cc3 100644 --- a/usr/src/bin/rm/rm.c +++ b/usr/src/bin/rm/rm.c @@ -12,14 +12,14 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)rm.c 8.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)rm.c 8.3 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include #include +#include #include #include #include @@ -46,7 +46,6 @@ main(argc, argv) int argc; char *argv[]; { - extern int optind; int ch, rflag; rflag = 0; @@ -94,9 +93,9 @@ void rmtree(argv) char **argv; { - register FTS *fts; - register FTSENT *p; - register int needstat; + FTS *fts; + FTSENT *p; + int needstat; /* * Remove a file hierarchy. If forcing removal (-f), or interactive @@ -178,8 +177,8 @@ void rmfile(argv) char **argv; { - register int df; - register char *f; + int df; + char *f; struct stat sb; df = dflag; @@ -216,7 +215,7 @@ check(path, name, sp) char *path, *name; struct stat *sp; { - register int first, ch; + int ch, first; char modep[15]; /* Check -i first. */ @@ -250,7 +249,7 @@ void checkdot(argv) char **argv; { - register char *p, **t, **save; + char *p, **save, **t; int complained; complained = 0; @@ -273,6 +272,7 @@ checkdot(argv) void usage() { + (void)fprintf(stderr, "usage: rm [-dfiRr] file ...\n"); exit(1); } diff --git a/usr/src/bin/rmdir/rmdir.c b/usr/src/bin/rmdir/rmdir.c index c364478921..25bd532b60 100644 --- a/usr/src/bin/rmdir/rmdir.c +++ b/usr/src/bin/rmdir/rmdir.c @@ -12,7 +12,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)rmdir.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)rmdir.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -54,6 +54,7 @@ main(argc, argv) void usage() { + (void)fprintf(stderr, "usage: rmdir directory ...\n"); exit(1); } diff --git a/usr/src/bin/sleep/sleep.c b/usr/src/bin/sleep/sleep.c index cb5944c687..714468bce3 100644 --- a/usr/src/bin/sleep/sleep.c +++ b/usr/src/bin/sleep/sleep.c @@ -12,12 +12,12 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)sleep.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)sleep.c 8.2 (Berkeley) %G%"; #endif /* not lint */ -#include #include #include +#include void usage __P((void)); @@ -48,6 +48,7 @@ main(argc, argv) void usage() { + (void)fprintf(stderr, "usage: sleep seconds\n"); exit(1); } diff --git a/usr/src/bin/stty/cchar.c b/usr/src/bin/stty/cchar.c index 638ff95b3c..b9b547aafe 100644 --- a/usr/src/bin/stty/cchar.c +++ b/usr/src/bin/stty/cchar.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)cchar.c 8.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)cchar.c 8.4 (Berkeley) %G%"; #endif /* not lint */ #include @@ -56,16 +56,22 @@ struct cchar cchars2[] = { { NULL }, }; +static int +c_cchar(a, b) + const void *a, *b; +{ + + return (strcmp(((struct cchar *)a)->name, ((struct cchar *)b)->name)); +} + int csearch(argvp, ip) char ***argvp; struct info *ip; { - register struct cchar *cp; - struct cchar tmp; + struct cchar *cp, tmp; long val; char *arg, *ep, *name; - static int c_cchar __P((const void *, const void *)); name = **argvp; @@ -111,10 +117,3 @@ csearch(argvp, ip) ip->set = 1; return (1); } - -static int -c_cchar(a, b) - const void *a, *b; -{ - return (strcmp(((struct cchar *)a)->name, ((struct cchar *)b)->name)); -} diff --git a/usr/src/bin/stty/gfmt.c b/usr/src/bin/stty/gfmt.c index 339240c083..c29a96c212 100644 --- a/usr/src/bin/stty/gfmt.c +++ b/usr/src/bin/stty/gfmt.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)gfmt.c 8.4 (Berkeley) %G%"; +static char sccsid[] = "@(#)gfmt.c 8.5 (Berkeley) %G%"; #endif /* not lint */ #include @@ -18,7 +18,15 @@ static char sccsid[] = "@(#)gfmt.c 8.4 (Berkeley) %G%"; #include "stty.h" #include "extern.h" -static void gerr __P((char *)); +static void +gerr(s) + char *s; +{ + if (s) + errx(1, "illegal gfmt1 option -- %s", s); + else + errx(1, "illegal gfmt1 option"); +} void gprint(tp, wp, ldisc) @@ -26,7 +34,7 @@ gprint(tp, wp, ldisc) struct winsize *wp; int ldisc; { - register struct cchar *cp; + struct cchar *cp; (void)printf("gfmt1:cflag=%x:iflag=%x:lflag=%x:oflag=%x:", tp->c_cflag, tp->c_iflag, tp->c_lflag, tp->c_oflag); @@ -37,11 +45,11 @@ gprint(tp, wp, ldisc) void gread(tp, s) - register struct termios *tp; + struct termios *tp; char *s; { - register char *ep, *p; - register struct cchar *cp; + struct cchar *cp; + char *ep, *p; long tmp; if ((s = strchr(s, ':')) == NULL) @@ -93,13 +101,3 @@ gread(tp, s) gerr(p); } } - -static void -gerr(s) - char *s; -{ - if (s) - errx(1, "illegal gfmt1 option -- %s", s); - else - errx(1, "illegal gfmt1 option"); -} diff --git a/usr/src/bin/stty/key.c b/usr/src/bin/stty/key.c index 3b88f8c00a..fdbdbc64ee 100644 --- a/usr/src/bin/stty/key.c +++ b/usr/src/bin/stty/key.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)key.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)key.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -66,15 +66,21 @@ static struct key { { "tty", f_tty, 0 }, }; +static int +c_key(a, b) + const void *a, *b; +{ + + return (strcmp(((struct key *)a)->name, ((struct key *)b)->name)); +} + int ksearch(argvp, ip) char ***argvp; struct info *ip; { - register struct key *kp; - register char *name; - struct key tmp; - static int c_key __P((const void *, const void *)); + char *name; + struct key *kp, tmp; name = **argvp; if (*name == '-') { @@ -99,13 +105,6 @@ ksearch(argvp, ip) return (1); } -static int -c_key(a, b) - const void *a, *b; -{ - return (strcmp(((struct key *)a)->name, ((struct key *)b)->name)); -} - void f_all(ip) struct info *ip; @@ -117,6 +116,7 @@ void f_cbreak(ip) struct info *ip; { + if (ip->off) f_sane(ip); else { @@ -132,6 +132,7 @@ void f_columns(ip) struct info *ip; { + ip->win.ws_col = atoi(ip->arg); ip->wset = 1; } @@ -140,6 +141,7 @@ void f_dec(ip) struct info *ip; { + ip->t.c_cc[VERASE] = (u_char)0177; ip->t.c_cc[VKILL] = CTRL('u'); ip->t.c_cc[VINTR] = CTRL('c'); @@ -153,6 +155,7 @@ void f_everything(ip) struct info *ip; { + print(&ip->t, &ip->win, ip->ldisc, BSD); } @@ -160,13 +163,12 @@ void f_extproc(ip) struct info *ip; { - int tmp; if (ip->set) { - tmp = 1; + int tmp = 1; (void)ioctl(ip->fd, TIOCEXT, &tmp); } else { - tmp = 0; + int tmp = 0; (void)ioctl(ip->fd, TIOCEXT, &tmp); } } @@ -175,6 +177,7 @@ void f_ispeed(ip) struct info *ip; { + cfsetispeed(&ip->t, atoi(ip->arg)); ip->set = 1; } @@ -183,6 +186,7 @@ void f_nl(ip) struct info *ip; { + if (ip->off) { ip->t.c_iflag |= ICRNL; ip->t.c_oflag |= ONLCR; @@ -197,6 +201,7 @@ void f_ospeed(ip) struct info *ip; { + cfsetospeed(&ip->t, atoi(ip->arg)); ip->set = 1; } @@ -205,6 +210,7 @@ void f_raw(ip) struct info *ip; { + if (ip->off) f_sane(ip); else { @@ -219,6 +225,7 @@ void f_rows(ip) struct info *ip; { + ip->win.ws_row = atoi(ip->arg); ip->wset = 1; } @@ -227,6 +234,7 @@ void f_sane(ip) struct info *ip; { + ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & CLOCAL); ip->t.c_iflag = TTYDEF_IFLAG; ip->t.c_iflag |= ICRNL; @@ -241,6 +249,7 @@ void f_size(ip) struct info *ip; { + (void)printf("%d %d\n", ip->win.ws_row, ip->win.ws_col); } @@ -248,6 +257,7 @@ void f_speed(ip) struct info *ip; { + (void)printf("%d\n", cfgetospeed(&ip->t)); } diff --git a/usr/src/bin/stty/modes.c b/usr/src/bin/stty/modes.c index 29ca482149..4c144d4a60 100644 --- a/usr/src/bin/stty/modes.c +++ b/usr/src/bin/stty/modes.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)modes.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)modes.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -167,8 +167,8 @@ msearch(argvp, ip) char ***argvp; struct info *ip; { - register struct modes *mp; - register char *name; + struct modes *mp; + char *name; name = **argvp; diff --git a/usr/src/bin/stty/print.c b/usr/src/bin/stty/print.c index cbd1b7db81..69b96ff970 100644 --- a/usr/src/bin/stty/print.c +++ b/usr/src/bin/stty/print.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)print.c 8.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)print.c 8.4 (Berkeley) %G%"; #endif /* not lint */ #include @@ -29,11 +29,10 @@ print(tp, wp, ldisc, fmt) int ldisc; enum FMT fmt; { - register struct cchar *p; - register long tmp; - register int cnt; - register u_char *cc; - int ispeed, ospeed; + struct cchar *p; + long tmp; + u_char *cc; + int cnt, ispeed, ospeed; char buf1[100], buf2[100]; cnt = 0; @@ -180,6 +179,7 @@ static void binit(lb) char *lb; { + if (col) { (void)printf("\n"); col = 0; @@ -191,6 +191,7 @@ static void bput(s) char *s; { + if (col == 0) { col = printf("%s: %s", label, s); return; diff --git a/usr/src/bin/stty/stty.c b/usr/src/bin/stty/stty.c index 3e9ae15c71..7dcda3c207 100644 --- a/usr/src/bin/stty/stty.c +++ b/usr/src/bin/stty/stty.c @@ -12,7 +12,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)stty.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)stty.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -129,7 +129,7 @@ args: argc -= optind; void usage() { - (void)fprintf(stderr, - "usage: stty: [-a|-e|-g] [-f file] [options]\n"); + + (void)fprintf(stderr, "usage: stty: [-a|-e|-g] [-f file] [options]\n"); exit (1); } diff --git a/usr/src/bin/stty/util.c b/usr/src/bin/stty/util.c index 8bd01fdb81..450147fd04 100644 --- a/usr/src/bin/stty/util.c +++ b/usr/src/bin/stty/util.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)util.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)util.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include diff --git a/usr/src/bin/test/operators.c b/usr/src/bin/test/operators.c index 7adb8c0b2e..e2ae17cdfd 100644 --- a/usr/src/bin/test/operators.c +++ b/usr/src/bin/test/operators.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)operators.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)operators.c 8.2 (Berkeley) %G%"; #endif /* not lint */ /* @@ -17,7 +17,7 @@ static char sccsid[] = "@(#)operators.c 8.1 (Berkeley) %G%"; #include "operators.h" -char *const unary_op[] = { +const char *const unary_op[] = { "!", "-b", "-c", @@ -39,7 +39,7 @@ char *const unary_op[] = { NULL }; -char *const binary_op[] = { +const char *const binary_op[] = { "-o", "|", "-a", diff --git a/usr/src/bin/test/operators.h b/usr/src/bin/test/operators.h index e629f4aaae..01843b3608 100644 --- a/usr/src/bin/test/operators.h +++ b/usr/src/bin/test/operators.h @@ -4,7 +4,7 @@ * * %sccs.include.redist.c% * - * @(#)operators.h 8.1 (Berkeley) %G% + * @(#)operators.h 8.2 (Berkeley) %G% */ #define NOT 0 @@ -45,7 +45,7 @@ #define OP_STRING 2 /* arguments to operator are string */ #define OP_FILE 3 /* argument is a file name */ -extern char *const unary_op[]; -extern char *const binary_op[]; +extern const char *const unary_op[]; +extern const char *const binary_op[]; extern const char op_priority[]; extern const char op_argflag[]; diff --git a/usr/src/bin/test/test.c b/usr/src/bin/test/test.c index 108d464426..b6b8080580 100644 --- a/usr/src/bin/test/test.c +++ b/usr/src/bin/test/test.c @@ -15,7 +15,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)test.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)test.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include @@ -69,7 +69,7 @@ struct filestat { static int expr_is_false __P((struct value *)); static void expr_operator __P((int, struct value *, struct filestat *)); static void get_int __P((char *, long *)); -static int lookup_op __P((char *, char *const *)); +static int lookup_op __P((char *, const char *const *)); static void overflow __P((void)); static int posix_binary_op __P((char **)); static int posix_unary_op __P((char **)); @@ -274,6 +274,7 @@ static int expr_is_false(val) struct value *val; { + if (val->type == STRING) { if (val->u.string[0] == '\0') return (1); @@ -425,11 +426,11 @@ filebit: if (fs->stat.st_mode & i && fs->rcode >= 0) static int lookup_op(name, table) - char *name; - char *const * table; + char *name; + const char *const * table; { - register char *const * tp; - register char const *p; + const char *const * tp; + const char *p; char c; c = name[1]; @@ -521,11 +522,13 @@ get_int(v, lp) static void syntax() { + err(2, "syntax error"); } static void overflow() { + err(2, "expression is too complex"); } diff --git a/usr/src/usr.bin/apropos/apropos.c b/usr/src/usr.bin/apropos/apropos.c index 15294a0f00..6087f5235b 100644 --- a/usr/src/usr.bin/apropos/apropos.c +++ b/usr/src/usr.bin/apropos/apropos.c @@ -12,7 +12,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)apropos.c 8.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)apropos.c 8.6 (Berkeley) %G%"; #endif /* not lint */ #include @@ -20,6 +20,7 @@ static char sccsid[] = "@(#)apropos.c 8.5 (Berkeley) %G%"; #include #include +#include #include #include #include @@ -27,17 +28,18 @@ static char sccsid[] = "@(#)apropos.c 8.5 (Berkeley) %G%"; #include "../man/config.h" #include "../man/pathnames.h" -#define MAXLINELEN 1024 /* max line handled */ - static int *found, foundman; +void apropos __P((char **, char *, int)); +void lowstr __P((char *, char *)); +int match __P((char *, char *)); +void usage __P((void)); + int main(argc, argv) int argc; char *argv[]; { - extern char *optarg; - extern int optind; ENTRY *ep; TAG *tp; int ch, rv; @@ -86,11 +88,9 @@ main(argc, argv) apropos(argv, ep->s, 0); } - if (!foundman) { - (void)fprintf(stderr, - "apropos: no %s file found.\n", _PATH_WHATIS); - exit(1); - } + if (!foundman) + errx(1, "no %s file found", _PATH_WHATIS); + rv = 1; for (p = argv; *p; ++p) if (found[p - argv]) @@ -100,15 +100,16 @@ main(argc, argv) exit(rv); } +void apropos(argv, path, buildpath) char **argv, *path; int buildpath; { - register char *end, *name, **p; - char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1]; + char *end, *name, **p; + char buf[LINE_MAX + 1], wbuf[LINE_MAX + 1]; for (name = path; name; name = end) { /* through name list */ - if (end = index(name, ':')) + if (end = strchr(name, ':')) *end++ = '\0'; if (buildpath) { @@ -125,9 +126,8 @@ apropos(argv, path, buildpath) /* for each file found */ while (fgets(buf, sizeof(buf), stdin)) { - if (!index(buf, '\n')) { - (void)fprintf(stderr, - "apropos: %s line too long.\n", name); + if (!strchr(buf, '\n')) { + warnx("%s: line too long", name); continue; } lowstr(buf, wbuf); @@ -150,31 +150,33 @@ apropos(argv, path, buildpath) * match -- * match anywhere the string appears */ +int match(bp, str) - register char *bp, *str; + char *bp, *str; { - register int len; - register char test; + int len; + char test; if (!*bp) - return(0); + return (0); /* backward compatible: everything matches empty string */ if (!*str) - return(1); + return (1); for (test = *str++, len = strlen(str); *bp;) if (test == *bp++ && !strncmp(bp, str, len)) - return(1); - return(0); + return (1); + return (0); } /* * lowstr -- * convert a string to lower case */ +void lowstr(from, to) - register char *from, *to; + char *from, *to; { - register char ch; + char ch; while ((ch = *from++) && ch != '\n') *to++ = isupper(ch) ? tolower(ch) : ch; @@ -185,8 +187,10 @@ lowstr(from, to) * usage -- * print usage message and die */ +void usage() { + (void)fprintf(stderr, "usage: apropos [-C file] [-M path] [-m path] keyword ...\n"); exit(1); diff --git a/usr/src/usr.bin/ar/append.c b/usr/src/usr.bin/ar/append.c index 3b625fc8f0..8038ba9976 100644 --- a/usr/src/usr.bin/ar/append.c +++ b/usr/src/usr.bin/ar/append.c @@ -9,35 +9,35 @@ */ #ifndef lint -static char sccsid[] = "@(#)append.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)append.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include + +#include #include #include #include #include #include + #include "archive.h" #include "extern.h" -extern char *archive; /* archive name */ - /* * append -- * Append files to the archive - modifies original archive or creates * a new archive if named archive does not exist. */ +int append(argv) char **argv; { - register int fd, afd; - register char *file; - struct stat sb; + int afd, fd, eval; + char *file; CF cf; - int eval; + struct stat sb; afd = open_archive(O_CREAT|O_RDWR); if (lseek(afd, (off_t)0, SEEK_END) == (off_t)-1) @@ -47,8 +47,7 @@ append(argv) SETCF(0, 0, afd, archive, WPAD); for (eval = 0; file = *argv++;) { if ((fd = open(file, O_RDONLY)) < 0) { - (void)fprintf(stderr, - "ar: %s: %s.\n", file, strerror(errno)); + warn("%s", file); eval = 1; continue; } @@ -60,5 +59,5 @@ append(argv) (void)close(fd); } close_archive(afd); - return(eval); + return (eval); } diff --git a/usr/src/usr.bin/ar/ar.c b/usr/src/usr.bin/ar/ar.c index 2eb55c33d7..2653f3d7da 100644 --- a/usr/src/usr.bin/ar/ar.c +++ b/usr/src/usr.bin/ar/ar.c @@ -15,24 +15,28 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)ar.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)ar.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include -#include + +#include #include +#include +#include #include -#include -#include #include -#include +#include +#include + #include "archive.h" #include "extern.h" CHDR chdr; u_int options; char *archive, *envtmp, *posarg, *posname; -static void badoptions(), usage(); +static void badoptions __P((char *)); +static void usage __P((void)); /* * main -- @@ -40,15 +44,14 @@ static void badoptions(), usage(); * functions. Some hacks that let us be backward compatible with 4.3 ar * option parsing and sanity checking. */ +int main(argc, argv) int argc; char **argv; { - extern int optind; int c; char *p; - int (*fcall)(), append(), contents(), delete(), extract(), - move(), print(), replace(); + int (*fcall) __P((char **)); if (argc < 3) usage(); @@ -58,10 +61,8 @@ main(argc, argv) * Fix it, if necessary. */ if (*argv[1] != '-') { - if (!(p = malloc((u_int)(strlen(argv[1]) + 2)))) { - (void)fprintf(stderr, "ar: %s.\n", strerror(errno)); - exit(1); - } + if (!(p = malloc((u_int)(strlen(argv[1]) + 2)))) + err(1, NULL); *p = '-'; (void)strcpy(p + 1, argv[1]); argv[1] = p; @@ -132,21 +133,18 @@ main(argc, argv) /* One of -dmpqrtx required. */ if (!(options & (AR_D|AR_M|AR_P|AR_Q|AR_R|AR_T|AR_X))) { - (void)fprintf(stderr, - "ar: one of options -dmpqrtx is required.\n"); + warnx("one of options -dmpqrtx is required"); usage(); } /* Only one of -a and -bi allowed. */ if (options & AR_A && options & AR_B) { - (void)fprintf(stderr, - "ar: only one of -a and -[bi] options allowed.\n"); + warnx("only one of -a and -[bi] options allowed"); usage(); } /* -ab require a position argument. */ if (options & (AR_A|AR_B)) { if (!(posarg = *argv++)) { - (void)fprintf(stderr, - "ar: no position operand specified.\n"); + warnx("no position operand specified"); usage(); } posname = rname(posarg); @@ -174,13 +172,13 @@ main(argc, argv) badoptions("-x"); if (!(archive = *argv++)) { - (void)fprintf(stderr, "ar: no archive specified.\n"); + warnx("no archive specified"); usage(); } /* -dmqr require a list of archive elements. */ if (options & (AR_D|AR_M|AR_Q|AR_R) && !*argv) { - (void)fprintf(stderr, "ar: no archive members specified.\n"); + warnx("no archive members specified"); usage(); } @@ -191,14 +189,15 @@ static void badoptions(arg) char *arg; { - (void)fprintf(stderr, - "ar: illegal option combination for %s.\n", arg); + + warnx("illegal option combination for %s", arg); usage(); } static void usage() { + (void)fprintf(stderr, "usage: ar -d [-Tv] archive file ...\n"); (void)fprintf(stderr, "\tar -m [-Tv] archive file ...\n"); (void)fprintf(stderr, "\tar -m [-abiTv] position archive file ...\n"); diff --git a/usr/src/usr.bin/ar/archive.c b/usr/src/usr.bin/ar/archive.c index 4ad06760b1..59dfb6a9c4 100644 --- a/usr/src/usr.bin/ar/archive.c +++ b/usr/src/usr.bin/ar/archive.c @@ -9,28 +9,29 @@ */ #ifndef lint -static char sccsid[] = "@(#)archive.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)archive.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include -#include -#include -#include + #include +#include +#include +#include +#include #include #include #include +#include + #include "archive.h" #include "extern.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ - typedef struct ar_hdr HDR; static char hb[sizeof(HDR) + 1]; /* real header */ +int open_archive(mode) int mode; { @@ -43,8 +44,7 @@ open_archive(mode) if ((fd = open(archive, mode, DEFFILEMODE)) >= 0) { /* POSIX.2 puts create message on stderr. */ if (!(options & AR_C)) - (void)fprintf(stderr, - "ar: creating archive %s.\n", archive); + warnx("creating archive %s", archive); created = 1; goto opened; } @@ -77,19 +77,20 @@ opened: if (flock(fd, LOCK_EX|LOCK_NB) && errno != EOPNOTSUPP) badfmt(); } else if (write(fd, ARMAG, SARMAG) != SARMAG) error(archive); - return(fd); + return (fd); } void close_archive(fd) int fd; { + (void)close(fd); /* Implicit unlock. */ } /* Convert ar header field to an integer. */ #define AR_ATOI(from, to, len, base) { \ - bcopy(from, buf, len); \ + memmove(buf, from, len); \ buf[len] = '\0'; \ to = strtol(buf, (char **)NULL, base); \ } @@ -98,18 +99,18 @@ close_archive(fd) * get_arobj -- * read the archive header for this member */ +int get_arobj(fd) int fd; { struct ar_hdr *hdr; - register int len, nr; - register char *p; - char buf[20]; + int len, nr; + char *p, buf[20]; nr = read(fd, hb, sizeof(HDR)); if (nr != sizeof(HDR)) { if (!nr) - return(0); + return (0); if (nr < 0) error(archive); badfmt(); @@ -151,13 +152,13 @@ get_arobj(fd) chdr.size -= len; } else { chdr.lname = 0; - bcopy(hdr->ar_name, chdr.name, sizeof(hdr->ar_name)); + memmove(chdr.name, hdr->ar_name, sizeof(hdr->ar_name)); /* Strip trailing spaces, null terminate. */ for (p = chdr.name + sizeof(hdr->ar_name) - 1; *p == ' '; --p); *++p = '\0'; } - return(1); + return (1); } static int already_written; @@ -166,12 +167,13 @@ static int already_written; * put_arobj -- * Write an archive member to a file. */ +void put_arobj(cfp, sb) CF *cfp; struct stat *sb; { - register int lname; - register char *name; + int lname; + char *name; struct ar_hdr *hdr; off_t size; @@ -193,8 +195,7 @@ put_arobj(cfp, sb) if (options & AR_TR) { if (lname > OLDARMAXNAME) { (void)fflush(stdout); - (void)fprintf(stderr, - "ar: warning: %s truncated to %.*s\n", + warnx("warning: %s truncated to %.*s\n", name, OLDARMAXNAME, name); (void)fflush(stderr); } @@ -202,7 +203,7 @@ put_arobj(cfp, sb) sb->st_uid, sb->st_gid, sb->st_mode, sb->st_size, ARFMAG); lname = 0; - } else if (lname > sizeof(hdr->ar_name) || index(name, ' ')) + } else if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) (void)sprintf(hb, HDR1, AR_EFMT1, lname, sb->st_mtimespec.ts_sec, sb->st_uid, sb->st_gid, sb->st_mode, sb->st_size + lname, ARFMAG); @@ -244,13 +245,14 @@ put_arobj(cfp, sb) * because 16-bit word addressed copies were faster?) Anyhow, it should * have been ripped out long ago. */ +void copy_ar(cfp, size) CF *cfp; off_t size; { static char pad = '\n'; - register off_t sz; - register int from, nr, nw, off, to; + off_t sz; + int from, nr, nw, off, to; char buf[8*1024]; if (!(sz = size)) diff --git a/usr/src/usr.bin/ar/archive.h b/usr/src/usr.bin/ar/archive.h index 5697162e06..3be661b906 100644 --- a/usr/src/usr.bin/ar/archive.h +++ b/usr/src/usr.bin/ar/archive.h @@ -7,7 +7,7 @@ * * %sccs.include.redist.c% * - * @(#)archive.h 8.1 (Berkeley) %G% + * @(#)archive.h 8.2 (Berkeley) %G% */ /* Ar(1) options. */ @@ -69,13 +69,11 @@ typedef struct { #include -__BEGIN_DECLS +struct stat; + void close_archive __P((int)); -void skip_arobj __P((int)); -int copy_ar __P((CF *, off_t)); +void copy_ar __P((CF *, off_t)); int get_arobj __P((int)); int open_archive __P((int)); -struct stat; -int put_arobj __P((CF *, struct stat *)); -__END_DECLS - +void put_arobj __P((CF *, struct stat *)); +void skip_arobj __P((int)); diff --git a/usr/src/usr.bin/ar/contents.c b/usr/src/usr.bin/ar/contents.c index 61b18e37ec..05811b4bb7 100644 --- a/usr/src/usr.bin/ar/contents.c +++ b/usr/src/usr.bin/ar/contents.c @@ -9,34 +9,34 @@ */ #ifndef lint -static char sccsid[] = "@(#)contents.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)contents.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include #include -#include -#include -#include -#include + #include +#include +#include #include #include +#include +#include + #include "archive.h" #include "extern.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ - /* * contents -- * Handles t[v] option - opens the archive and then reads headers, * skipping member contents. */ +int contents(argv) - register char **argv; + char **argv; { - register int afd, all; + int afd, all; struct tm *tp; char *file, buf[25]; @@ -64,7 +64,7 @@ next: skip_arobj(afd); if (*argv) { orphans(argv); - return(1); + return (1); } - return(0); + return (0); } diff --git a/usr/src/usr.bin/ar/delete.c b/usr/src/usr.bin/ar/delete.c index 486f226fe5..f031f3d062 100644 --- a/usr/src/usr.bin/ar/delete.c +++ b/usr/src/usr.bin/ar/delete.c @@ -9,30 +9,29 @@ */ #ifndef lint -static char sccsid[] = "@(#)delete.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)delete.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include + +#include #include -#include +#include #include -#include +#include + #include "archive.h" #include "extern.h" #include "pathnames.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ -extern char *tname; /* temporary file "name" */ - /*- * delete -- * Deletes named members from the archive. */ +int delete(argv) - register char **argv; + char **argv; { CF cf; off_t size; @@ -65,7 +64,7 @@ delete(argv) if (*argv) { orphans(argv); - return(1); + return (1); } - return(0); + return (0); } diff --git a/usr/src/usr.bin/ar/extern.h b/usr/src/usr.bin/ar/extern.h index b8bd7ff98a..5249a482ce 100644 --- a/usr/src/usr.bin/ar/extern.h +++ b/usr/src/usr.bin/ar/extern.h @@ -4,17 +4,25 @@ * * %sccs.include.redist.c% * - * @(#)extern.h 8.1 (Berkeley) %G% + * @(#)extern.h 8.2 (Berkeley) %G% */ -#include +int append __P((char **)); +void badfmt __P((void)); +int compare __P((char *)); +int contents __P((char **)); +int delete __P((char **)); +void error __P((char *)); +int extract __P((char **)); +char *files __P((char **argv)); +int move __P((char **)); +void orphans __P((char **argv)); +int print __P((char **)); +int replace __P((char **)); +char *rname __P((char *)); +int tmp __P((void)); -__BEGIN_DECLS -void badfmt __P((void)); -void error __P((char *)); -void orphans __P((char **argv)); -int compare __P((char *)); -int tmp __P((void)); -char *files __P((char **argv)); -char *rname __P((char *)); -__END_DECLS +extern char *archive; +extern char *posarg, *posname; /* positioning file name */ +extern char *tname; /* temporary file "name" */ +extern CHDR chdr; /* converted header */ diff --git a/usr/src/usr.bin/ar/extract.c b/usr/src/usr.bin/ar/extract.c index 300b3a9da2..3c1e17e2e9 100644 --- a/usr/src/usr.bin/ar/extract.c +++ b/usr/src/usr.bin/ar/extract.c @@ -9,24 +9,23 @@ */ #ifndef lint -static char sccsid[] = "@(#)extract.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)extract.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include #include -#include -#include + #include -#include +#include +#include #include #include +#include + #include "archive.h" #include "extern.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ - /* * extract -- * Extract files from the named archive - if member names given only @@ -35,15 +34,15 @@ extern char *archive; /* archive name */ * members date otherwise date is time of extraction. Does not modify * archive. */ +int extract(argv) char **argv; { - register int afd, all, tfd; + char *file; + int afd, all, eval, tfd; struct timeval tv[2]; struct stat sb; CF cf; - int eval; - char *file; eval = 0; tv[0].tv_usec = tv[1].tv_usec = 0; @@ -65,8 +64,7 @@ extract(argv) continue; if ((tfd = open(file, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR)) < 0) { - (void)fprintf(stderr, "ar: %s: %s.\n", - file, strerror(errno)); + warn("%s", file); skip_arobj(afd); eval = 1; continue; @@ -80,15 +78,13 @@ extract(argv) copy_ar(&cf, chdr.size); if (fchmod(tfd, (short)chdr.mode)) { - (void)fprintf(stderr, "ar: %s: chmod: %s\n", - file, strerror(errno)); + warn("chmod: %s", file); eval = 1; } if (options & AR_O) { tv[0].tv_sec = tv[1].tv_sec = chdr.date; if (utimes(file, tv)) { - (void)fprintf(stderr, "ar: %s: utimes: %s\n", - file, strerror(errno)); + warn("utimes: %s", file); eval = 1; } } @@ -100,7 +96,7 @@ extract(argv) if (*argv) { orphans(argv); - return(1); + return (1); } - return(0); + return (0); } diff --git a/usr/src/usr.bin/ar/misc.c b/usr/src/usr.bin/ar/misc.c index 908062a65d..6d57cc330c 100644 --- a/usr/src/usr.bin/ar/misc.c +++ b/usr/src/usr.bin/ar/misc.c @@ -9,25 +9,27 @@ */ #ifndef lint -static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include -#include -#include + #include -#include +#include +#include +#include #include #include #include +#include + #include "archive.h" #include "extern.h" #include "pathnames.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ char *tname = "temporary file"; /* temporary file "name" */ +int tmp() { extern char *envtmp; @@ -44,7 +46,7 @@ tmp() if (envtmp) (void)sprintf(path, "%s/%s", envtmp, _NAME_ARTMP); else - bcopy(_PATH_ARTMP, path, sizeof(_PATH_ARTMP)); + strcpy(path, _PATH_ARTMP); sigfillset(&set); (void)sigprocmask(SIG_BLOCK, &set, &oset); @@ -52,7 +54,7 @@ tmp() error(tname); (void)unlink(path); (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return(fd); + return (fd); } /* @@ -64,55 +66,57 @@ char * files(argv) char **argv; { - register char **list; - char *p; + char **list, *p; for (list = argv; *list; ++list) if (compare(*list)) { p = *list; - for (; list[0] = list[1]; ++list); - return(p); + for (; list[0] = list[1]; ++list) + continue; + return (p); } - return(NULL); + return (NULL); } void orphans(argv) char **argv; { + for (; *argv; ++argv) - (void)fprintf(stderr, - "ar: %s: not found in archive.\n", *argv); + warnx("%s: not found in archive", *argv); } char * rname(path) char *path; { - register char *ind; + char *ind; - return((ind = rindex(path, '/')) ? ind + 1 : path); + return ((ind = strrchr(path, '/')) ? ind + 1 : path); } +int compare(dest) char *dest; { + if (options & AR_TR) - return(!strncmp(chdr.name, rname(dest), OLDARMAXNAME)); - return(!strcmp(chdr.name, rname(dest))); + return (!strncmp(chdr.name, rname(dest), OLDARMAXNAME)); + return (!strcmp(chdr.name, rname(dest))); } void badfmt() { - errno = EFTYPE; - error(archive); + + errx(1, "%s: %s", archive, strerror(EFTYPE)); } void error(name) char *name; { - (void)fprintf(stderr, "ar: %s: %s\n", name, strerror(errno)); - exit(1); + + errx(1, "%s", name); } diff --git a/usr/src/usr.bin/ar/move.c b/usr/src/usr.bin/ar/move.c index fe3b7aed88..1e4083a681 100644 --- a/usr/src/usr.bin/ar/move.c +++ b/usr/src/usr.bin/ar/move.c @@ -9,24 +9,23 @@ */ #ifndef lint -static char sccsid[] = "@(#)move.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)move.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include + +#include #include -#include +#include +#include #include -#include +#include + #include "archive.h" #include "extern.h" #include "pathnames.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ -extern char *tname; /* temporary file "name" */ - /* * move -- * Change location of named members in archive - if 'b' or 'i' option @@ -34,10 +33,10 @@ extern char *tname; /* temporary file "name" */ * option selected members go after 'posname'. If no options, members * are moved to end of archive. */ +int move(argv) char **argv; { - extern char *posarg, *posname; /* positioning file names */ CF cf; off_t size, tsize; int afd, curfd, mods, tfd1, tfd2, tfd3; @@ -83,10 +82,9 @@ move(argv) } if (mods) { - (void)fprintf(stderr, "ar: %s: archive member not found.\n", - posarg); + warnx("%s: archive member not found", posarg); close_archive(afd); - return(1); + return (1); } (void)lseek(afd, (off_t)SARMAG, SEEK_SET); @@ -110,7 +108,7 @@ move(argv) if (*argv) { orphans(argv); - return(1); + return (1); } - return(0); + return (0); } diff --git a/usr/src/usr.bin/ar/print.c b/usr/src/usr.bin/ar/print.c index d601ca011f..5e87d74df2 100644 --- a/usr/src/usr.bin/ar/print.c +++ b/usr/src/usr.bin/ar/print.c @@ -9,30 +9,30 @@ */ #ifndef lint -static char sccsid[] = "@(#)print.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)print.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include -#include -#include + #include +#include #include +#include + #include "archive.h" #include "extern.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ - /* * print -- * Prints archive members on stdout - if member names given only * print those members, otherwise print all members. */ +int print(argv) char **argv; { CF cf; - register int afd, all; + int afd, all; char *file; afd = open_archive(O_RDONLY); @@ -58,7 +58,7 @@ print(argv) if (*argv) { orphans(argv); - return(1); + return (1); } - return(0); + return (0); } diff --git a/usr/src/usr.bin/ar/replace.c b/usr/src/usr.bin/ar/replace.c index 93f2f4dea2..0087df0426 100644 --- a/usr/src/usr.bin/ar/replace.c +++ b/usr/src/usr.bin/ar/replace.c @@ -9,25 +9,23 @@ */ #ifndef lint -static char sccsid[] = "@(#)replace.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)replace.c 8.2 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include -#include -#include -#include + #include +#include +#include +#include #include #include +#include + #include "archive.h" #include "extern.h" -extern CHDR chdr; /* converted header */ -extern char *archive; /* archive name */ -extern char *tname; /* temporary file "name" */ - /* * replace -- * Replace or add named members to archive. Entries already in the @@ -35,19 +33,17 @@ extern char *tname; /* temporary file "name" */ * the key entry, based on the a, b and i options. If the u option * is specified, modification dates select for replacement. */ +int replace(argv) char **argv; { - extern char *posarg, *posname; /* positioning file name */ - register char *file; - register int afd, curfd, mods, sfd; + char *file; + int afd, curfd, errflg, exists, mods, sfd, tfd1, tfd2; struct stat sb; CF cf; off_t size, tsize; - int err, exists, tfd1, tfd2; - char *rname(); - err = 0; + errflg = 0; /* * If doesn't exist, simply append to the archive. There's * a race here, but it's pretty short, and not worth fixing. @@ -75,9 +71,8 @@ replace(argv) for (curfd = tfd1; get_arobj(afd);) { if (*argv && (file = files(argv))) { if ((sfd = open(file, O_RDONLY)) < 0) { - err = 1; - (void)fprintf(stderr, "ar: %s: %s.\n", - file, strerror(errno)); + errflg = 1; + warn("%s", file); goto useold; } (void)fstat(sfd, &sb); @@ -112,10 +107,9 @@ useold: SETCF(afd, archive, curfd, tname, RPAD|WPAD); } if (mods) { - (void)fprintf(stderr, "ar: %s: archive member not found.\n", - posarg); + warnx("%s: archive member not found", posarg); close_archive(afd); - return(1); + return (1); } /* Append any left-over arguments to the end of the after file. */ @@ -123,9 +117,8 @@ append: while (file = *argv++) { if (options & AR_V) (void)printf("a - %s\n", file); if ((sfd = open(file, O_RDONLY)) < 0) { - err = 1; - (void)fprintf(stderr, "ar: %s: %s.\n", - file, strerror(errno)); + errflg = 1; + warn("%s", file); continue; } (void)fstat(sfd, &sb); @@ -153,5 +146,5 @@ append: while (file = *argv++) { (void)ftruncate(afd, tsize + SARMAG); close_archive(afd); - return(err); + return (errflg); } diff --git a/usr/src/usr.bin/banner/banner.c b/usr/src/usr.bin/banner/banner.c index 62e35f86c6..e4bb05b3fa 100644 --- a/usr/src/usr.bin/banner/banner.c +++ b/usr/src/usr.bin/banner/banner.c @@ -12,7 +12,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)banner.c 8.1 (Berkeley) %G%"; +static char sccsid[] = "@(#)banner.c 8.2 (Berkeley) %G%"; #endif /* not lint */ /* @@ -20,7 +20,11 @@ static char sccsid[] = "@(#)banner.c 8.1 (Berkeley) %G%"; * banner [-w#] [-d] [-t] message ... */ +#include #include +#include +#include +#include #define MAXMSG 1024 #define DWIDTH 132 @@ -987,31 +991,21 @@ char data_table[NBYTES] = { /* 9270 */ 193 }; -int i,j; -int width = DWIDTH; /* -w option: scrunch letters to 80 columns */ -int debug; -int trace; -char line[DWIDTH]; -char print[DWIDTH]; -char message[MAXMSG]; -int nchars; -int linen; -int x,y; -int term; -int pc; -int max; +char line[DWIDTH]; +char message[MAXMSG]; +char print[DWIDTH]; +int debug, i, j, linen, max, nchars, pc, term, trace, x, y; +int width = DWIDTH; /* -w option: scrunch letters to 80 columns */ +int main(argc, argv) int argc; char **argv; { - extern char *optarg; - extern int optind; int ch; - char *strcpy(), *strcat(); while ((ch = getopt(argc, argv, "w:td")) != EOF) - switch((char)ch) { + switch(ch) { case 'w': width = atoi(optarg); if (width <= 0) @@ -1031,30 +1025,11 @@ main(argc, argv) argc -= optind; argv += optind; - for (i=0; i= NCHARS || + asc_ptr[(u_char) message[i]] == 0) { + warnx("The character '%c' is not in my character set", + message[i]); j++; } - if (j) exit(1); + if (j) + exit(1); if (trace) printf("Message '%s' is OK\n",message); /* Now have message. Print it one character at a time. */ - for (i=0; i NBYTES) { + while (!term) { + if (pc < 0 || pc > NBYTES) { printf("bad pc: %d\n",pc); exit(1); } @@ -1127,13 +1105,13 @@ main(argc, argv) x = x & 63; while (x--) { if (print[linen++]) { - for (j=0; j<=max; j++) + for (j=0; j <= max; j++) if (print[j]) putchar(line[j]); putchar('\n'); } } - for (j=0; j #include #include +void usage __P((void)); + +int main(argc, argv) int argc; char **argv; { - extern int optind; - register char *p; + char *p; int ch; while ((ch = getopt(argc, argv, "")) != EOF) @@ -63,8 +65,10 @@ main(argc, argv) * (3) If there are any trailing slash characters in string, they * shall be removed. */ - for (; *p; ++p); - while (*--p == '/'); + for (; *p; ++p) + continue; + while (*--p == '/') + continue; *++p = '\0'; /* @@ -99,8 +103,10 @@ main(argc, argv) exit(0); } +void usage() { + (void)fprintf(stderr, "usage: basename string [suffix]\n"); exit(1); }