diff options
33 files changed, 224 insertions, 176 deletions
diff --git a/usr.bin/basename/basename.c b/usr.bin/basename/basename.c index b369190..4925b27 100644 --- a/usr.bin/basename/basename.c +++ b/usr.bin/basename/basename.c @@ -38,12 +38,13 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)basename.c 8.3 (Berkeley) 4/2/94"; +static char sccsid[] = "@(#)basename.c 8.4 (Berkeley) 5/4/95"; #endif /* not lint */ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> void usage __P((void)); diff --git a/usr.bin/col/col.c b/usr.bin/col/col.c index 77b6dc6..8458281 100644 --- a/usr.bin/col/col.c +++ b/usr.bin/col/col.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)col.c 8.3 (Berkeley) 4/2/94"; +static char sccsid[] = "@(#)col.c 8.5 (Berkeley) 5/4/95"; #endif /* not lint */ #include <ctype.h> @@ -49,6 +49,7 @@ static char sccsid[] = "@(#)col.c 8.3 (Berkeley) 4/2/94"; #include <string.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #define BS '\b' /* backspace */ #define TAB '\t' /* tab */ @@ -294,6 +295,9 @@ main(argc, argv) l->l_max_col = cur_col; cur_col++; } + if (max_line == 0) + exit(0); /* no lines, so just exit */ + /* goto the last line that had a character on it */ for (; l->l_next; l = l->l_next) this_line++; diff --git a/usr.bin/colrm/colrm.c b/usr.bin/colrm/colrm.c index a7c7a65..06f6232 100644 --- a/usr.bin/colrm/colrm.c +++ b/usr.bin/colrm/colrm.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)colrm.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)colrm.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -47,6 +47,7 @@ static char sccsid[] = "@(#)colrm.c 8.1 (Berkeley) 6/6/93"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #define TAB 8 diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c index d3f71c5..5dbab1c 100644 --- a/usr.bin/column/column.c +++ b/usr.bin/column/column.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)column.c 8.3 (Berkeley) 4/2/94"; +static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)column.c 8.3 (Berkeley) 4/2/94"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> void c_columnate __P((void)); void *emalloc __P((int)); diff --git a/usr.bin/comm/comm.c b/usr.bin/comm/comm.c index 8ffbbb5..82f995f 100644 --- a/usr.bin/comm/comm.c +++ b/usr.bin/comm/comm.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)comm.c 8.3 (Berkeley) 4/2/94"; +static char sccsid[] = "@(#)comm.c 8.4 (Berkeley) 5/4/95"; #endif /* not lint */ #include <fcntl.h> @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)comm.c 8.3 (Berkeley) 4/2/94"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #define MAXLINELEN (LINE_MAX + 1) diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index 25ffdd3..15e1524 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)cut.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95"; #endif /* not lint */ #include <ctype.h> @@ -50,6 +50,7 @@ static char sccsid[] = "@(#)cut.c 8.1 (Berkeley) 6/6/93"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> int cflag; char dchar; @@ -218,7 +219,8 @@ f_cut(fp, fname) int output; char lbuf[_POSIX2_LINE_MAX + 1]; - for (sep = dchar, output = 0; fgets(lbuf, sizeof(lbuf), fp);) { + for (sep = dchar; fgets(lbuf, sizeof(lbuf), fp);) { + output = 0; for (isdelim = 0, p = lbuf;; ++p) { if (!(ch = *p)) err("%s: line too long.\n", fname); diff --git a/usr.bin/dirname/dirname.c b/usr.bin/dirname/dirname.c index 9586e5b..ca0caf0 100644 --- a/usr.bin/dirname/dirname.c +++ b/usr.bin/dirname/dirname.c @@ -38,11 +38,12 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)dirname.c 8.3 (Berkeley) 4/2/94"; +static char sccsid[] = "@(#)dirname.c 8.4 (Berkeley) 5/4/95"; #endif /* not lint */ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> void usage __P((void)); diff --git a/usr.bin/du/du.c b/usr.bin/du/du.c index 48869de..173ea63 100644 --- a/usr.bin/du/du.c +++ b/usr.bin/du/du.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)du.c 8.4 (Berkeley) 4/1/94"; +static char sccsid[] = "@(#)du.c 8.5 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/param.h> @@ -54,6 +54,7 @@ static char sccsid[] = "@(#)du.c 8.4 (Berkeley) 4/1/94"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> int linkchk __P((FTSENT *)); void usage __P((void)); diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 6523bba..a5fc173 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -32,9 +32,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)find.1 8.4 (Berkeley) 4/1/94 +.\" @(#)find.1 8.7 (Berkeley) 5/9/95 .\" -.Dd April 1, 1994 +.Dd May 9, 1995 .Dt FIND 1 .Os .Sh NAME @@ -157,9 +157,14 @@ was executed. .It Ic -fstype Ar type True if the file is contained in a file system of type .Ar type . -Currently supported types are ``local'', ``mfs'', ``nfs'', ``msdos'', -``rdonly'' and ``ufs''. -The types ``local'' and ``rdonly'' are not specific file system types. +The +.Xr sysctl 8 +command can be used to find out the types of filesystems +that are available on the system: +.Bd -literal -offset indent +sysctl vfs +.Ed +In addition, there are two pseudo-types, ``local'' and ``rdonly''. The former matches any file system physically mounted on the system where the .Nm find @@ -196,7 +201,7 @@ True if the difference between the file last modification time and the time was started, rounded up to the next full 24\-hour period, is .Ar n 24\-hour periods. -.It Ic \&-ok Ar utility Ns Op argument ... ; +.It Ic \&-ok Ar utility Op argument ... ; The .Ic \&-ok primary is identical to the @@ -265,12 +270,14 @@ Note, the first character of a symbolic mode may not be a dash (``\-''). .It Ic -print This primary always evaluates to true. It prints the pathname of the current file to standard output. -The expression is appended to the user specified expression if neither +If none of .Ic -exec , -.Ic -ls +.Ic -ls , or .Ic \&-ok -is specified. +is specified, the given expression shall be effectively replaced by +.Cm \&( Ns Ar given\& expression Ns Cm \&) +.Ic -print . .It Ic -prune This primary always evaluates to true. It causes diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c index 22fc3a3..dbc6c68 100644 --- a/usr.bin/find/find.c +++ b/usr.bin/find/find.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)find.c 8.3 (Berkeley) 4/1/94"; +static char sccsid[] = "@(#)find.c 8.5 (Berkeley) 8/5/94"; #endif /* not lint */ #include <sys/types.h> @@ -90,15 +90,21 @@ find_formplan(argv) /* * if the user didn't specify one of -print, -ok or -exec, then -print - * is assumed so we add a -print node on the end. It is possible that - * the user might want the -print someplace else on the command line, - * but there's no way to know that. + * is assumed so we bracket the current expression with parens, if + * necessary, and add a -print node on the end. */ if (!isoutput) { - new = c_print(); - if (plan == NULL) + if (plan == NULL) { + new = c_print(); tail = plan = new; - else { + } else { + new = c_openparen(); + new->next = plan; + plan = new; + new = c_closeparen(); + tail->next = new; + tail = new; + new = c_print(); tail->next = new; tail = new; } @@ -170,6 +176,10 @@ find_execute(plan, paths) entry->fts_path, strerror(entry->fts_errno)); rval = 1; continue; +#ifdef FTS_W + case FTS_W: + continue; +#endif /* FTS_W */ } #define BADCH " \t\n\\'\"" if (isxargs && strpbrk(entry->fts_path, BADCH)) { diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index f537676..02ff6f6 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)function.c 8.6 (Berkeley) 4/1/94"; +static char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/param.h> @@ -373,18 +373,15 @@ f_fstype(plan, entry) } first = 0; - switch (plan->flags) { - case F_MTFLAG: - val = sb.f_flags; - break; - case F_MTTYPE: - val = sb.f_type; - break; - default: - abort(); - } + + /* + * Further tests may need both of these values, so + * always copy both of them. + */ + val = sb.f_flags; + val = sb.f_type; } - switch(plan->flags) { + switch (plan->flags) { case F_MTFLAG: return (val & plan->mt_data); case F_MTTYPE: @@ -399,10 +396,21 @@ c_fstype(arg) char *arg; { register PLAN *new; + struct vfsconf vfc; ftsoptions &= ~FTS_NOSTAT; new = palloc(N_FSTYPE, f_fstype); + + /* + * Check first for a filesystem name. + */ + if (getvfsbyname(arg, &vfc) == 0) { + new->flags = F_MTTYPE; + new->mt_data = vfc.vfc_typenum; + return (new); + } + switch (*arg) { case 'l': if (!strcmp(arg, "local")) { @@ -411,27 +419,6 @@ c_fstype(arg) return (new); } break; - case 'm': - if (!strcmp(arg, "mfs")) { - new->flags = F_MTTYPE; - new->mt_data = MOUNT_MFS; - return (new); - } - break; - case 'n': - if (!strcmp(arg, "nfs")) { - new->flags = F_MTTYPE; - new->mt_data = MOUNT_NFS; - return (new); - } - break; - case 'p': - if (!strcmp(arg, "msdos")) { - new->flags = F_MTTYPE; - new->mt_data = MOUNT_MSDOS; - return (new); - } - break; case 'r': if (!strcmp(arg, "rdonly")) { new->flags = F_MTFLAG; @@ -439,13 +426,6 @@ c_fstype(arg) return (new); } break; - case 'u': - if (!strcmp(arg, "ufs")) { - new->flags = F_MTTYPE; - new->mt_data = MOUNT_UFS; - return (new); - } - break; } errx(1, "%s: unknown file type", arg); /* NOTREACHED */ @@ -858,9 +838,9 @@ c_size(arg) /* * -type c functions -- * - * True if the type of the file is c, where c is b, c, d, p, or f for - * block special file, character special file, directory, FIFO, or - * regular file, respectively. + * True if the type of the file is c, where c is b, c, d, p, f or w + * for block special file, character special file, directory, FIFO, + * regular file or whiteout respectively. */ int f_type(plan, entry) @@ -901,6 +881,12 @@ c_type(typestring) case 's': mask = S_IFSOCK; break; +#ifdef FTS_WHITEOUT + case 'w': + mask = S_IFWHT; + ftsoptions |= FTS_WHITEOUT; + break; +#endif /* FTS_WHITEOUT */ default: errx(1, "-type: %s: unknown type", typestring); } diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index c8375863..20985c8 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -41,7 +41,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 4/16/94"; +static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -54,6 +54,7 @@ static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 4/16/94"; #include <stdio.h> #include <stdlib.h> #include <time.h> +#include <unistd.h> #include "find.h" diff --git a/usr.bin/finger/extern.h b/usr.bin/finger/extern.h index 2b675f1..b213fe4 100644 --- a/usr.bin/finger/extern.h +++ b/usr.bin/finger/extern.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)extern.h 8.1 (Berkeley) 6/6/93 + * @(#)extern.h 8.2 (Berkeley) 4/28/95 */ extern char tbuf[1024]; /* Temp buffer for anybody. */ @@ -40,7 +40,6 @@ extern DB *db; /* Database. */ void enter_lastlog __P((PERSON *)); PERSON *enter_person __P((struct passwd *)); void enter_where __P((struct utmp *, PERSON *)); -void err __P((const char *, ...)); PERSON *find_person __P((char *)); void lflag_print __P((void)); int match __P((struct passwd *, char *)); diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1 index 069f9cd..045084a 100644 --- a/usr.bin/finger/finger.1 +++ b/usr.bin/finger/finger.1 @@ -1,4 +1,4 @@ -.\" Copyright (c) 1989, 1990, 1993 +.\" Copyright (c) 1989, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)finger.1 8.2 (Berkeley) 2/16/94 +.\" @(#)finger.1 8.3 (Berkeley) 5/5/94 .\" -.Dd February 16, 1994 +.Dd May 5, 1994 .Dt FINGER 1 .Os BSD 4 .Sh NAME @@ -150,6 +150,11 @@ style. The .Fl l option is the only option that may be passed to a remote machine. +.Sh FILES +.Bl -tag -width /var/log/lastlog -compact +.It Pa /var/log/lastlog +last login data base +.El .Sh SEE ALSO .Xr chpass 1 , .Xr w 1 , diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 5a16765..f4ece3a 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93"; +static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; #endif /* not lint */ /* @@ -58,15 +58,19 @@ static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93"; */ #include <sys/param.h> + +#include <db.h> +#include <err.h> +#include <errno.h> #include <fcntl.h> -#include <time.h> #include <pwd.h> -#include <utmp.h> -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <db.h> +#include <time.h> +#include <unistd.h> +#include <utmp.h> + #include "finger.h" DB *db; @@ -77,6 +81,7 @@ char tbuf[1024]; static void loginlist __P((void)); static void userlist __P((int, char **)); +int main(argc, argv) int argc; char **argv; @@ -134,7 +139,7 @@ main(argc, argv) lflag_print(); else sflag_print(); - exit(0); + return (0); } static void @@ -148,7 +153,7 @@ loginlist() char name[UT_NAMESIZE + 1]; if (!freopen(_PATH_UTMP, "r", stdin)) - err("%s: %s", _PATH_UTMP, strerror(errno)); + err(1, "%s", _PATH_UTMP); name[UT_NAMESIZE] = NULL; while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) @@ -163,12 +168,15 @@ loginlist() } if (db && lflag) for (sflag = R_FIRST;; sflag = R_NEXT) { + PERSON *tmp; + r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - enter_lastlog(*(PERSON **)data.data); + memmove(&tmp, data.data, sizeof tmp); + enter_lastlog(tmp); } } @@ -186,7 +194,7 @@ userlist(argc, argv) if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL || (used = calloc(argc, sizeof(int))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); /* Pull out all network requests. */ for (ap = p = argv, np = nargv; *p; ++p) @@ -207,13 +215,13 @@ userlist(argc, argv) */ if (mflag) for (p = argv; *p; ++p) - if (pw = getpwnam(*p)) + if ((pw = getpwnam(*p)) != NULL) enter_person(pw); else (void)fprintf(stderr, "finger: %s: no such user\n", *p); else { - while (pw = getpwent()) + while ((pw = getpwent()) != NULL) for (p = argv, ip = used; *p; ++p, ++ip) if (match(pw, *p)) { enter_person(pw); @@ -237,7 +245,7 @@ net: for (p = nargv; *p;) * appropriate data whenever a match occurs. */ if (!freopen(_PATH_UTMP, "r", stdin)) - err("%s: %s", _PATH_UTMP, strerror(errno)); + err(1, "%s", _PATH_UTMP); while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) continue; @@ -247,11 +255,14 @@ net: for (p = nargv; *p;) } if (db) for (sflag = R_FIRST;; sflag = R_NEXT) { + PERSON *tmp; + r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - enter_lastlog(*(PERSON **)data.data); + memmove(&tmp, data.data, sizeof tmp); + enter_lastlog(tmp); } } diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c index d079c24..96edb1b 100644 --- a/usr.bin/finger/lprint.c +++ b/usr.bin/finger/lprint.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)lprint.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> @@ -45,6 +45,7 @@ static char sccsid[] = "@(#)lprint.c 8.1 (Berkeley) 6/6/93"; #include <time.h> #include <tzfile.h> #include <db.h> +#include <err.h> #include <pwd.h> #include <utmp.h> #include <errno.h> @@ -72,15 +73,17 @@ lflag_print() extern int pplan; register PERSON *pn; register int sflag, r; + PERSON *tmp; DBT data, key; for (sflag = R_FIRST;; sflag = R_NEXT) { r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - pn = *(PERSON **)data.data; + memmove(&tmp, data.data, sizeof tmp); + pn = tmp; if (sflag != R_FIRST) putchar('\n'); lprint(pn); diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c index 51f1b43..3eb7518 100644 --- a/usr.bin/finger/net.c +++ b/usr.bin/finger/net.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)net.c 8.3 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> @@ -121,7 +121,8 @@ netfinger(name) * it isn't a space, we can simply set the 7th bit. Every ASCII * character with bit 7 set is printable. */ - if (fp = fdopen(s, "r")) + lastc = 0; + if ((fp = fdopen(s, "r")) != NULL) while ((c = getc(fp)) != EOF) { c &= 0x7f; if (c == 0x0d) { diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index 68deb76..54c7eea 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)sprint.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)sprint.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)sprint.c 8.1 (Berkeley) 6/6/93"; #include <time.h> #include <tzfile.h> #include <db.h> +#include <err.h> #include <pwd.h> #include <errno.h> #include <utmp.h> @@ -61,6 +62,7 @@ sflag_print() register WHERE *w; register int sflag, r; register char *p; + PERSON *tmp; DBT data, key; /* @@ -83,10 +85,11 @@ sflag_print() for (sflag = R_FIRST;; sflag = R_NEXT) { r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - pn = *(PERSON **)data.data; + memmove(&tmp, data.data, sizeof tmp); + pn = tmp; for (w = pn->whead; w != NULL; w = w->next) { (void)printf("%-*.*s %-*.*s ", UT_NAMESIZE, UT_NAMESIZE, diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index c27cf1b..b51b7ab 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -35,13 +35,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)util.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/param.h> #include <sys/stat.h> #include <fcntl.h> #include <db.h> +#include <err.h> #include <pwd.h> #include <utmp.h> #include <errno.h> @@ -80,14 +81,14 @@ match(pw, user) if ((p = strtok(p, ",")) == NULL) return(0); - for (t = name; *t = *p; ++p) + for (t = name; (*t = *p) != '\0'; ++p) if (*t == '&') { (void)strcpy(t, pw->pw_name); while (*++t); } else ++t; - for (t = name; p = strtok(t, "\t "); t = NULL) + for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL) if (!strcasecmp(p, user)) return(1); return(0); @@ -169,17 +170,18 @@ enter_person(pw) if (db == NULL && (db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL)) == NULL) - err("%s", strerror(errno)); + err(1, NULL); key.data = pw->pw_name; key.size = strlen(pw->pw_name); - switch((*db->get)(db, &key, &data, 0)) { + switch ((*db->get)(db, &key, &data, 0)) { case 0: - return(*(PERSON **)data.data); + memmove(&pn, data.data, sizeof pn); + return (pn); default: case -1: - err("db get: %s", strerror(errno)); + err(1, "db get"); /* NOTREACHED */ case 1: ++entries; @@ -190,8 +192,8 @@ enter_person(pw) data.size = sizeof(PERSON *); data.data = &pn; if ((*db->put)(db, &key, &data, 0)) - err("%s", strerror(errno)); - return(pn); + err(1, "db put"); + return (pn); } } @@ -201,6 +203,7 @@ find_person(name) { register int cnt; DBT data, key; + PERSON *p; char buf[UT_NAMESIZE + 1]; if (!db) @@ -213,7 +216,10 @@ find_person(name) key.data = buf; key.size = cnt; - return((*db->get)(db, &key, &data, 0) ? NULL : *(PERSON **)data.data); + if ((*db->get)(db, &key, &data, 0)) + return (NULL); + memmove(&p, data.data, sizeof p); + return (p); } PERSON * @@ -222,7 +228,7 @@ palloc() PERSON *p; if ((p = malloc((u_int) sizeof(PERSON))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); return(p); } @@ -233,7 +239,7 @@ walloc(pn) register WHERE *w; if ((w = malloc((u_int) sizeof(WHERE))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); if (pn->whead == NULL) pn->whead = pn->wtail = w; else { @@ -300,8 +306,7 @@ find_idle_and_ttywrite(w) (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty); if (stat(tbuf, &sb) < 0) { - (void)fprintf(stderr, - "finger: %s: %s\n", tbuf, strerror(errno)); + warn(tbuf); return; } w->idletime = now < sb.st_atime ? 0 : now - sb.st_atime; @@ -333,7 +338,7 @@ userinfo(pn, pw) /* ampersands get replaced by the login name */ if (!(p = strsep(&bp, ","))) return; - for (t = name; *t = *p; ++p) + for (t = name; (*t = *p) != '\0'; ++p) if (*t == '&') { (void)strcpy(t, pw->pw_name); if (islower(*t)) @@ -350,32 +355,3 @@ userinfo(pn, pw) pn->homephone = ((p = strsep(&bp, ",")) && *p) ? strdup(p) : NULL; } - -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "finger: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 90d7304..c2bf826 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)fstat.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95"; #endif /* not lint */ #include <sys/param.h> @@ -61,7 +61,7 @@ static char sccsid[] = "@(#)fstat.c 8.1 (Berkeley) 6/6/93"; #undef KERNEL #define NFS #include <sys/mount.h> -#include <nfs/nfsv2.h> +#include <nfs/nfsproto.h> #include <nfs/rpcv2.h> #include <nfs/nfs.h> #include <nfs/nfsnode.h> @@ -76,6 +76,7 @@ static char sccsid[] = "@(#)fstat.c 8.1 (Berkeley) 6/6/93"; #include <ctype.h> #include <errno.h> #include <kvm.h> +#include <limits.h> #include <nlist.h> #include <paths.h> #include <pwd.h> @@ -154,6 +155,7 @@ main(argc, argv) struct kinfo_proc *p, *plast; int arg, ch, what; char *memf, *nlistf; + char buf[_POSIX2_LINE_MAX]; int cnt; arg = 0; @@ -228,8 +230,8 @@ main(argc, argv) if (nlistf != NULL || memf != NULL) setgid(getgid()); - if ((kd = kvm_open(nlistf, memf, NULL, O_RDONLY, NULL)) == NULL) { - fprintf(stderr, "fstat: %s\n", kvm_geterr(kd)); + if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == NULL) { + fprintf(stderr, "fstat: %s\n", buf); exit(1); } #ifdef notdef diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c index e33a3c2..a3ad1de 100644 --- a/usr.bin/head/head.c +++ b/usr.bin/head/head.c @@ -38,15 +38,17 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)head.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)head.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> + +#include <ctype.h> #include <errno.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <stdio.h> -#include <ctype.h> +#include <unistd.h> /* * head - give the first few lines of a stream or of each of a set of files diff --git a/usr.bin/hexdump/hexsyntax.c b/usr.bin/hexdump/hexsyntax.c index 68abbe6..300d43e 100644 --- a/usr.bin/hexdump/hexsyntax.c +++ b/usr.bin/hexdump/hexsyntax.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)hexsyntax.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)hexsyntax.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -40,6 +40,8 @@ static char sccsid[] = "@(#)hexsyntax.c 8.1 (Berkeley) 6/6/93"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> + #include "hexdump.h" off_t skip; /* bytes to skip */ diff --git a/usr.bin/hexdump/odsyntax.c b/usr.bin/hexdump/odsyntax.c index 1a4011f..46f308b 100644 --- a/usr.bin/hexdump/odsyntax.c +++ b/usr.bin/hexdump/odsyntax.c @@ -32,14 +32,16 @@ */ #ifndef lint -static char sccsid[] = "@(#)odsyntax.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)odsyntax.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> -#include <stdlib.h> -#include <stdio.h> #include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + #include "hexdump.h" int deprecated; diff --git a/usr.bin/join/join.1 b/usr.bin/join/join.1 index fa383c6..a1855cf 100644 --- a/usr.bin/join/join.1 +++ b/usr.bin/join/join.1 @@ -32,9 +32,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)join.1 8.1 (Berkeley) 6/6/93 +.\" @(#)join.1 8.3 (Berkeley) 4/28/95 .\" -.Dd June 6, 1993 +.Dd April 28, 1995 .Dt JOIN 1 .Os .Sh NAME @@ -84,6 +84,11 @@ The following options are available: In addition to the default output, produce a line for each unpairable line in file .Ar file_number . +(The argument to +.Fl a +must not be preceded by a space; see the +.Sx COMPATIBILITY +section.) .It Fl e Ar string Replace empty output fields with .Ar string . @@ -165,6 +170,10 @@ the following options are available: .It Fl a In addition to the default output, produce a line for each unpairable line in both file 1 and file 2. +(To distinguish between this and +.Fl a Ar file_number , +.Nm join +currently requires that the latter not include any white space.) .It Fl j1 Ar field Join on the .Ar field Ns 'th diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c index 587fa84..122c62f 100644 --- a/usr.bin/join/join.c +++ b/usr.bin/join/join.c @@ -42,7 +42,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)join.c 8.3 (Berkeley) 4/16/94"; +static char sccsid[] = "@(#)join.c 8.6 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/param.h> @@ -53,6 +53,7 @@ static char sccsid[] = "@(#)join.c 8.3 (Berkeley) 4/16/94"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> /* * There's a structure per input file which encapsulates the state of the @@ -288,6 +289,10 @@ slurp(F) F->setalloc * sizeof(LINE))) == NULL) err(1, NULL); memset(F->set + cnt, 0, 50 * sizeof(LINE)); + + /* re-set lastlp in case it moved */ + if (lastlp != NULL) + lastlp = &F->set[F->setcnt - 1]; } /* @@ -309,7 +314,7 @@ slurp(F) if ((bp = fgetln(F->fp, &len)) == NULL) return; if (lp->linealloc <= len + 1) { - lp->linealloc += MAX(100, len + 1); + lp->linealloc += MAX(100, len + 1 - lp->linealloc); if ((lp->line = realloc(lp->line, lp->linealloc)) == NULL) err(1, NULL); @@ -351,9 +356,9 @@ cmp(lp1, fieldno1, lp2, fieldno2) LINE *lp1, *lp2; u_long fieldno1, fieldno2; { - if (lp1->fieldcnt < fieldno1) - return (lp2->fieldcnt < fieldno2 ? 0 : 1); - if (lp2->fieldcnt < fieldno2) + if (lp1->fieldcnt <= fieldno1) + return (lp2->fieldcnt <= fieldno2 ? 0 : 1); + if (lp2->fieldcnt <= fieldno2) return (-1); return (strcmp(lp1->fields[fieldno1], lp2->fields[fieldno2])); } @@ -472,7 +477,7 @@ fieldarg(option) u_long fieldno; char *end, *token; - while ((token = strsep(&option, " \t")) != NULL) { + while ((token = strsep(&option, ", \t")) != NULL) { if (*token == '\0') continue; if (token[0] != '1' && token[0] != '2' || token[1] != '.') diff --git a/usr.bin/look/look.c b/usr.bin/look/look.c index 87db927..ddbd67fd 100644 --- a/usr.bin/look/look.c +++ b/usr.bin/look/look.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/14/93"; +static char sccsid[] = "@(#)look.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ /* @@ -56,13 +56,15 @@ static char sccsid[] = "@(#)look.c 8.1 (Berkeley) 6/14/93"; #include <sys/mman.h> #include <sys/stat.h> -#include <limits.h> +#include <ctype.h> #include <errno.h> #include <fcntl.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> +#include <unistd.h> + #include "pathnames.h" /* diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c index 396fa81..172a424 100644 --- a/usr.bin/mt/mt.c +++ b/usr.bin/mt/mt.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)mt.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)mt.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ /* @@ -48,12 +48,14 @@ static char sccsid[] = "@(#)mt.c 8.1 (Berkeley) 6/6/93"; #include <sys/types.h> #include <sys/ioctl.h> #include <sys/mtio.h> -#include <fcntl.h> + +#include <ctype.h> #include <errno.h> -#include <stdlib.h> +#include <fcntl.h> #include <stdio.h> -#include <ctype.h> +#include <stdlib.h> #include <string.h> +#include <unistd.h> struct commands { char *c_name; diff --git a/usr.bin/printenv/printenv.c b/usr.bin/printenv/printenv.c index 121cd2f..fc40e3d 100644 --- a/usr.bin/printenv/printenv.c +++ b/usr.bin/printenv/printenv.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)printenv.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)printenv.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -46,6 +46,7 @@ static char sccsid[] = "@(#)printenv.c 8.1 (Berkeley) 6/6/93"; #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <unistd.h> void usage __P((void)); diff --git a/usr.bin/rev/rev.c b/usr.bin/rev/rev.c index fe95991..2fe272e 100644 --- a/usr.bin/rev/rev.c +++ b/usr.bin/rev/rev.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)rev.c 8.2 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)rev.c 8.3 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> @@ -48,6 +48,7 @@ static char sccsid[] = "@(#)rev.c 8.2 (Berkeley) 1/2/94"; #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> void usage __P((void)); diff --git a/usr.bin/tr/str.c b/usr.bin/tr/str.c index f86493a..367e1b1 100644 --- a/usr.bin/tr/str.c +++ b/usr.bin/tr/str.c @@ -32,7 +32,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)str.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)str.c 8.2 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/cdefs.h> @@ -241,8 +241,8 @@ genrange(s) char *savestart; savestart = s->str; - stopval = *++s->str == '\\' ? backslash(s) : *s->str; - if (stopval < s->lastch) { + stopval = *++s->str == '\\' ? backslash(s) : *s->str++; + if (stopval < (u_char)s->lastch) { s->str = savestart; return (0); } diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index d92a519..c34e51d 100644 --- a/usr.bin/tr/tr.c +++ b/usr.bin/tr/tr.c @@ -38,13 +38,16 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)tr.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)tr.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/types.h> + #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> + #include "extern.h" static int string1[NCHARS] = { diff --git a/usr.bin/uname/uname.c b/usr.bin/uname/uname.c index 2ee1547..86b5dce 100644 --- a/usr.bin/uname/uname.c +++ b/usr.bin/uname/uname.c @@ -38,7 +38,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)uname.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)uname.c 8.2 (Berkeley) 5/4/95"; #endif /* not lint */ #include <sys/param.h> @@ -47,6 +47,7 @@ static char sccsid[] = "@(#)uname.c 8.1 (Berkeley) 6/6/93"; #include <err.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> void usage __P((void)); diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index e84f82e..b2b85e1 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -41,7 +41,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)uniq.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)uniq.c 8.3 (Berkeley) 5/4/95"; #endif /* not lint */ #include <errno.h> @@ -49,6 +49,7 @@ static char sccsid[] = "@(#)uniq.c 8.1 (Berkeley) 6/6/93"; #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #define MAXLINELEN (8 * 1024) @@ -171,7 +172,8 @@ show(ofp, str) FILE *ofp; char *str; { - if (cflag) + + if (cflag && *str) (void)fprintf(ofp, "%4d %s", repeats + 1, str); if (dflag && repeats || uflag && !repeats) (void)fprintf(ofp, "%s", str); |