projects
/
unix-history
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2fb5319
)
prettyness police
author
Jan-Simon Pendry
<pendry@ucbvax.Berkeley.EDU>
Fri, 1 Apr 1994 20:20:35 +0000
(12:20 -0800)
committer
Jan-Simon Pendry
<pendry@ucbvax.Berkeley.EDU>
Fri, 1 Apr 1994 20:20:35 +0000
(12:20 -0800)
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
32 files changed:
usr/src/bin/ls/ls.c
patch
|
blob
|
blame
|
history
usr/src/bin/ls/print.c
patch
|
blob
|
blame
|
history
usr/src/bin/ls/util.c
patch
|
blob
|
blame
|
history
usr/src/bin/pwd/pwd.c
patch
|
blob
|
blame
|
history
usr/src/bin/rm/rm.c
patch
|
blob
|
blame
|
history
usr/src/bin/rmdir/rmdir.c
patch
|
blob
|
blame
|
history
usr/src/bin/sleep/sleep.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/cchar.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/gfmt.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/key.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/modes.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/print.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/stty.c
patch
|
blob
|
blame
|
history
usr/src/bin/stty/util.c
patch
|
blob
|
blame
|
history
usr/src/bin/test/operators.c
patch
|
blob
|
blame
|
history
usr/src/bin/test/operators.h
patch
|
blob
|
blame
|
history
usr/src/bin/test/test.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/apropos/apropos.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/append.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/ar.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/archive.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/archive.h
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/contents.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/delete.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/extern.h
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/extract.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/misc.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/move.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/print.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/ar/replace.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/banner/banner.c
patch
|
blob
|
blame
|
history
usr/src/usr.bin/basename/basename.c
patch
|
blob
|
blame
|
history
diff --git
a/usr/src/bin/ls/ls.c
b/usr/src/bin/ls/ls.c
index
fd3ae6a
..
0c49aa4
100644
(file)
--- 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
#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 <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-79,7
+79,7
@@
main(argc, argv)
if (isatty(STDOUT_FILENO)) {
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 ||
!win.ws_col) {
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
termwidth = atoi(p);
}
else
@@
-246,8
+246,8
@@
traverse(argc, argv, options)
int argc, options;
char *argv[];
{
int argc, options;
char *argv[];
{
-
register
FTS *ftsp;
-
register
FTSENT *p, *chp;
+ FTS *ftsp;
+ FTSENT *p, *chp;
int ch_options;
if ((ftsp =
int ch_options;
if ((ftsp =
@@
-264,7
+264,7
@@
traverse(argc, argv, options)
*/
ch_options = !f_recursive && options & FTS_NOSTAT ? FTS_NAMEONLY : 0;
*/
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);
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)
*/
static void
display(p, list)
- register FTSENT *p;
- FTSENT *list;
+ FTSENT *p, *list;
{
{
- register FTSENT *cur;
struct stat *sp;
DISPLAY d;
struct stat *sp;
DISPLAY d;
+ FTSENT *cur;
NAMES *np;
NAMES *np;
- u_long btotal, maxblock, maxinode, maxlen, maxnlink;
u_quad_t maxsize;
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 */
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;
{
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)
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
2d7cfc0
..
f8b9478
100644
(file)
--- a/
usr/src/bin/ls/print.c
+++ b/
usr/src/bin/ls/print.c
@@
-9,7
+9,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)print.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)print.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
@@
-42,7
+42,7
@@
void
printscol(dp)
DISPLAY *dp;
{
printscol(dp)
DISPLAY *dp;
{
-
register
FTSENT *p;
+ FTSENT *p;
for (p = dp->list; p; p = p->fts_link) {
if (IS_NOPRINT(p))
for (p = dp->list; p; p = p->fts_link) {
if (IS_NOPRINT(p))
@@
-56,8
+56,8
@@
void
printlong(dp)
DISPLAY *dp;
{
printlong(dp)
DISPLAY *dp;
{
-
register FTSENT *
p;
-
register struct stat *s
p;
+
struct stat *s
p;
+
FTSENT *
p;
NAMES *np;
char buf[20];
NAMES *np;
char buf[20];
@@
-112,8
+112,8
@@
printcol(dp)
extern int termwidth;
static FTSENT **array;
static int lastentries = -1;
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;
/*
int endcol, numcols, numrows, row;
/*
@@
-176,7
+176,7
@@
printcol(dp)
*/
static int
printaname(p, inodefield, sizefield)
*/
static int
printaname(p, inodefield, sizefield)
-
register
FTSENT *p;
+ FTSENT *p;
u_long sizefield, inodefield;
{
struct stat *sp;
u_long sizefield, inodefield;
{
struct stat *sp;
diff --git
a/usr/src/bin/ls/util.c
b/usr/src/bin/ls/util.c
index
a8846b3
..
4ad8bc5
100644
(file)
--- a/
usr/src/bin/ls/util.c
+++ b/
usr/src/bin/ls/util.c
@@
-9,7
+9,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)util.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)util.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-26,12
+26,12
@@
static char sccsid[] = "@(#)util.c 8.1 (Berkeley) %G%";
void
prcopy(src, dest, len)
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 : '?';
}
ch = *src++;
*dest++ = isprint(ch) ? ch : '?';
}
diff --git
a/usr/src/bin/pwd/pwd.c
b/usr/src/bin/pwd/pwd.c
index
33a5eae
..
bf45019
100644
(file)
--- 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
#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 */
#endif /* not lint */
-#include <sys/types.h>
-
#include <err.h>
#include <err.h>
-#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
void usage __P((void));
#include <unistd.h>
void usage __P((void));
@@
-64,6
+60,7
@@
main(argc, argv)
void
usage()
{
void
usage()
{
+
(void)fprintf(stderr, "usage: pwd\n");
exit(1);
}
(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
0f7e90b
..
24b4eb3
100644
(file)
--- 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
#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 <sys/types.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/errno.h>
#include <err.h>
#include <err.h>
+#include <errno.h>
#include <fts.h>
#include <stdio.h>
#include <stdlib.h>
#include <fts.h>
#include <stdio.h>
#include <stdlib.h>
@@
-46,7
+46,6
@@
main(argc, argv)
int argc;
char *argv[];
{
int argc;
char *argv[];
{
- extern int optind;
int ch, rflag;
rflag = 0;
int ch, rflag;
rflag = 0;
@@
-94,9
+93,9
@@
void
rmtree(argv)
char **argv;
{
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
/*
* Remove a file hierarchy. If forcing removal (-f), or interactive
@@
-178,8
+177,8
@@
void
rmfile(argv)
char **argv;
{
rmfile(argv)
char **argv;
{
-
register
int df;
-
register
char *f;
+ int df;
+ char *f;
struct stat sb;
df = dflag;
struct stat sb;
df = dflag;
@@
-216,7
+215,7
@@
check(path, name, sp)
char *path, *name;
struct stat *sp;
{
char *path, *name;
struct stat *sp;
{
-
register int first, ch
;
+
int ch, first
;
char modep[15];
/* Check -i first. */
char modep[15];
/* Check -i first. */
@@
-250,7
+249,7
@@
void
checkdot(argv)
char **argv;
{
checkdot(argv)
char **argv;
{
-
register char *p, **t, **save
;
+
char *p, **save, **t
;
int complained;
complained = 0;
int complained;
complained = 0;
@@
-273,6
+272,7
@@
checkdot(argv)
void
usage()
{
void
usage()
{
+
(void)fprintf(stderr, "usage: rm [-dfiRr] file ...\n");
exit(1);
}
(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
c364478
..
25bd532
100644
(file)
--- 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
#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 <err.h>
#endif /* not lint */
#include <err.h>
@@
-54,6
+54,7
@@
main(argc, argv)
void
usage()
{
void
usage()
{
+
(void)fprintf(stderr, "usage: rmdir directory ...\n");
exit(1);
}
(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
cb5944c
..
714468b
100644
(file)
--- 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
#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 */
#endif /* not lint */
-#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
void usage __P((void));
void usage __P((void));
@@
-48,6
+48,7
@@
main(argc, argv)
void
usage()
{
void
usage()
{
+
(void)fprintf(stderr, "usage: sleep seconds\n");
exit(1);
}
(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
638ff95
..
b9b547a
100644
(file)
--- a/
usr/src/bin/stty/cchar.c
+++ b/
usr/src/bin/stty/cchar.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)cchar.c 8.
3
(Berkeley) %G%";
+static char sccsid[] = "@(#)cchar.c 8.
4
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-56,16
+56,22
@@
struct cchar cchars2[] = {
{ NULL },
};
{ 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;
{
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;
long val;
char *arg, *ep, *name;
- static int c_cchar __P((const void *, const void *));
name = **argvp;
name = **argvp;
@@
-111,10
+117,3
@@
csearch(argvp, ip)
ip->set = 1;
return (1);
}
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
339240c
..
c29a96c
100644
(file)
--- a/
usr/src/bin/stty/gfmt.c
+++ b/
usr/src/bin/stty/gfmt.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)gfmt.c 8.
4
(Berkeley) %G%";
+static char sccsid[] = "@(#)gfmt.c 8.
5
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-18,7
+18,15
@@
static char sccsid[] = "@(#)gfmt.c 8.4 (Berkeley) %G%";
#include "stty.h"
#include "extern.h"
#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)
void
gprint(tp, wp, ldisc)
@@
-26,7
+34,7
@@
gprint(tp, wp, ldisc)
struct winsize *wp;
int 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);
(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)
void
gread(tp, s)
-
register
struct termios *tp;
+ struct termios *tp;
char *s;
{
char *s;
{
-
register char *ep, *
p;
-
register struct cchar *c
p;
+
struct cchar *c
p;
+
char *ep, *
p;
long tmp;
if ((s = strchr(s, ':')) == NULL)
long tmp;
if ((s = strchr(s, ':')) == NULL)
@@
-93,13
+101,3
@@
gread(tp, s)
gerr(p);
}
}
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
3b88f8c
..
fdbdbc6
100644
(file)
--- a/
usr/src/bin/stty/key.c
+++ b/
usr/src/bin/stty/key.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)key.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)key.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-66,15
+66,21
@@
static struct key {
{ "tty", f_tty, 0 },
};
{ "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;
{
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 == '-') {
name = **argvp;
if (*name == '-') {
@@
-99,13
+105,6
@@
ksearch(argvp, ip)
return (1);
}
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;
void
f_all(ip)
struct info *ip;
@@
-117,6
+116,7
@@
void
f_cbreak(ip)
struct info *ip;
{
f_cbreak(ip)
struct info *ip;
{
+
if (ip->off)
f_sane(ip);
else {
if (ip->off)
f_sane(ip);
else {
@@
-132,6
+132,7
@@
void
f_columns(ip)
struct info *ip;
{
f_columns(ip)
struct info *ip;
{
+
ip->win.ws_col = atoi(ip->arg);
ip->wset = 1;
}
ip->win.ws_col = atoi(ip->arg);
ip->wset = 1;
}
@@
-140,6
+141,7
@@
void
f_dec(ip)
struct info *ip;
{
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');
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;
{
f_everything(ip)
struct info *ip;
{
+
print(&ip->t, &ip->win, ip->ldisc, BSD);
}
print(&ip->t, &ip->win, ip->ldisc, BSD);
}
@@
-160,13
+163,12
@@
void
f_extproc(ip)
struct info *ip;
{
f_extproc(ip)
struct info *ip;
{
- int tmp;
if (ip->set) {
if (ip->set) {
- tmp = 1;
+
int
tmp = 1;
(void)ioctl(ip->fd, TIOCEXT, &tmp);
} else {
(void)ioctl(ip->fd, TIOCEXT, &tmp);
} else {
- tmp = 0;
+
int
tmp = 0;
(void)ioctl(ip->fd, TIOCEXT, &tmp);
}
}
(void)ioctl(ip->fd, TIOCEXT, &tmp);
}
}
@@
-175,6
+177,7
@@
void
f_ispeed(ip)
struct info *ip;
{
f_ispeed(ip)
struct info *ip;
{
+
cfsetispeed(&ip->t, atoi(ip->arg));
ip->set = 1;
}
cfsetispeed(&ip->t, atoi(ip->arg));
ip->set = 1;
}
@@
-183,6
+186,7
@@
void
f_nl(ip)
struct info *ip;
{
f_nl(ip)
struct info *ip;
{
+
if (ip->off) {
ip->t.c_iflag |= ICRNL;
ip->t.c_oflag |= ONLCR;
if (ip->off) {
ip->t.c_iflag |= ICRNL;
ip->t.c_oflag |= ONLCR;
@@
-197,6
+201,7
@@
void
f_ospeed(ip)
struct info *ip;
{
f_ospeed(ip)
struct info *ip;
{
+
cfsetospeed(&ip->t, atoi(ip->arg));
ip->set = 1;
}
cfsetospeed(&ip->t, atoi(ip->arg));
ip->set = 1;
}
@@
-205,6
+210,7
@@
void
f_raw(ip)
struct info *ip;
{
f_raw(ip)
struct info *ip;
{
+
if (ip->off)
f_sane(ip);
else {
if (ip->off)
f_sane(ip);
else {
@@
-219,6
+225,7
@@
void
f_rows(ip)
struct info *ip;
{
f_rows(ip)
struct info *ip;
{
+
ip->win.ws_row = atoi(ip->arg);
ip->wset = 1;
}
ip->win.ws_row = atoi(ip->arg);
ip->wset = 1;
}
@@
-227,6
+234,7
@@
void
f_sane(ip)
struct info *ip;
{
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;
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;
{
f_size(ip)
struct info *ip;
{
+
(void)printf("%d %d\n", ip->win.ws_row, ip->win.ws_col);
}
(void)printf("%d %d\n", ip->win.ws_row, ip->win.ws_col);
}
@@
-248,6
+257,7
@@
void
f_speed(ip)
struct info *ip;
{
f_speed(ip)
struct info *ip;
{
+
(void)printf("%d\n", cfgetospeed(&ip->t));
}
(void)printf("%d\n", cfgetospeed(&ip->t));
}
diff --git
a/usr/src/bin/stty/modes.c
b/usr/src/bin/stty/modes.c
index
29ca482
..
4c144d4
100644
(file)
--- a/
usr/src/bin/stty/modes.c
+++ b/
usr/src/bin/stty/modes.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)modes.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)modes.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-167,8
+167,8
@@
msearch(argvp, ip)
char ***argvp;
struct info *ip;
{
char ***argvp;
struct info *ip;
{
-
register
struct modes *mp;
-
register
char *name;
+ struct modes *mp;
+ char *name;
name = **argvp;
name = **argvp;
diff --git
a/usr/src/bin/stty/print.c
b/usr/src/bin/stty/print.c
index
cbd1b7d
..
69b96ff
100644
(file)
--- a/
usr/src/bin/stty/print.c
+++ b/
usr/src/bin/stty/print.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)print.c 8.
3
(Berkeley) %G%";
+static char sccsid[] = "@(#)print.c 8.
4
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-29,11
+29,10
@@
print(tp, wp, ldisc, fmt)
int ldisc;
enum FMT 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;
char buf1[100], buf2[100];
cnt = 0;
@@
-180,6
+179,7
@@
static void
binit(lb)
char *lb;
{
binit(lb)
char *lb;
{
+
if (col) {
(void)printf("\n");
col = 0;
if (col) {
(void)printf("\n");
col = 0;
@@
-191,6
+191,7
@@
static void
bput(s)
char *s;
{
bput(s)
char *s;
{
+
if (col == 0) {
col = printf("%s: %s", label, s);
return;
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
3e9ae15
..
7dcda3c
100644
(file)
--- 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
#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 <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-129,7
+129,7
@@
args: argc -= optind;
void
usage()
{
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);
}
exit (1);
}
diff --git
a/usr/src/bin/stty/util.c
b/usr/src/bin/stty/util.c
index
8bd01fd
..
450147f
100644
(file)
--- a/
usr/src/bin/stty/util.c
+++ b/
usr/src/bin/stty/util.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)util.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)util.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
diff --git
a/usr/src/bin/test/operators.c
b/usr/src/bin/test/operators.c
index
7adb8c0
..
e2ae17c
100644
(file)
--- a/
usr/src/bin/test/operators.c
+++ b/
usr/src/bin/test/operators.c
@@
-6,7
+6,7
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)operators.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)operators.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
/*
#endif /* not lint */
/*
@@
-17,7
+17,7
@@
static char sccsid[] = "@(#)operators.c 8.1 (Berkeley) %G%";
#include "operators.h"
#include "operators.h"
-char *const unary_op[] = {
+c
onst c
har *const unary_op[] = {
"!",
"-b",
"-c",
"!",
"-b",
"-c",
@@
-39,7
+39,7
@@
char *const unary_op[] = {
NULL
};
NULL
};
-char *const binary_op[] = {
+c
onst c
har *const binary_op[] = {
"-o",
"|",
"-a",
"-o",
"|",
"-a",
diff --git
a/usr/src/bin/test/operators.h
b/usr/src/bin/test/operators.h
index
e629f4a
..
01843b3
100644
(file)
--- a/
usr/src/bin/test/operators.h
+++ b/
usr/src/bin/test/operators.h
@@
-4,7
+4,7
@@
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)operators.h 8.
1
(Berkeley) %G%
+ * @(#)operators.h 8.
2
(Berkeley) %G%
*/
#define NOT 0
*/
#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 */
#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 c
onst c
har *const unary_op[];
+extern c
onst c
har *const binary_op[];
extern const char op_priority[];
extern const char op_argflag[];
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
108d464
..
b6b8080
100644
(file)
--- 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
#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 <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
@@
-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 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 *, c
onst c
har *const *));
static void overflow __P((void));
static int posix_binary_op __P((char **));
static int posix_unary_op __P((char **));
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;
{
expr_is_false(val)
struct value *val;
{
+
if (val->type == STRING) {
if (val->u.string[0] == '\0')
return (1);
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)
static int
lookup_op(name, table)
- char
*name;
- c
har
*const * table;
+ char *name;
+ c
onst char
*const * table;
{
{
-
register
char *const * tp;
-
register char const
*p;
+
const
char *const * tp;
+
const char
*p;
char c;
c = name[1];
char c;
c = name[1];
@@
-521,11
+522,13
@@
get_int(v, lp)
static void
syntax()
{
static void
syntax()
{
+
err(2, "syntax error");
}
static void
overflow()
{
err(2, "syntax error");
}
static void
overflow()
{
+
err(2, "expression is too complex");
}
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
15294a0
..
6087f52
100644
(file)
--- 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
#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 <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
@@
-20,6
+20,7
@@
static char sccsid[] = "@(#)apropos.c 8.5 (Berkeley) %G%";
#include <ctype.h>
#include <err.h>
#include <ctype.h>
#include <err.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@
-27,17
+28,18
@@
static char sccsid[] = "@(#)apropos.c 8.5 (Berkeley) %G%";
#include "../man/config.h"
#include "../man/pathnames.h"
#include "../man/config.h"
#include "../man/pathnames.h"
-#define MAXLINELEN 1024 /* max line handled */
-
static int *found, foundman;
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[];
{
int
main(argc, argv)
int argc;
char *argv[];
{
- extern char *optarg;
- extern int optind;
ENTRY *ep;
TAG *tp;
int ch, rv;
ENTRY *ep;
TAG *tp;
int ch, rv;
@@
-86,11
+88,9
@@
main(argc, argv)
apropos(argv, ep->s, 0);
}
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])
rv = 1;
for (p = argv; *p; ++p)
if (found[p - argv])
@@
-100,15
+100,16
@@
main(argc, argv)
exit(rv);
}
exit(rv);
}
+void
apropos(argv, path, buildpath)
char **argv, *path;
int buildpath;
{
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 */
for (name = path; name; name = end) { /* through name list */
- if (end =
index
(name, ':'))
+ if (end =
strchr
(name, ':'))
*end++ = '\0';
if (buildpath) {
*end++ = '\0';
if (buildpath) {
@@
-125,9
+126,8
@@
apropos(argv, path, buildpath)
/* for each file found */
while (fgets(buf, sizeof(buf), stdin)) {
/* 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);
continue;
}
lowstr(buf, wbuf);
@@
-150,31
+150,33
@@
apropos(argv, path, buildpath)
* match --
* match anywhere the string appears
*/
* match --
* match anywhere the string appears
*/
+int
match(bp, str)
match(bp, str)
-
register
char *bp, *str;
+ char *bp, *str;
{
{
-
register
int len;
-
register
char test;
+ int len;
+ char test;
if (!*bp)
if (!*bp)
- return(0);
+ return
(0);
/* backward compatible: everything matches empty string */
if (!*str)
/* 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))
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
*/
}
/*
* lowstr --
* convert a string to lower case
*/
+void
lowstr(from, to)
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;
while ((ch = *from++) && ch != '\n')
*to++ = isupper(ch) ? tolower(ch) : ch;
@@
-185,8
+187,10
@@
lowstr(from, to)
* usage --
* print usage message and die
*/
* usage --
* print usage message and die
*/
+void
usage()
{
usage()
{
+
(void)fprintf(stderr,
"usage: apropos [-C file] [-M path] [-m path] keyword ...\n");
exit(1);
(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
3b625fc
..
8038ba9
100644
(file)
--- a/
usr/src/usr.bin/ar/append.c
+++ b/
usr/src/usr.bin/ar/append.c
@@
-9,35
+9,35
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)append.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)append.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
-#include <sys/errno.h>
+
+#include <err.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
+
#include "archive.h"
#include "extern.h"
#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.
*/
/*
* 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;
{
append(argv)
char **argv;
{
- register int fd, afd;
- register char *file;
- struct stat sb;
+ int afd, fd, eval;
+ char *file;
CF cf;
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)
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) {
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;
}
eval = 1;
continue;
}
@@
-60,5
+59,5
@@
append(argv)
(void)close(fd);
}
close_archive(afd);
(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
2eb55c3
..
2653f3d
100644
(file)
--- 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
#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 <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
-#include <sys/errno.h>
+
+#include <ar.h>
#include <dirent.h>
#include <dirent.h>
+#include <err.h>
+#include <paths.h>
#include <stdio.h>
#include <stdio.h>
-#include <ar.h>
-#include <string.h>
#include <stdlib.h>
#include <stdlib.h>
-#include <paths.h>
+#include <string.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
CHDR chdr;
u_int options;
char *archive, *envtmp, *posarg, *posname;
#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 --
/*
* 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.
*/
* 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;
{
main(argc, argv)
int argc;
char **argv;
{
- extern int optind;
int c;
char *p;
int c;
char *p;
- int (*fcall)(), append(), contents(), delete(), extract(),
- move(), print(), replace();
+ int (*fcall) __P((char **));
if (argc < 3)
usage();
if (argc < 3)
usage();
@@
-58,10
+61,8
@@
main(argc, argv)
* Fix it, if necessary.
*/
if (*argv[1] != '-') {
* 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;
*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))) {
/* 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) {
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++)) {
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);
usage();
}
posname = rname(posarg);
@@
-174,13
+172,13
@@
main(argc, argv)
badoptions("-x");
if (!(archive = *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) {
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();
}
usage();
}
@@
-191,14
+189,15
@@
static void
badoptions(arg)
char *arg;
{
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()
{
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");
(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
4ad0676
..
59dfb6a
100644
(file)
--- a/
usr/src/usr.bin/ar/archive.c
+++ b/
usr/src/usr.bin/ar/archive.c
@@
-9,28
+9,29
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)archive.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)archive.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <dirent.h>
+
#include <ar.h>
#include <ar.h>
+#include <dirent.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#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 */
typedef struct ar_hdr HDR;
static char hb[sizeof(HDR) + 1]; /* real header */
+int
open_archive(mode)
int mode;
{
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))
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;
}
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);
badfmt();
} else if (write(fd, ARMAG, SARMAG) != SARMAG)
error(archive);
- return(fd);
+ return
(fd);
}
void
close_archive(fd)
int 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) { \
(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); \
}
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
*/
* get_arobj --
* read the archive header for this member
*/
+int
get_arobj(fd)
int fd;
{
struct ar_hdr *hdr;
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)
nr = read(fd, hb, sizeof(HDR));
if (nr != sizeof(HDR)) {
if (!nr)
- return(0);
+ return
(0);
if (nr < 0)
error(archive);
badfmt();
if (nr < 0)
error(archive);
badfmt();
@@
-151,13
+152,13
@@
get_arobj(fd)
chdr.size -= len;
} else {
chdr.lname = 0;
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';
}
/* 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;
}
static int already_written;
@@
-166,12
+167,13
@@
static int already_written;
* put_arobj --
* Write an archive member to a file.
*/
* put_arobj --
* Write an archive member to a file.
*/
+void
put_arobj(cfp, sb)
CF *cfp;
struct stat *sb;
{
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;
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);
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);
}
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;
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);
(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.
*/
* 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';
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))
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
5697162
..
3be661b
100644
(file)
--- a/
usr/src/usr.bin/ar/archive.h
+++ b/
usr/src/usr.bin/ar/archive.h
@@
-7,7
+7,7
@@
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)archive.h 8.
1
(Berkeley) %G%
+ * @(#)archive.h 8.
2
(Berkeley) %G%
*/
/* Ar(1) options. */
*/
/* Ar(1) options. */
@@
-69,13
+69,11
@@
typedef struct {
#include <sys/cdefs.h>
#include <sys/cdefs.h>
-__BEGIN_DECLS
+struct stat;
+
void close_archive __P((int));
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));
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
61b18e3
..
05811b4
100644
(file)
--- a/
usr/src/usr.bin/ar/contents.c
+++ b/
usr/src/usr.bin/ar/contents.c
@@
-9,34
+9,34
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)contents.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)contents.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <tzfile.h>
-#include <dirent.h>
+
#include <ar.h>
#include <ar.h>
+#include <dirent.h>
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
+#include <tzfile.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#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.
*/
/*
* contents --
* Handles t[v] option - opens the archive and then reads headers,
* skipping member contents.
*/
+int
contents(argv)
contents(argv)
-
register
char **argv;
+ char **argv;
{
{
-
register
int afd, all;
+ int afd, all;
struct tm *tp;
char *file, buf[25];
struct tm *tp;
char *file, buf[25];
@@
-64,7
+64,7
@@
next: skip_arobj(afd);
if (*argv) {
orphans(argv);
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
486f226
..
f031f3d
100644
(file)
--- a/
usr/src/usr.bin/ar/delete.c
+++ b/
usr/src/usr.bin/ar/delete.c
@@
-9,30
+9,29
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)delete.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)delete.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
-#include <fcntl.h>
+
+#include <ar.h>
#include <dirent.h>
#include <dirent.h>
-#include <
unistd
.h>
+#include <
fcntl
.h>
#include <stdio.h>
#include <stdio.h>
-#include <ar.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#include "pathnames.h"
#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.
*/
/*-
* delete --
* Deletes named members from the archive.
*/
+int
delete(argv)
delete(argv)
-
register
char **argv;
+ char **argv;
{
CF cf;
off_t size;
{
CF cf;
off_t size;
@@
-65,7
+64,7
@@
delete(argv)
if (*argv) {
orphans(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
b8bd7ff
..
5249a48
100644
(file)
--- a/
usr/src/usr.bin/ar/extern.h
+++ b/
usr/src/usr.bin/ar/extern.h
@@
-4,17
+4,25
@@
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)extern.h 8.
1
(Berkeley) %G%
+ * @(#)extern.h 8.
2
(Berkeley) %G%
*/
*/
-#include <sys/cdefs.h>
+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
300b3a9
..
3c1e17e
100644
(file)
--- a/
usr/src/usr.bin/ar/extract.c
+++ b/
usr/src/usr.bin/ar/extract.c
@@
-9,24
+9,23
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)extract.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)extract.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
+
#include <dirent.h>
#include <dirent.h>
-#include <unistd.h>
+#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#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
/*
* 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.
*/
* members date otherwise date is time of extraction. Does not modify
* archive.
*/
+int
extract(argv)
char **argv;
{
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;
struct timeval tv[2];
struct stat sb;
CF cf;
- int eval;
- char *file;
eval = 0;
tv[0].tv_usec = tv[1].tv_usec = 0;
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) {
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;
skip_arobj(afd);
eval = 1;
continue;
@@
-80,15
+78,13
@@
extract(argv)
copy_ar(&cf, chdr.size);
if (fchmod(tfd, (short)chdr.mode)) {
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)) {
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;
}
}
eval = 1;
}
}
@@
-100,7
+96,7
@@
extract(argv)
if (*argv) {
orphans(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
908062a
..
6d57cc3
100644
(file)
--- a/
usr/src/usr.bin/ar/misc.c
+++ b/
usr/src/usr.bin/ar/misc.c
@@
-9,25
+9,27
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)misc.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)misc.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
-#include <sys/errno.h>
-#include <signal.h>
+
#include <dirent.h>
#include <dirent.h>
-#include <unistd.h>
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#include "pathnames.h"
#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" */
char *tname = "temporary file"; /* temporary file "name" */
+int
tmp()
{
extern char *envtmp;
tmp()
{
extern char *envtmp;
@@
-44,7
+46,7
@@
tmp()
if (envtmp)
(void)sprintf(path, "%s/%s", envtmp, _NAME_ARTMP);
else
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);
sigfillset(&set);
(void)sigprocmask(SIG_BLOCK, &set, &oset);
@@
-52,7
+54,7
@@
tmp()
error(tname);
(void)unlink(path);
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
error(tname);
(void)unlink(path);
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
- return(fd);
+ return
(fd);
}
/*
}
/*
@@
-64,55
+66,57
@@
char *
files(argv)
char **argv;
{
files(argv)
char **argv;
{
- register char **list;
- char *p;
+ char **list, *p;
for (list = argv; *list; ++list)
if (compare(*list)) {
p = *list;
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;
{
}
void
orphans(argv)
char **argv;
{
+
for (; *argv; ++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;
{
}
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;
{
compare(dest)
char *dest;
{
+
if (options & AR_TR)
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()
{
}
void
badfmt()
{
- errno = EFTYPE;
- err
or(archive
);
+
+ err
x(1, "%s: %s", archive, strerror(EFTYPE)
);
}
void
error(name)
char *name;
{
}
void
error(name)
char *name;
{
- (void)fprintf(stderr, "ar: %s: %s\n", name, strerror(errno));
- e
xit(1
);
+
+ e
rrx(1, "%s", name
);
}
}
diff --git
a/usr/src/usr.bin/ar/move.c
b/usr/src/usr.bin/ar/move.c
index
fe3b7ae
..
1e4083a
100644
(file)
--- a/
usr/src/usr.bin/ar/move.c
+++ b/
usr/src/usr.bin/ar/move.c
@@
-9,24
+9,23
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)move.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)move.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
-#include <fcntl.h>
+
+#include <ar.h>
#include <dirent.h>
#include <dirent.h>
-#include <unistd.h>
+#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdio.h>
-#include <ar.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#include "pathnames.h"
#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
/*
* 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.
*/
* option selected members go after 'posname'. If no options, members
* are moved to end of archive.
*/
+int
move(argv)
char **argv;
{
move(argv)
char **argv;
{
- extern char *posarg, *posname; /* positioning file names */
CF cf;
off_t size, tsize;
int afd, curfd, mods, tfd1, tfd2, tfd3;
CF cf;
off_t size, tsize;
int afd, curfd, mods, tfd1, tfd2, tfd3;
@@
-83,10
+82,9
@@
move(argv)
}
if (mods) {
}
if (mods) {
- (void)fprintf(stderr, "ar: %s: archive member not found.\n",
- posarg);
+ warnx("%s: archive member not found", posarg);
close_archive(afd);
close_archive(afd);
- return(1);
+ return
(1);
}
(void)lseek(afd, (off_t)SARMAG, SEEK_SET);
}
(void)lseek(afd, (off_t)SARMAG, SEEK_SET);
@@
-110,7
+108,7
@@
move(argv)
if (*argv) {
orphans(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
d601ca0
..
5e87d74
100644
(file)
--- a/
usr/src/usr.bin/ar/print.c
+++ b/
usr/src/usr.bin/ar/print.c
@@
-9,30
+9,30
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)print.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)print.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
-#include <fcntl.h>
-#include <unistd.h>
+
#include <dirent.h>
#include <dirent.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdio.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#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.
*/
/*
* 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;
print(argv)
char **argv;
{
CF cf;
-
register
int afd, all;
+ int afd, all;
char *file;
afd = open_archive(O_RDONLY);
char *file;
afd = open_archive(O_RDONLY);
@@
-58,7
+58,7
@@
print(argv)
if (*argv) {
orphans(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
93f2f4d
..
0087df0
100644
(file)
--- a/
usr/src/usr.bin/ar/replace.c
+++ b/
usr/src/usr.bin/ar/replace.c
@@
-9,25
+9,23
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)replace.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)replace.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#include <unistd.h>
+
#include <ar.h>
#include <ar.h>
+#include <dirent.h>
+#include <err.h>
+#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
+
#include "archive.h"
#include "extern.h"
#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
/*
* 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.
*/
* 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;
{
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;
struct stat sb;
CF cf;
off_t size, tsize;
- int err, exists, tfd1, tfd2;
- char *rname();
- err = 0;
+ err
flg
= 0;
/*
* If doesn't exist, simply append to the archive. There's
* a race here, but it's pretty short, and not worth fixing.
/*
* 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) {
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);
goto useold;
}
(void)fstat(sfd, &sb);
@@
-112,10
+107,9
@@
useold: SETCF(afd, archive, curfd, tname, RPAD|WPAD);
}
if (mods) {
}
if (mods) {
- (void)fprintf(stderr, "ar: %s: archive member not found.\n",
- posarg);
+ warnx("%s: archive member not found", posarg);
close_archive(afd);
close_archive(afd);
- return(1);
+ return
(1);
}
/* Append any left-over arguments to the end of the after file. */
}
/* 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) {
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);
continue;
}
(void)fstat(sfd, &sb);
@@
-153,5
+146,5
@@
append: while (file = *argv++) {
(void)ftruncate(afd, tsize + SARMAG);
close_archive(afd);
(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
62e35f8
..
e4bb05b
100644
(file)
--- 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
#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 */
/*
#endif /* not lint */
/*
@@
-20,7
+20,11
@@
static char sccsid[] = "@(#)banner.c 8.1 (Berkeley) %G%";
* banner [-w#] [-d] [-t] message ...
*/
* banner [-w#] [-d] [-t] message ...
*/
+#include <err.h>
#include <stdio.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
#define MAXMSG 1024
#define DWIDTH 132
#define MAXMSG 1024
#define DWIDTH 132
@@
-987,31
+991,21
@@
char data_table[NBYTES] = {
/* 9270 */ 193
};
/* 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;
{
main(argc, argv)
int argc;
char **argv;
{
- extern char *optarg;
- extern int optind;
int ch;
int ch;
- char *strcpy(), *strcat();
while ((ch = getopt(argc, argv, "w:td")) != EOF)
while ((ch = getopt(argc, argv, "w:td")) != EOF)
- switch(
(char)
ch) {
+ switch(ch) {
case 'w':
width = atoi(optarg);
if (width <= 0)
case 'w':
width = atoi(optarg);
if (width <= 0)
@@
-1031,30
+1025,11
@@
main(argc, argv)
argc -= optind;
argv += optind;
argc -= optind;
argv += optind;
- for (i
=0; i<
width; i++) {
+ for (i
= 0; i <
width; i++) {
j = i * 132 / width;
print[j] = 1;
}
j = i * 132 / width;
print[j] = 1;
}
-#ifdef notdef
- {
-#define dir(f) "/e1/mrh/ucb/lib/f"
-#define INDTBL dir(ban.dat.indtbl)
-#define OBJECT dir(ban.dat.object)
- FILE *fd;
-
- fd = fopen(INDTBL, "r");
- for (i=0; i<NCHARS; i++) {
- fscanf(fd, "%d", &asc_ptr[i]);
- }
- fclose(fd);
-
- fd = fopen(OBJECT, "r");
- fread(data_table, 1, NBYTES, fd);
- fclose(fd);
- }
-#endif
-
/* Have now read in the data. Next get the message to be printed. */
if (*argv) {
strcpy(message, *argv);
/* Have now read in the data. Next get the message to be printed. */
if (*argv) {
strcpy(message, *argv);
@@
-1073,18
+1048,18
@@
main(argc, argv)
/* some debugging print statements */
if (debug) {
printf("int asc_ptr[128] = {\n");
/* some debugging print statements */
if (debug) {
printf("int asc_ptr[128] = {\n");
- for (i
=0; i<
128; i++) {
+ for (i
= 0; i <
128; i++) {
printf("%4d, ",asc_ptr[i]);
if ((i+1) % 8 == 0)
printf("\n");
}
printf("};\nchar data_table[NBYTES] = {\n");
printf(" /* ");
printf("%4d, ",asc_ptr[i]);
if ((i+1) % 8 == 0)
printf("\n");
}
printf("};\nchar data_table[NBYTES] = {\n");
printf(" /* ");
- for (i
=0; i<
10; i++) printf(" %3d ",i);
+ for (i
= 0; i <
10; i++) printf(" %3d ",i);
printf(" */\n");
printf(" */\n");
- for (i
=0; i<
NBYTES; i += 10) {
+ for (i
= 0; i <
NBYTES; i += 10) {
printf("/* %4d */ ",i);
printf("/* %4d */ ",i);
- for (j
=i; j<
i+10; j++) {
+ for (j
= i; j <
i+10; j++) {
x = data_table[j] & 0377;
printf(" %3d, ",x);
}
x = data_table[j] & 0377;
printf(" %3d, ",x);
}
@@
-1095,27
+1070,30
@@
main(argc, argv)
/* check message to make sure it's legal */
j = 0;
/* check message to make sure it's legal */
j = 0;
- for (i=0; i<nchars; i++)
- if (asc_ptr[message[i]] == 0) {
- printf("The character '%c' is not in my character set.\n",message[i]);
+ for (i = 0; i < nchars; i++)
+ if ((u_char) message[i] >= NCHARS ||
+ asc_ptr[(u_char) message[i]] == 0) {
+ warnx("The character '%c' is not in my character set",
+ message[i]);
j++;
}
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. */
if (trace)
printf("Message '%s' is OK\n",message);
/* Now have message. Print it one character at a time. */
- for (i
=0; i<
nchars; i++) {
+ for (i
= 0; i <
nchars; i++) {
if (trace)
printf("Char #%d: %c\n", i, message[i]);
if (trace)
printf("Char #%d: %c\n", i, message[i]);
- for (j
=0; j<
DWIDTH; j++) line[j] = ' ';
- pc = asc_ptr[message[i]];
+ for (j
= 0; j <
DWIDTH; j++) line[j] = ' ';
+ pc = asc_ptr[
(u_char)
message[i]];
term = 0;
max = 0;
linen = 0;
term = 0;
max = 0;
linen = 0;
- while (
!term
) {
- if (pc
<
0 || pc > NBYTES) {
+ while (
!term
) {
+ if (pc
<
0 || pc > NBYTES) {
printf("bad pc: %d\n",pc);
exit(1);
}
printf("bad pc: %d\n",pc);
exit(1);
}
@@
-1127,13
+1105,13
@@
main(argc, argv)
x = x & 63;
while (x--) {
if (print[linen++]) {
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');
}
}
if (print[j])
putchar(line[j]);
putchar('\n');
}
}
- for (j
=0; j<
DWIDTH; j++) line[j] = ' ';
+ for (j
= 0; j <
DWIDTH; j++) line[j] = ' ';
pc++;
}
else {
pc++;
}
else {
diff --git
a/usr/src/usr.bin/basename/basename.c
b/usr/src/usr.bin/basename/basename.c
index
05bea27
..
ffe311d
100644
(file)
--- a/
usr/src/usr.bin/basename/basename.c
+++ b/
usr/src/usr.bin/basename/basename.c
@@
-12,19
+12,21
@@
static char copyright[] =
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)basename.c 8.
1
(Berkeley) %G%";
+static char sccsid[] = "@(#)basename.c 8.
2
(Berkeley) %G%";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+void usage __P((void));
+
+int
main(argc, argv)
int argc;
char **argv;
{
main(argc, argv)
int argc;
char **argv;
{
- extern int optind;
- register char *p;
+ char *p;
int ch;
while ((ch = getopt(argc, argv, "")) != EOF)
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.
*/
* (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';
/*
*++p = '\0';
/*
@@
-99,8
+103,10
@@
main(argc, argv)
exit(0);
}
exit(0);
}
+void
usage()
{
usage()
{
+
(void)fprintf(stderr, "usage: basename string [suffix]\n");
exit(1);
}
(void)fprintf(stderr, "usage: basename string [suffix]\n");
exit(1);
}