Keith Bostic uploaded the 4.4 find to uunet for us (tested and seems to
authorNate Willams <nate@FreeBSD.org>
Wed, 28 Jul 1993 22:15:10 +0000 (22:15 +0000)
committerNate Willams <nate@FreeBSD.org>
Wed, 28 Jul 1993 22:15:10 +0000 (22:15 +0000)
work well)  Changes are minimal from the previous version, mostly
ANSI-fication stuff and fnmatch updates for the fnmatch code we have now,
before I made an informed guess on how it was supposed to work.

usr.bin/find/Makefile
usr.bin/find/extern.h
usr.bin/find/find.1
usr.bin/find/find.c
usr.bin/find/find.h
usr.bin/find/function.c
usr.bin/find/ls.c
usr.bin/find/main.c
usr.bin/find/misc.c
usr.bin/find/operator.c
usr.bin/find/option.c

index a541970..f15dd25 100644 (file)
@@ -1,4 +1,4 @@
-#      @(#)Makefile    5.3 (Berkeley) 8/19/91
+#      @(#)Makefile    8.1 (Berkeley) 6/6/93
 
 PROG=  find
 SRCS=  find.c function.c ls.c main.c misc.c operator.c option.c
 
 PROG=  find
 SRCS=  find.c function.c ls.c main.c misc.c operator.c option.c
index beb5229..1f02f12 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     @(#)extern.h    5.3 (Berkeley) 7/19/91
+ *     @(#)extern.h    8.1 (Berkeley) 6/6/93
  */
 
 #include <sys/cdefs.h>
 
 void    brace_subst __P((char *, char **, char *, int));
 void   *emalloc __P((unsigned int));
  */
 
 #include <sys/cdefs.h>
 
 void    brace_subst __P((char *, char **, char *, int));
 void   *emalloc __P((unsigned int));
-void    err __P((const char *, ...));
 PLAN   *find_create __P((char ***));
 void    find_execute __P((PLAN *, char **));
 PLAN   *find_formplan __P((char **));
 PLAN   *not_squish __P((PLAN *));
 PLAN   *find_create __P((char ***));
 void    find_execute __P((PLAN *, char **));
 PLAN   *find_formplan __P((char **));
 PLAN   *not_squish __P((PLAN *));
+OPTION *option __P((char *));
 PLAN   *or_squish __P((PLAN *));
 PLAN   *paren_squish __P((PLAN *));
 struct stat;
 PLAN   *or_squish __P((PLAN *));
 PLAN   *paren_squish __P((PLAN *));
 struct stat;
index 2f900b3..9360c94 100644 (file)
@@ -1,5 +1,5 @@
-.\" Copyright (c) 1990 The Regents of the University of California.
-.\" All rights reserved.
+.\" Copyright (c) 1990, 1993
+.\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" This code is derived from software contributed to Berkeley by
 .\" the Institute of Electrical and Electronics Engineers, Inc.
 .\"
 .\" This code is derived from software contributed to Berkeley by
 .\" the Institute of Electrical and Electronics Engineers, Inc.
@@ -32,9 +32,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\"    @(#)find.1      6.30 (Berkeley) 2/27/92
+.\"    @(#)find.1      8.1 (Berkeley) 6/6/93
 .\"
 .\"
-.Dd February 27, 1992
+.Dd June 6, 1993
 .Dt FIND 1
 .Os
 .Sh NAME
 .Dt FIND 1
 .Os
 .Sh NAME
@@ -42,7 +42,7 @@
 .Nd walk a file hierarchy
 .Sh SYNOPSIS
 .Nm find
 .Nd walk a file hierarchy
 .Sh SYNOPSIS
 .Nm find
-.Op Fl dsXx
+.Op Fl HdhXx
 .Op Fl f Ar file
 .Op Ar file ...
 .Ar expression
 .Op Fl f Ar file
 .Op Ar file ...
 .Ar expression
@@ -55,14 +55,19 @@ listed, evaluating an
 (composed of the ``primaries'' and ``operands'' listed below) in terms
 of each file in the tree.
 .Pp
 (composed of the ``primaries'' and ``operands'' listed below) in terms
 of each file in the tree.
 .Pp
-If
-.Ar file
-is a symbolic link referencing an existing file, the directory tree
-referenced by the link is descended instead of the link itself.
-.Pp
 The options are as follows:
 .Pp
 .Bl -tag -width Ds
 The options are as follows:
 .Pp
 .Bl -tag -width Ds
+.It Fl H
+The
+.Fl H
+option causes the file information and file type (see
+.Xr stat  2  ) ,
+returned for each symbolic link encountered on the command line to be 
+those of the file referenced by the link, not the link itself.
+If the referenced file does not exist, the file information and type will
+be for the link itself.  File information of all symbolic links not on 
+the command line is that of the link itself.
 .It Fl d
 The
 .Fl d
 .It Fl d
 The
 .Fl d
@@ -85,9 +90,9 @@ option specifies a file hierarchy for
 to traverse.
 File hierarchies may also be specified as the operands immediately
 following the options.
 to traverse.
 File hierarchies may also be specified as the operands immediately
 following the options.
-.It Fl s
+.It Fl h
 The
 The
-.Fl s
+.Fl h
 option causes the file information and file type (see
 .Xr stat  2  ) ,
 returned for each symbolic link to be those of the file referenced by the
 option causes the file information and file type (see
 .Xr stat  2  ) ,
 returned for each symbolic link to be those of the file referenced by the
@@ -374,11 +379,12 @@ that are newer than ``ttt''.
 .Sh SEE ALSO
 .Xr chmod 1 ,
 .Xr locate 1 ,
 .Sh SEE ALSO
 .Xr chmod 1 ,
 .Xr locate 1 ,
-.Xr test 1 ,
 .Xr stat 2 ,
 .Xr stat 2 ,
+.Xr fts 3 ,
 .Xr getpwent 3 ,
 .Xr getgrent 3 ,
 .Xr getpwent 3 ,
 .Xr getgrent 3 ,
-.Xr strmode 3
+.Xr strmode 3 ,
+.Xr symlink 7
 .Sh STANDARDS
 The
 .Nm find
 .Sh STANDARDS
 The
 .Nm find
index a950e1a..a1a068c 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)find.c     5.5 (Berkeley) 5/5/92";
+static char sccsid[] = "@(#)find.c     8.1 (Berkeley) 6/6/93";
 #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 <errno.h>
 #include <fts.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <fts.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+
 #include "find.h"
 
 /*
 #include "find.h"
 
 /*
@@ -74,7 +77,7 @@ find_formplan(argv)
         * by c_name() with an argument of foo and `-->' represents the
         * plan->next pointer.
         */
         * by c_name() with an argument of foo and `-->' represents the
         * plan->next pointer.
         */
-       for (plan = NULL; *argv;) {
+       for (plan = tail = NULL; *argv;) {
                if (!(new = find_create(&argv)))
                        continue;
                if (plan == NULL)
                if (!(new = find_create(&argv)))
                        continue;
                if (plan == NULL)
@@ -127,7 +130,7 @@ find_formplan(argv)
        plan = paren_squish(plan);              /* ()'s */
        plan = not_squish(plan);                /* !'s */
        plan = or_squish(plan);                 /* -o's */
        plan = paren_squish(plan);              /* ()'s */
        plan = not_squish(plan);                /* !'s */
        plan = or_squish(plan);                 /* -o's */
-       return(plan);
+       return (plan);
 }
  
 FTS *tree;                     /* pointer to top of FTS hierarchy */
 }
  
 FTS *tree;                     /* pointer to top of FTS hierarchy */
@@ -146,7 +149,7 @@ find_execute(plan, paths)
        PLAN *p;
     
        if (!(tree = fts_open(paths, ftsoptions, (int (*)())NULL)))
        PLAN *p;
     
        if (!(tree = fts_open(paths, ftsoptions, (int (*)())NULL)))
-               err("ftsopen: %s", strerror(errno));
+               err(1, "ftsopen");
 
        while (entry = fts_read(tree)) {
                switch(entry->fts_info) {
 
        while (entry = fts_read(tree)) {
                switch(entry->fts_info) {
@@ -162,22 +165,13 @@ find_execute(plan, paths)
                case FTS_ERR:
                case FTS_NS:
                        (void)fflush(stdout);
                case FTS_ERR:
                case FTS_NS:
                        (void)fflush(stdout);
-                       (void)fprintf(stderr, "find: %s: %s\n", 
-                           entry->fts_path, strerror(errno));
+                       warn("%s", entry->fts_path);
                        continue;
                        continue;
-               case FTS_SL:
-                       if (entry->fts_level == FTS_ROOTLEVEL) {
-                               (void)fts_set(tree, entry, FTS_FOLLOW);
-                               continue;
-                       }
-                       break;
                }
                }
-
 #define        BADCH   " \t\n\\'\""
                if (isxargs && strpbrk(entry->fts_path, BADCH)) {
                        (void)fflush(stdout);
 #define        BADCH   " \t\n\\'\""
                if (isxargs && strpbrk(entry->fts_path, BADCH)) {
                        (void)fflush(stdout);
-                       (void)fprintf(stderr,
-                           "find: illegal path: %s\n", entry->fts_path);
+                       warnx("%s: illegal path", entry->fts_path);
                        continue;
                }
                 
                        continue;
                }
                 
index 1756a78..4c4ffa5 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
@@ -33,7 +33,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *     @(#)find.h      5.9 (Berkeley) 7/19/91
+ *     @(#)find.h      8.1 (Berkeley) 6/6/93
  */
 
 /* node type */
  */
 
 /* node type */
@@ -48,7 +48,8 @@ enum ntype {
 /* node definition */
 typedef struct _plandata {
        struct _plandata *next;                 /* next node */
 /* node definition */
 typedef struct _plandata {
        struct _plandata *next;                 /* next node */
-       int (*eval)();                          /* node evaluation function */
+       int (*eval)                             /* node evaluation function */
+           __P((struct _plandata *, FTSENT *));
 #define        F_EQUAL         1                       /* [acm]time inum links size */
 #define        F_LESSTHAN      2
 #define        F_GREATER       3
 #define        F_EQUAL         1                       /* [acm]time inum links size */
 #define        F_LESSTHAN      2
 #define        F_GREATER       3
@@ -92,4 +93,15 @@ typedef struct _plandata {
 #define        e_orig  p_un.ex._e_orig
 #define        e_len   p_un.ex._e_len
 
 #define        e_orig  p_un.ex._e_orig
 #define        e_len   p_un.ex._e_len
 
+typedef struct _option {
+       char *name;                     /* option name */
+       enum ntype token;               /* token type */
+       PLAN *(*create)();              /* create function: DON'T PROTOTYPE! */
+#define        O_NONE          0x01            /* no call required */
+#define        O_ZERO          0x02            /* pass: nothing */
+#define        O_ARGV          0x04            /* pass: argv, increment argv */
+#define        O_ARGVP         0x08            /* pass: *argv, N_OK || N_EXEC */
+       int flags;
+} OPTION;
+
 #include "extern.h"
 #include "extern.h"
index 1708b7c..0c50993 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
@@ -35,7 +35,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)function.c 5.20 (Berkeley) 1/27/92";
+static char sccsid[] = "@(#)function.c 8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -43,46 +43,51 @@ static char sccsid[] = "@(#)function.c      5.20 (Berkeley) 1/27/92";
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/mount.h>
+
+#include <err.h>
 #include <errno.h>
 #include <errno.h>
+#include <fnmatch.h>
+#include <fts.h>
 #include <grp.h>
 #include <pwd.h>
 #include <grp.h>
 #include <pwd.h>
-#include <fts.h>
-#include <unistd.h>
-#include <fnmatch.h>
-#include <tzfile.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <tzfile.h>
+#include <unistd.h>
+
 #include "find.h"
 
 #include "find.h"
 
-#define        COMPARE(a, b) { \
-       switch(plan->flags) { \
-       case F_EQUAL: \
-               return(a == b); \
-       case F_LESSTHAN: \
-               return(a < b); \
-       case F_GREATER: \
-               return(a > b); \
-       } \
-       return(0); \
+#define        COMPARE(a, b) {                                                 \
+       switch (plan->flags) {                                          \
+       case F_EQUAL:                                                   \
+               return (a == b);                                        \
+       case F_LESSTHAN:                                                \
+               return (a < b);                                         \
+       case F_GREATER:                                                 \
+               return (a > b);                                         \
+       default:                                                        \
+               abort();                                                \
+       }                                                               \
 }
 
 }
 
-static PLAN *palloc __P((enum ntype, int (*)()));
+static PLAN *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *))));
 
 /*
  * find_parsenum --
  *     Parse a string of the form [+-]# and return the value.
  */
 
 /*
  * find_parsenum --
  *     Parse a string of the form [+-]# and return the value.
  */
-long
-find_parsenum(plan, option, str, endch)
+static long
+find_parsenum(plan, option, vp, endch)
        PLAN *plan;
        PLAN *plan;
-       char *option, *str, *endch;
+       char *option, *vp, *endch;
 {
        long value;
 {
        long value;
-       char *endchar;          /* pointer to character ending conversion */
+       char *endchar, *str;    /* Pointer to character ending conversion. */
     
     
-       /* determine comparison from leading + or - */
-       switch(*str) {
+       /* Determine comparison from leading + or -. */
+       str = vp;
+       switch (*str) {
        case '+':
                ++str;
                plan->flags = F_GREATER;
        case '+':
                ++str;
                plan->flags = F_GREATER;
@@ -97,26 +102,37 @@ find_parsenum(plan, option, str, endch)
        }
     
        /*
        }
     
        /*
-        * convert the string with strtol().  Note, if strtol() returns zero
+        * Convert the string with strtol().  Note, if strtol() returns zero
         * and endchar points to the beginning of the string we know we have
         * a syntax error.
         */
        value = strtol(str, &endchar, 10);
         * and endchar points to the beginning of the string we know we have
         * a syntax error.
         */
        value = strtol(str, &endchar, 10);
-       if (!value && endchar == str ||
-           endchar[0] && (!endch || endchar[0] != *endch))
-               err("%s: %s", option, "illegal numeric value");
+       if (value == 0 && endchar == str)
+               errx(1, "%s: %s: illegal numeric value", option, vp);
+       if (endchar[0] && (endch == NULL || endchar[0] != *endch))
+               errx(1, "%s: %s: illegal trailing character", option, vp);
        if (endch)
                *endch = endchar[0];
        if (endch)
                *endch = endchar[0];
-       return(value);
+       return (value);
 }
 
 }
 
+/*
+ * The value of n for the inode times (atime, ctime, and mtime) is a range,
+ * i.e. n matches from (n - 1) to n 24 hour periods.  This interacts with
+ * -n, such that "-mtime -1" would be less than 0 days, which isn't what the
+ * user wanted.  Correct so that -1 is "less than 1".
+ */
+#define        TIME_CORRECT(p, ttype)                                          \
+       if ((p)->type == ttype && (p)->flags == F_LESSTHAN)             \
+               ++((p)->t_data);
+
 /*
  * -atime n functions --
  *
  *     True if the difference between the file access time and the
  *     current time is n 24 hour periods.
 /*
  * -atime n functions --
  *
  *     True if the difference between the file access time and the
  *     current time is n 24 hour periods.
- *
  */
  */
+int
 f_atime(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_atime(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -137,7 +153,8 @@ c_atime(arg)
 
        new = palloc(N_ATIME, f_atime);
        new->t_data = find_parsenum(new, "-atime", arg, NULL);
 
        new = palloc(N_ATIME, f_atime);
        new->t_data = find_parsenum(new, "-atime", arg, NULL);
-       return(new);
+       TIME_CORRECT(new, N_ATIME);
+       return (new);
 }
 /*
  * -ctime n functions --
 }
 /*
  * -ctime n functions --
@@ -145,6 +162,7 @@ c_atime(arg)
  *     True if the difference between the last change of file
  *     status information and the current time is n 24 hour periods.
  */
  *     True if the difference between the last change of file
  *     status information and the current time is n 24 hour periods.
  */
+int
 f_ctime(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_ctime(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -164,8 +182,9 @@ c_ctime(arg)
        ftsoptions &= ~FTS_NOSTAT;
 
        new = palloc(N_CTIME, f_ctime);
        ftsoptions &= ~FTS_NOSTAT;
 
        new = palloc(N_CTIME, f_ctime);
-       new->t_data = find_parsenum(new, "-ctime", arg, (char *)NULL);
-       return(new);
+       new->t_data = find_parsenum(new, "-ctime", arg, NULL);
+       TIME_CORRECT(new, N_CTIME);
+       return (new);
 }
 
 /*
 }
 
 /*
@@ -175,12 +194,12 @@ c_ctime(arg)
  *     so that all entries in a directory are acted on before the directory
  *     itself.
  */
  *     so that all entries in a directory are acted on before the directory
  *     itself.
  */
-/* ARGSUSED */
+int
 f_always_true(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_always_true(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return(1);
+       return (1);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -188,7 +207,7 @@ c_depth()
 {
        isdepth = 1;
 
 {
        isdepth = 1;
 
-       return(palloc(N_DEPTH, f_always_true));
+       return (palloc(N_DEPTH, f_always_true));
 }
  
 /*
 }
  
 /*
@@ -203,6 +222,7 @@ c_depth()
  *     The primary -ok is different in that it requests affirmation of the
  *     user before executing the utility.
  */
  *     The primary -ok is different in that it requests affirmation of the
  *     user before executing the utility.
  */
+int
 f_exec(plan, entry)
        register PLAN *plan;
        FTSENT *entry;
 f_exec(plan, entry)
        register PLAN *plan;
        FTSENT *entry;
@@ -218,25 +238,23 @@ f_exec(plan, entry)
                            entry->fts_path, plan->e_len[cnt]);
 
        if (plan->flags == F_NEEDOK && !queryuser(plan->e_argv))
                            entry->fts_path, plan->e_len[cnt]);
 
        if (plan->flags == F_NEEDOK && !queryuser(plan->e_argv))
-               return(0);
+               return (0);
 
 
-       switch(pid = vfork()) {
+       switch (pid = vfork()) {
        case -1:
        case -1:
-               err("fork: %s", strerror(errno));
+               err(1, "fork");
                /* NOTREACHED */
        case 0:
                if (fchdir(dotfd)) {
                /* NOTREACHED */
        case 0:
                if (fchdir(dotfd)) {
-                       (void)fprintf(stderr,
-                           "find: chdir: %s\n", strerror(errno));
+                       warn("chdir");
                        _exit(1);
                }
                execvp(plan->e_argv[0], plan->e_argv);
                        _exit(1);
                }
                execvp(plan->e_argv[0], plan->e_argv);
-               (void)fprintf(stderr,
-                   "find: %s: %s\n", plan->e_argv[0], strerror(errno));
+               warn("%s", plan->e_argv[0]);
                _exit(1);
        }
        pid = waitpid(pid, &status, 0);
                _exit(1);
        }
        pid = waitpid(pid, &status, 0);
-       return(pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status));
+       return (pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status));
 }
  
 /*
 }
  
 /*
@@ -263,8 +281,8 @@ c_exec(argvp, isok)
 
        for (ap = argv = *argvp;; ++ap) {
                if (!*ap)
 
        for (ap = argv = *argvp;; ++ap) {
                if (!*ap)
-                       err("%s: %s",
-                           isok ? "-ok" : "-exec", "no terminating \";\"");
+                       errx(1,
+                           "%s: no terminating \";\"", isok ? "-ok" : "-exec");
                if (**ap == ';')
                        break;
        }
                if (**ap == ';')
                        break;
        }
@@ -290,7 +308,7 @@ c_exec(argvp, isok)
        new->e_argv[cnt] = new->e_orig[cnt] = NULL;
 
        *argvp = argv + 1;
        new->e_argv[cnt] = new->e_orig[cnt] = NULL;
 
        *argvp = argv + 1;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -305,7 +323,7 @@ c_follow()
        ftsoptions &= ~FTS_PHYSICAL;
        ftsoptions |= FTS_LOGICAL;
 
        ftsoptions &= ~FTS_PHYSICAL;
        ftsoptions |= FTS_LOGICAL;
 
-       return(palloc(N_FOLLOW, f_always_true));
+       return (palloc(N_FOLLOW, f_always_true));
 }
  
 /*
 }
  
 /*
@@ -313,6 +331,7 @@ c_follow()
  *
  *     True if the file is of a certain type.
  */
  *
  *     True if the file is of a certain type.
  */
+int
 f_fstype(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_fstype(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -333,7 +352,7 @@ f_fstype(plan, entry)
                 */
                if (entry->fts_info == FTS_SL ||
                    entry->fts_info == FTS_SLNONE) {
                 */
                if (entry->fts_info == FTS_SL ||
                    entry->fts_info == FTS_SLNONE) {
-                       if (p = rindex(entry->fts_accpath, '/'))
+                       if (p = strrchr(entry->fts_accpath, '/'))
                                ++p;
                        else
                                p = entry->fts_accpath;
                                ++p;
                        else
                                p = entry->fts_accpath;
@@ -346,7 +365,7 @@ f_fstype(plan, entry)
                        p = NULL;
 
                if (statfs(entry->fts_accpath, &sb))
                        p = NULL;
 
                if (statfs(entry->fts_accpath, &sb))
-                       err("%s: %s", entry->fts_accpath, strerror(errno));
+                       err(1, "%s", entry->fts_accpath);
 
                if (p) {
                        p[0] = save[0];
 
                if (p) {
                        p[0] = save[0];
@@ -354,20 +373,24 @@ f_fstype(plan, entry)
                }
 
                first = 0;
                }
 
                first = 0;
-               switch(plan->flags) {
+               switch (plan->flags) {
                case F_MTFLAG:
                        val = sb.f_flags;
                        break;
                case F_MTTYPE:
                        val = sb.f_type;
                        break;
                case F_MTFLAG:
                        val = sb.f_flags;
                        break;
                case F_MTTYPE:
                        val = sb.f_type;
                        break;
+               default:
+                       abort();
                }
        }
        switch(plan->flags) {
        case F_MTFLAG:
                }
        }
        switch(plan->flags) {
        case F_MTFLAG:
-               return(val & plan->mt_data);    
+               return (val & plan->mt_data);   
        case F_MTTYPE:
        case F_MTTYPE:
-               return(val == plan->mt_data);
+               return (val == plan->mt_data);
+       default:
+               abort();
        }
 }
  
        }
 }
  
@@ -380,34 +403,34 @@ c_fstype(arg)
        ftsoptions &= ~FTS_NOSTAT;
     
        new = palloc(N_FSTYPE, f_fstype);
        ftsoptions &= ~FTS_NOSTAT;
     
        new = palloc(N_FSTYPE, f_fstype);
-       switch(*arg) {
+       switch (*arg) {
        case 'l':
                if (!strcmp(arg, "local")) {
                        new->flags = F_MTFLAG;
                        new->mt_data = MNT_LOCAL;
        case 'l':
                if (!strcmp(arg, "local")) {
                        new->flags = F_MTFLAG;
                        new->mt_data = MNT_LOCAL;
-                       return(new);
+                       return (new);
                }
                break;
        case 'm':
                if (!strcmp(arg, "mfs")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_MFS;
                }
                break;
        case 'm':
                if (!strcmp(arg, "mfs")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_MFS;
-                       return(new);
+                       return (new);
                }
                break;
        case 'n':
                if (!strcmp(arg, "nfs")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_NFS;
                }
                break;
        case 'n':
                if (!strcmp(arg, "nfs")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_NFS;
-                       return(new);
+                       return (new);
                }
                break;
                }
                break;
-#ifdef PC_FSTYPE
+#ifdef MOUNT_PC
        case 'p':
                if (!strcmp(arg, "pc")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_PC;
        case 'p':
                if (!strcmp(arg, "pc")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_PC;
-                       return(new);
+                       return (new);
                }
                break;
 #endif
                }
                break;
 #endif
@@ -415,18 +438,18 @@ c_fstype(arg)
                if (!strcmp(arg, "rdonly")) {
                        new->flags = F_MTFLAG;
                        new->mt_data = MNT_RDONLY;
                if (!strcmp(arg, "rdonly")) {
                        new->flags = F_MTFLAG;
                        new->mt_data = MNT_RDONLY;
-                       return(new);
+                       return (new);
                }
                break;
        case 'u':
                if (!strcmp(arg, "ufs")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_UFS;
                }
                break;
        case 'u':
                if (!strcmp(arg, "ufs")) {
                        new->flags = F_MTTYPE;
                        new->mt_data = MOUNT_UFS;
-                       return(new);
+                       return (new);
                }
                break;
        }
                }
                break;
        }
-       err("unknown file type %s", arg);
+       errx(1, "%s: unknown file type", arg);
        /* NOTREACHED */
 }
  
        /* NOTREACHED */
 }
  
@@ -437,11 +460,12 @@ c_fstype(arg)
  *     an equivalent of the getgrnam() function does not return a valid group
  *     name, gname is taken as a group ID.
  */
  *     an equivalent of the getgrnam() function does not return a valid group
  *     name, gname is taken as a group ID.
  */
+int
 f_group(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_group(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return(entry->fts_statp->st_gid == plan->g_data);
+       return (entry->fts_statp->st_gid == plan->g_data);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -458,13 +482,13 @@ c_group(gname)
        if (g == NULL) {
                gid = atoi(gname);
                if (gid == 0 && gname[0] != '0')
        if (g == NULL) {
                gid = atoi(gname);
                if (gid == 0 && gname[0] != '0')
-                       err("%s: %s", "-group", "no such group");
+                       errx(1, "-group: %s: no such group", gname);
        } else
                gid = g->gr_gid;
     
        new = palloc(N_GROUP, f_group);
        new->g_data = gid;
        } else
                gid = g->gr_gid;
     
        new = palloc(N_GROUP, f_group);
        new->g_data = gid;
-       return(new);
+       return (new);
 }
 
 /*
 }
 
 /*
@@ -472,6 +496,7 @@ c_group(gname)
  *
  *     True if the file has inode # n.
  */
  *
  *     True if the file has inode # n.
  */
+int
 f_inum(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_inum(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -488,8 +513,8 @@ c_inum(arg)
        ftsoptions &= ~FTS_NOSTAT;
     
        new = palloc(N_INUM, f_inum);
        ftsoptions &= ~FTS_NOSTAT;
     
        new = palloc(N_INUM, f_inum);
-       new->i_data = find_parsenum(new, "-inum", arg, (char *)NULL);
-       return(new);
+       new->i_data = find_parsenum(new, "-inum", arg, NULL);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -497,6 +522,7 @@ c_inum(arg)
  *
  *     True if the file has n links.
  */
  *
  *     True if the file has n links.
  */
+int
 f_links(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_links(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -513,8 +539,8 @@ c_links(arg)
        ftsoptions &= ~FTS_NOSTAT;
     
        new = palloc(N_LINKS, f_links);
        ftsoptions &= ~FTS_NOSTAT;
     
        new = palloc(N_LINKS, f_links);
-       new->l_data = (nlink_t)find_parsenum(new, "-links", arg, (char *)NULL);
-       return(new);
+       new->l_data = (nlink_t)find_parsenum(new, "-links", arg, NULL);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -522,13 +548,13 @@ c_links(arg)
  *
  *     Always true - prints the current entry to stdout in "ls" format.
  */
  *
  *     Always true - prints the current entry to stdout in "ls" format.
  */
-/* ARGSUSED */
+int
 f_ls(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp);
 f_ls(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp);
-       return(1);
+       return (1);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -537,7 +563,7 @@ c_ls()
        ftsoptions &= ~FTS_NOSTAT;
        isoutput = 1;
     
        ftsoptions &= ~FTS_NOSTAT;
        isoutput = 1;
     
-       return(palloc(N_LS, f_ls));
+       return (palloc(N_LS, f_ls));
 }
 
 /*
 }
 
 /*
@@ -546,6 +572,7 @@ c_ls()
  *     True if the difference between the file modification time and the
  *     current time is n 24 hour periods.
  */
  *     True if the difference between the file modification time and the
  *     current time is n 24 hour periods.
  */
+int
 f_mtime(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_mtime(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -565,8 +592,9 @@ c_mtime(arg)
        ftsoptions &= ~FTS_NOSTAT;
 
        new = palloc(N_MTIME, f_mtime);
        ftsoptions &= ~FTS_NOSTAT;
 
        new = palloc(N_MTIME, f_mtime);
-       new->t_data = find_parsenum(new, "-mtime", arg, (char *)NULL);
-       return(new);
+       new->t_data = find_parsenum(new, "-mtime", arg, NULL);
+       TIME_CORRECT(new, N_MTIME);
+       return (new);
 }
 
 /*
 }
 
 /*
@@ -575,11 +603,12 @@ c_mtime(arg)
  *     True if the basename of the filename being examined
  *     matches pattern using Pattern Matching Notation S3.14
  */
  *     True if the basename of the filename being examined
  *     matches pattern using Pattern Matching Notation S3.14
  */
+int
 f_name(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_name(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return(!fnmatch(plan->c_data, entry->fts_name, FNM_PATHNAME));
+       return (!fnmatch(plan->c_data, entry->fts_name, 0));
 }
  
 PLAN *
 }
  
 PLAN *
@@ -590,7 +619,7 @@ c_name(pattern)
 
        new = palloc(N_NAME, f_name);
        new->c_data = pattern;
 
        new = palloc(N_NAME, f_name);
        new->c_data = pattern;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -600,11 +629,12 @@ c_name(pattern)
  *     then the modification time of the file named by the pathname
  *     file.
  */
  *     then the modification time of the file named by the pathname
  *     file.
  */
+int
 f_newer(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_newer(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return(entry->fts_statp->st_mtime > plan->t_data);
+       return (entry->fts_statp->st_mtime > plan->t_data);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -617,10 +647,10 @@ c_newer(filename)
        ftsoptions &= ~FTS_NOSTAT;
 
        if (stat(filename, &sb))
        ftsoptions &= ~FTS_NOSTAT;
 
        if (stat(filename, &sb))
-               err("%s: %s", filename, strerror(errno));
+               err(1, "%s", filename);
        new = palloc(N_NEWER, f_newer);
        new->t_data = sb.st_mtime;
        new = palloc(N_NEWER, f_newer);
        new->t_data = sb.st_mtime;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -629,14 +659,14 @@ c_newer(filename)
  *     True if file belongs to a user ID for which the equivalent
  *     of the getgrnam() 9.2.1 [POSIX.1] function returns NULL.
  */
  *     True if file belongs to a user ID for which the equivalent
  *     of the getgrnam() 9.2.1 [POSIX.1] function returns NULL.
  */
-/* ARGSUSED */
+int
 f_nogroup(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        char *group_from_gid();
 
 f_nogroup(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        char *group_from_gid();
 
-       return(group_from_gid(entry->fts_statp->st_gid, 1) ? 1 : 0);
+       return (group_from_gid(entry->fts_statp->st_gid, 1) ? 1 : 0);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -644,7 +674,7 @@ c_nogroup()
 {
        ftsoptions &= ~FTS_NOSTAT;
 
 {
        ftsoptions &= ~FTS_NOSTAT;
 
-       return(palloc(N_NOGROUP, f_nogroup));
+       return (palloc(N_NOGROUP, f_nogroup));
 }
  
 /*
 }
  
 /*
@@ -653,14 +683,14 @@ c_nogroup()
  *     True if file belongs to a user ID for which the equivalent
  *     of the getpwuid() 9.2.2 [POSIX.1] function returns NULL.
  */
  *     True if file belongs to a user ID for which the equivalent
  *     of the getpwuid() 9.2.2 [POSIX.1] function returns NULL.
  */
-/* ARGSUSED */
+int
 f_nouser(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        char *user_from_uid();
 
 f_nouser(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        char *user_from_uid();
 
-       return(user_from_uid(entry->fts_statp->st_uid, 1) ? 1 : 0);
+       return (user_from_uid(entry->fts_statp->st_uid, 1) ? 1 : 0);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -668,7 +698,7 @@ c_nouser()
 {
        ftsoptions &= ~FTS_NOSTAT;
 
 {
        ftsoptions &= ~FTS_NOSTAT;
 
-       return(palloc(N_NOUSER, f_nouser));
+       return (palloc(N_NOUSER, f_nouser));
 }
  
 /*
 }
  
 /*
@@ -677,11 +707,12 @@ c_nouser()
  *     True if the path of the filename being examined
  *     matches pattern using Pattern Matching Notation S3.14
  */
  *     True if the path of the filename being examined
  *     matches pattern using Pattern Matching Notation S3.14
  */
+int
 f_path(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_path(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return(!fnmatch(plan->c_data, entry->fts_path, FNM_PATHNAME));
+       return (!fnmatch(plan->c_data, entry->fts_path, 0));
 }
  
 PLAN *
 }
  
 PLAN *
@@ -692,7 +723,7 @@ c_path(pattern)
 
        new = palloc(N_NAME, f_path);
        new->c_data = pattern;
 
        new = palloc(N_NAME, f_path);
        new->c_data = pattern;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -702,6 +733,7 @@ c_path(pattern)
  *     with a leading digit, it's treated as an octal mode, otherwise as a
  *     symbolic mode.
  */
  *     with a leading digit, it's treated as an octal mode, otherwise as a
  *     symbolic mode.
  */
+int
 f_perm(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_perm(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -711,9 +743,9 @@ f_perm(plan, entry)
        mode = entry->fts_statp->st_mode &
            (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
        if (plan->flags == F_ATLEAST)
        mode = entry->fts_statp->st_mode &
            (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
        if (plan->flags == F_ATLEAST)
-               return((plan->m_data | mode) == mode);
+               return ((plan->m_data | mode) == mode);
        else
        else
-               return(mode == plan->m_data);
+               return (mode == plan->m_data);
        /* NOTREACHED */
 }
  
        /* NOTREACHED */
 }
  
@@ -734,10 +766,10 @@ c_perm(perm)
        }
 
        if ((set = setmode(perm)) == NULL)
        }
 
        if ((set = setmode(perm)) == NULL)
-               err("%s: %s", "-perm", "illegal mode string");
+               err(1, "-perm: %s: illegal mode string", perm);
 
        new->m_data = getmode(set, 0);
 
        new->m_data = getmode(set, 0);
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -746,13 +778,13 @@ c_perm(perm)
  *     Always true, causes the current pathame to be written to
  *     standard output.
  */
  *     Always true, causes the current pathame to be written to
  *     standard output.
  */
-/* ARGSUSED */
+int
 f_print(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        (void)printf("%s\n", entry->fts_path);
 f_print(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        (void)printf("%s\n", entry->fts_path);
-       return(1);
+       return (1);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -760,7 +792,7 @@ c_print()
 {
        isoutput = 1;
 
 {
        isoutput = 1;
 
-       return(palloc(N_PRINT, f_print));
+       return (palloc(N_PRINT, f_print));
 }
  
 /*
 }
  
 /*
@@ -768,7 +800,7 @@ c_print()
  *
  *     Prune a portion of the hierarchy.
  */
  *
  *     Prune a portion of the hierarchy.
  */
-/* ARGSUSED */
+int
 f_prune(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_prune(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -776,14 +808,14 @@ f_prune(plan, entry)
        extern FTS *tree;
 
        if (fts_set(tree, entry, FTS_SKIP))
        extern FTS *tree;
 
        if (fts_set(tree, entry, FTS_SKIP))
-               err("%s: %s", entry->fts_path, strerror(errno));
-       return(1);
+               err(1, "%s", entry->fts_path);
+       return (1);
 }
  
 PLAN *
 c_prune()
 {
 }
  
 PLAN *
 c_prune()
 {
-       return(palloc(N_PRUNE, f_prune));
+       return (palloc(N_PRUNE, f_prune));
 }
  
 /*
 }
  
 /*
@@ -796,6 +828,7 @@ c_prune()
 #define        FIND_SIZE       512
 static int divsize = 1;
 
 #define        FIND_SIZE       512
 static int divsize = 1;
 
+int
 f_size(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_size(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -817,10 +850,11 @@ c_size(arg)
        ftsoptions &= ~FTS_NOSTAT;
 
        new = palloc(N_SIZE, f_size);
        ftsoptions &= ~FTS_NOSTAT;
 
        new = palloc(N_SIZE, f_size);
+       endch = 'c';
        new->o_data = find_parsenum(new, "-size", arg, &endch);
        if (endch == 'c')
                divsize = 0;
        new->o_data = find_parsenum(new, "-size", arg, &endch);
        if (endch == 'c')
                divsize = 0;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -830,11 +864,12 @@ c_size(arg)
  *     block special file, character special file, directory, FIFO, or
  *     regular file, respectively.
  */
  *     block special file, character special file, directory, FIFO, or
  *     regular file, respectively.
  */
+int
 f_type(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_type(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return((entry->fts_statp->st_mode & S_IFMT) == plan->m_data);
+       return ((entry->fts_statp->st_mode & S_IFMT) == plan->m_data);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -869,12 +904,12 @@ c_type(typestring)
                mask = S_IFSOCK;
                break;
        default:
                mask = S_IFSOCK;
                break;
        default:
-               err("%s: %s", "-type", "unknown type");
+               errx(1, "-type: %s: unknown type", typestring);
        }
     
        new = palloc(N_TYPE, f_type);
        new->m_data = mask;
        }
     
        new = palloc(N_TYPE, f_type);
        new->m_data = mask;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -884,11 +919,12 @@ c_type(typestring)
  *     an equivalent of the getpwnam() S9.2.2 [POSIX.1] function does not
  *     return a valid user name, uname is taken as a user ID.
  */
  *     an equivalent of the getpwnam() S9.2.2 [POSIX.1] function does not
  *     return a valid user name, uname is taken as a user ID.
  */
+int
 f_user(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
 f_user(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
-       return(entry->fts_statp->st_uid == plan->u_data);
+       return (entry->fts_statp->st_uid == plan->u_data);
 }
  
 PLAN *
 }
  
 PLAN *
@@ -905,13 +941,13 @@ c_user(username)
        if (p == NULL) {
                uid = atoi(username);
                if (uid == 0 && username[0] != '0')
        if (p == NULL) {
                uid = atoi(username);
                if (uid == 0 && username[0] != '0')
-                       err("%s: %s", "-user", "no such user");
+                       errx(1, "-user: %s: no such user", username);
        } else
                uid = p->pw_uid;
 
        new = palloc(N_USER, f_user);
        new->u_data = uid;
        } else
                uid = p->pw_uid;
 
        new = palloc(N_USER, f_user);
        new->u_data = uid;
-       return(new);
+       return (new);
 }
  
 /*
 }
  
 /*
@@ -925,7 +961,7 @@ c_xdev()
 {
        ftsoptions |= FTS_XDEV;
 
 {
        ftsoptions |= FTS_XDEV;
 
-       return(palloc(N_XDEV, f_always_true));
+       return (palloc(N_XDEV, f_always_true));
 }
 
 /*
 }
 
 /*
@@ -933,6 +969,7 @@ c_xdev()
  *
  *     True if expression is true.
  */
  *
  *     True if expression is true.
  */
+int
 f_expr(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_expr(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -942,7 +979,7 @@ f_expr(plan, entry)
 
        for (p = plan->p_data[0];
            p && (state = (p->eval)(p, entry)); p = p->next);
 
        for (p = plan->p_data[0];
            p && (state = (p->eval)(p, entry)); p = p->next);
-       return(state);
+       return (state);
 }
  
 /*
 }
  
 /*
@@ -953,13 +990,13 @@ f_expr(plan, entry)
 PLAN *
 c_openparen()
 {
 PLAN *
 c_openparen()
 {
-       return(palloc(N_OPENPAREN, (int (*)())-1));
+       return (palloc(N_OPENPAREN, (int (*)())-1));
 }
  
 PLAN *
 c_closeparen()
 {
 }
  
 PLAN *
 c_closeparen()
 {
-       return(palloc(N_CLOSEPAREN, (int (*)())-1));
+       return (palloc(N_CLOSEPAREN, (int (*)())-1));
 }
  
 /*
 }
  
 /*
@@ -967,6 +1004,7 @@ c_closeparen()
  *
  *     Negation of a primary; the unary NOT operator.
  */
  *
  *     Negation of a primary; the unary NOT operator.
  */
+int
 f_not(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_not(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -976,13 +1014,13 @@ f_not(plan, entry)
 
        for (p = plan->p_data[0];
            p && (state = (p->eval)(p, entry)); p = p->next);
 
        for (p = plan->p_data[0];
            p && (state = (p->eval)(p, entry)); p = p->next);
-       return(!state);
+       return (!state);
 }
  
 PLAN *
 c_not()
 {
 }
  
 PLAN *
 c_not()
 {
-       return(palloc(N_NOT, f_not));
+       return (palloc(N_NOT, f_not));
 }
  
 /*
 }
  
 /*
@@ -991,6 +1029,7 @@ c_not()
  *     Alternation of primaries; the OR operator.  The second expression is
  * not evaluated if the first expression is true.
  */
  *     Alternation of primaries; the OR operator.  The second expression is
  * not evaluated if the first expression is true.
  */
+int
 f_or(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 f_or(plan, entry)
        PLAN *plan;
        FTSENT *entry;
@@ -1002,23 +1041,23 @@ f_or(plan, entry)
            p && (state = (p->eval)(p, entry)); p = p->next);
 
        if (state)
            p && (state = (p->eval)(p, entry)); p = p->next);
 
        if (state)
-               return(1);
+               return (1);
 
        for (p = plan->p_data[1];
            p && (state = (p->eval)(p, entry)); p = p->next);
 
        for (p = plan->p_data[1];
            p && (state = (p->eval)(p, entry)); p = p->next);
-       return(state);
+       return (state);
 }
 
 PLAN *
 c_or()
 {
 }
 
 PLAN *
 c_or()
 {
-       return(palloc(N_OR, f_or));
+       return (palloc(N_OR, f_or));
 }
 
 static PLAN *
 palloc(t, f)
        enum ntype t;
 }
 
 static PLAN *
 palloc(t, f)
        enum ntype t;
-       int (*f)();
+       int (*f) __P((PLAN *, FTSENT *));
 {
        PLAN *new;
 
 {
        PLAN *new;
 
@@ -1027,8 +1066,8 @@ palloc(t, f)
                new->eval = f;
                new->flags = 0;
                new->next = NULL;
                new->eval = f;
                new->flags = 0;
                new->next = NULL;
-               return(new);
+               return (new);
        }
        }
-       err("%s", strerror(errno));
+       err(1, NULL);
        /* NOTREACHED */
 }
        /* NOTREACHED */
 }
index a404f1b..dd51f97 100644 (file)
@@ -1,6 +1,6 @@
 /*
 /*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ls.c       5.6 (Berkeley) 3/9/91";
+static char sccsid[] = "@(#)ls.c       8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/stat.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/stat.h>
-#include <time.h>
-#include <tzfile.h>
+
+#include <err.h>
 #include <errno.h>
 #include <errno.h>
-#include <utmp.h>
-#include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdio.h>
 #include <string.h>
+#include <time.h>
+#include <tzfile.h>
+#include <unistd.h>
+#include <utmp.h>
 
 /* Derived from the print routines in the ls(1) source code. */
 
 
 /* Derived from the print routines in the ls(1) source code. */
 
+static void printlink __P((char *));
+static void printtime __P((time_t));
+
 void
 printlong(name, accpath, sb)
        char *name;                     /* filename to print */
 void
 printlong(name, accpath, sb)
        char *name;                     /* filename to print */
@@ -55,7 +60,7 @@ printlong(name, accpath, sb)
 {
        char modep[15], *user_from_uid(), *group_from_gid();
 
 {
        char modep[15], *user_from_uid(), *group_from_gid();
 
-       (void)printf("%6lu %4ld ", sb->st_ino, sb->st_blocks);
+       (void)printf("%6lu %4qd ", sb->st_ino, sb->st_blocks);
        (void)strmode(sb->st_mode, modep);
        (void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, UT_NAMESIZE,
            user_from_uid(sb->st_uid, 0), UT_NAMESIZE,
        (void)strmode(sb->st_mode, modep);
        (void)printf("%s %3u %-*s %-*s ", modep, sb->st_nlink, UT_NAMESIZE,
            user_from_uid(sb->st_uid, 0), UT_NAMESIZE,
@@ -65,7 +70,7 @@ printlong(name, accpath, sb)
                (void)printf("%3d, %3d ", major(sb->st_rdev),
                    minor(sb->st_rdev));
        else
                (void)printf("%3d, %3d ", major(sb->st_rdev),
                    minor(sb->st_rdev));
        else
-               (void)printf("%8ld ", sb->st_size);
+               (void)printf("%8qd ", sb->st_size);
        printtime(sb->st_mtime);
        (void)printf("%s", name);
        if (S_ISLNK(sb->st_mode))
        printtime(sb->st_mtime);
        (void)printf("%s", name);
        if (S_ISLNK(sb->st_mode))
@@ -73,6 +78,7 @@ printlong(name, accpath, sb)
        (void)putchar('\n');
 }
 
        (void)putchar('\n');
 }
 
+static void
 printtime(ftime)
        time_t ftime;
 {
 printtime(ftime)
        time_t ftime;
 {
@@ -96,6 +102,7 @@ printtime(ftime)
        (void)putchar(' ');
 }
 
        (void)putchar(' ');
 }
 
+static void
 printlink(name)
        char *name;
 {
 printlink(name)
        char *name;
 {
@@ -103,8 +110,7 @@ printlink(name)
        char path[MAXPATHLEN + 1];
 
        if ((lnklen = readlink(name, path, MAXPATHLEN)) == -1) {
        char path[MAXPATHLEN + 1];
 
        if ((lnklen = readlink(name, path, MAXPATHLEN)) == -1) {
-               (void)fprintf(stderr,
-                   "\nfind: %s: %s\n", name, strerror(errno));
+               warn("%s", name);
                return;
        }
        path[lnklen] = '\0';
                return;
        }
        path[lnklen] = '\0';
index cfa12c0..073a5f0 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.10 (Berkeley) 12/5/91";
+static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include <err.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <fcntl.h>
-#include <time.h>
 #include <fts.h>
 #include <fts.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <time.h>
+
 #include "find.h"
 
 time_t now;                    /* time find was run */
 #include "find.h"
 
 time_t now;                    /* time find was run */
@@ -53,29 +56,32 @@ int isdepth;                        /* do directories on post-order visit */
 int isoutput;                  /* user specified output operator */
 int isxargs;                   /* don't permit xargs delimiting chars */
 
 int isoutput;                  /* user specified output operator */
 int isxargs;                   /* don't permit xargs delimiting chars */
 
-static void usage();
+static void usage __P((void));
 
 
+int
 main(argc, argv)
        int argc;
 main(argc, argv)
        int argc;
-       char **argv;
+       char *argv[];
 {
        register char **p, **start;
 {
        register char **p, **start;
-       PLAN *find_formplan();
        int ch;
 
        (void)time(&now);       /* initialize the time-of-day */
 
        p = start = argv;
        ftsoptions = FTS_NOSTAT|FTS_PHYSICAL;
        int ch;
 
        (void)time(&now);       /* initialize the time-of-day */
 
        p = start = argv;
        ftsoptions = FTS_NOSTAT|FTS_PHYSICAL;
-       while ((ch = getopt(argc, argv, "df:sXx")) != EOF)
+       while ((ch = getopt(argc, argv, "Hdf:hXx")) != EOF)
                switch(ch) {
                switch(ch) {
+               case 'H':
+                       ftsoptions |= FTS_COMFOLLOW;
+                       break;
                case 'd':
                        isdepth = 1;
                        break;
                case 'f':
                        *p++ = optarg;
                        break;
                case 'd':
                        isdepth = 1;
                        break;
                case 'f':
                        *p++ = optarg;
                        break;
-               case 's':
+               case 'h':
                        ftsoptions &= ~FTS_PHYSICAL;
                        ftsoptions |= FTS_LOGICAL;
                        break;
                        ftsoptions &= ~FTS_PHYSICAL;
                        ftsoptions |= FTS_LOGICAL;
                        break;
@@ -83,7 +89,6 @@ main(argc, argv)
                        isxargs = 1;
                        break;
                case 'x':
                        isxargs = 1;
                        break;
                case 'x':
-                       ftsoptions &= ~FTS_NOSTAT;
                        ftsoptions |= FTS_XDEV;
                        break;
                case '?':
                        ftsoptions |= FTS_XDEV;
                        break;
                case '?':
@@ -106,7 +111,7 @@ main(argc, argv)
        *p = NULL;
 
        if ((dotfd = open(".", O_RDONLY, 0)) < 0)
        *p = NULL;
 
        if ((dotfd = open(".", O_RDONLY, 0)) < 0)
-               err(".: %s", strerror(errno));
+               err(1, ".:");
 
        find_execute(find_formplan(argv), start);
        exit(0);
 
        find_execute(find_formplan(argv), start);
        exit(0);
@@ -116,6 +121,15 @@ static void
 usage()
 {
        (void)fprintf(stderr,
 usage()
 {
        (void)fprintf(stderr,
-           "usage: find [-dsXx] [-f file] [file ...] expression\n");
+           "usage: find [-HdhXx] [-f file] [file ...] expression\n");
        exit(1);
 }
        exit(1);
 }
+
+
+
+
+
+
+
+
+
index 3ff4d5a..ea9a333 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)misc.c     5.8 (Berkeley) 5/24/91";
+static char sccsid[] = "@(#)misc.c     8.1 (Berkeley) 6/6/93";
 #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 <errno.h>
+#include <fts.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "find.h"
  
 /*
 #include "find.h"
  
 /*
@@ -63,8 +67,8 @@ brace_subst(orig, store, path, len)
                if (ch == '{' && orig[1] == '}') {
                        while ((p - *store) + plen > len)
                                if (!(*store = realloc(*store, len *= 2)))
                if (ch == '{' && orig[1] == '}') {
                        while ((p - *store) + plen > len)
                                if (!(*store = realloc(*store, len *= 2)))
-                                       err("%s", strerror(errno));
-                       bcopy(path, p, plen);
+                                       err(1, NULL);
+                       memmove(p, path, plen);
                        p += plen;
                        ++orig;
                } else
                        p += plen;
                        ++orig;
                } else
@@ -77,6 +81,7 @@ brace_subst(orig, store, path, len)
  *     print a message to standard error and then read input from standard
  *     input. If the input is 'y' then 1 is returned.
  */
  *     print a message to standard error and then read input from standard
  *     input. If the input is 'y' then 1 is returned.
  */
+int
 queryuser(argv)
        register char **argv;
 {
 queryuser(argv)
        register char **argv;
 {
@@ -103,7 +108,7 @@ queryuser(argv)
                (void)fprintf(stderr, "\n");
                (void)fflush(stderr);
        }
                (void)fprintf(stderr, "\n");
                (void)fflush(stderr);
        }
-        return(first == 'y');
+        return (first == 'y');
 }
  
 /*
 }
  
 /*
@@ -117,36 +122,6 @@ emalloc(len)
        void *p;
 
        if (p = malloc(len))
        void *p;
 
        if (p = malloc(len))
-               return(p);
-       err("%s", strerror(errno));
-       /* NOTREACHED */
-}
-
-#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, "find: ");
-       (void)vfprintf(stderr, fmt, ap);
-       va_end(ap);
-       (void)fprintf(stderr, "\n");
-       exit(1);
-       /* NOTREACHED */
+               return (p);
+       err(1, NULL);
 }
 }
index b62add6..a706b88 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)operator.c 5.4 (Berkeley) 5/24/91";
+static char sccsid[] = "@(#)operator.c 8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
+
+#include <err.h>
+#include <fts.h>
 #include <stdio.h>
 #include <stdio.h>
+
 #include "find.h"
     
 /*
 #include "find.h"
     
 /*
@@ -53,10 +57,10 @@ yanknode(planp)
        PLAN *node;             /* top node removed from the plan */
     
        if ((node = (*planp)) == NULL)
        PLAN *node;             /* top node removed from the plan */
     
        if ((node = (*planp)) == NULL)
-               return(NULL);
+               return (NULL);
        (*planp) = (*planp)->next;
        node->next = NULL;
        (*planp) = (*planp)->next;
        node->next = NULL;
-       return(node);
+       return (node);
 }
  
 /*
 }
  
 /*
@@ -77,7 +81,7 @@ yankexpr(planp)
     
        /* first pull the top node from the plan */
        if ((node = yanknode(planp)) == NULL)
     
        /* first pull the top node from the plan */
        if ((node = yanknode(planp)) == NULL)
-               return(NULL);
+               return (NULL);
     
        /*
         * If the node is an '(' then we recursively slurp up expressions
     
        /*
         * If the node is an '(' then we recursively slurp up expressions
@@ -88,7 +92,7 @@ yankexpr(planp)
        if (node->type == N_OPENPAREN)
                for (tail = subplan = NULL;;) {
                        if ((next = yankexpr(planp)) == NULL)
        if (node->type == N_OPENPAREN)
                for (tail = subplan = NULL;;) {
                        if ((next = yankexpr(planp)) == NULL)
-                               err("%s: %s", "(", "missing closing ')'");
+                               err(1, "(: missing closing ')'");
                        /*
                         * If we find a closing ')' we store the collected
                         * subplan in our '(' node and convert the node to
                        /*
                         * If we find a closing ')' we store the collected
                         * subplan in our '(' node and convert the node to
@@ -98,8 +102,7 @@ yankexpr(planp)
                         */
                        if (next->type == N_CLOSEPAREN) {
                                if (subplan == NULL)
                         */
                        if (next->type == N_CLOSEPAREN) {
                                if (subplan == NULL)
-                                       err("%s: %s",
-                                           "()", "empty inner expression");
+                                       errx(1, "(): empty inner expression");
                                node->p_data[0] = subplan;
                                node->type = N_EXPR;
                                node->eval = f_expr;
                                node->p_data[0] = subplan;
                                node->type = N_EXPR;
                                node->eval = f_expr;
@@ -114,7 +117,7 @@ yankexpr(planp)
                                tail->next = NULL;
                        }
                }
                                tail->next = NULL;
                        }
                }
-       return(node);
+       return (node);
 }
  
 /*
 }
  
 /*
@@ -141,7 +144,7 @@ paren_squish(plan)
                 * '(' someplace.
                 */
                if (expr->type == N_CLOSEPAREN)
                 * '(' someplace.
                 */
                if (expr->type == N_CLOSEPAREN)
-                       err("%s: %s", ")", "no beginning '('");
+                       errx(1, "): no beginning '('");
 
                /* add the expression to our result plan */
                if (result == NULL)
 
                /* add the expression to our result plan */
                if (result == NULL)
@@ -152,7 +155,7 @@ paren_squish(plan)
                }
                tail->next = NULL;
        }
                }
                tail->next = NULL;
        }
-       return(result);
+       return (result);
 }
  
 /*
 }
  
 /*
@@ -192,9 +195,9 @@ not_squish(plan)
                                node = yanknode(&plan);
                        }
                        if (node == NULL)
                                node = yanknode(&plan);
                        }
                        if (node == NULL)
-                               err("%s: %s", "!", "no following expression");
+                               errx(1, "!: no following expression");
                        if (node->type == N_OR)
                        if (node->type == N_OR)
-                               err("%s: %s", "!", "nothing between ! and -o");
+                               errx(1, "!: nothing between ! and -o");
                        if (notlevel % 2 != 1)
                                next = node;
                        else
                        if (notlevel % 2 != 1)
                                next = node;
                        else
@@ -210,7 +213,7 @@ not_squish(plan)
                }
                tail->next = NULL;
        }
                }
                tail->next = NULL;
        }
-       return(result);
+       return (result);
 }
  
 /*
 }
  
 /*
@@ -246,12 +249,12 @@ or_squish(plan)
                 */
                if (next->type == N_OR) {
                        if (result == NULL)
                 */
                if (next->type == N_OR) {
                        if (result == NULL)
-                               err("%s: %s", "-o", "no expression before -o");
+                               errx(1, "-o: no expression before -o");
                        next->p_data[0] = result;
                        next->p_data[1] = or_squish(plan);
                        if (next->p_data[1] == NULL)
                        next->p_data[0] = result;
                        next->p_data[1] = or_squish(plan);
                        if (next->p_data[1] == NULL)
-                               err("%s: %s", "-o", "no expression after -o");
-                       return(next);
+                               errx(1, "-o: no expression after -o");
+                       return (next);
                }
 
                /* add the node to our result plan */
                }
 
                /* add the node to our result plan */
@@ -263,5 +266,5 @@ or_squish(plan)
                }
                tail->next = NULL;
        }
                }
                tail->next = NULL;
        }
-       return(result);
+       return (result);
 }
 }
index de3500c..87337ca 100644 (file)
@@ -1,6 +1,6 @@
 /*-
 /*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Cimarron D. Taylor of the University of California, Berkeley.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)option.c   5.11 (Berkeley) 8/21/91";
+static char sccsid[] = "@(#)option.c   8.1 (Berkeley) 6/6/93";
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#include <err.h>
 #include <fts.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <fts.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "find.h"
 
 
-typedef struct _option {
-       char *name;             /* option name */
-       enum ntype token;       /* token type */
-       PLAN *(*create)();      /* create function */
-#define        O_NONE          0x01    /* no call required */
-#define        O_ZERO          0x02    /* pass: nothing */
-#define        O_ARGV          0x04    /* pass: argv, increment argv */
-#define        O_ARGVP         0x08    /* pass: *argv, N_OK || N_EXEC */
-       int flags;
-} OPTION;
+#include "find.h"
 
 /* NB: the following table must be sorted lexically. */
 static OPTION options[] = {
 
 /* NB: the following table must be sorted lexically. */
 static OPTION options[] = {
-       "!",            N_NOT,          c_not,          O_ZERO,
-       "(",            N_OPENPAREN,    c_openparen,    O_ZERO,
-       ")",            N_CLOSEPAREN,   c_closeparen,   O_ZERO,
-       "-a",           N_AND,          NULL,           O_NONE,
-       "-and",         N_AND,          NULL,           O_NONE,
-       "-atime",       N_ATIME,        c_atime,        O_ARGV,
-       "-ctime",       N_CTIME,        c_ctime,        O_ARGV,
-       "-depth",       N_DEPTH,        c_depth,        O_ZERO,
-       "-exec",        N_EXEC,         c_exec,         O_ARGVP,
-       "-follow",      N_FOLLOW,       c_follow,       O_ZERO,
-       "-fstype",      N_FSTYPE,       c_fstype,       O_ARGV,
-       "-group",       N_GROUP,        c_group,        O_ARGV,
-       "-inum",        N_INUM,         c_inum,         O_ARGV,
-       "-links",       N_LINKS,        c_links,        O_ARGV,
-       "-ls",          N_LS,           c_ls,           O_ZERO,
-       "-mtime",       N_MTIME,        c_mtime,        O_ARGV,
-       "-name",        N_NAME,         c_name,         O_ARGV,
-       "-newer",       N_NEWER,        c_newer,        O_ARGV,
-       "-nogroup",     N_NOGROUP,      c_nogroup,      O_ZERO,
-       "-nouser",      N_NOUSER,       c_nouser,       O_ZERO,
-       "-o",           N_OR,           c_or,           O_ZERO,
-       "-ok",          N_OK,           c_exec,         O_ARGVP,
-       "-or",          N_OR,           c_or,           O_ZERO,
-       "-path",        N_PATH,         c_path,         O_ARGV,
-       "-perm",        N_PERM,         c_perm,         O_ARGV,
-       "-print",       N_PRINT,        c_print,        O_ZERO,
-       "-prune",       N_PRUNE,        c_prune,        O_ZERO,
-       "-size",        N_SIZE,         c_size,         O_ARGV,
-       "-type",        N_TYPE,         c_type,         O_ARGV,
-       "-user",        N_USER,         c_user,         O_ARGV,
-       "-xdev",        N_XDEV,         c_xdev,         O_ZERO,
+       { "!",          N_NOT,          c_not,          O_ZERO },
+       { "(",          N_OPENPAREN,    c_openparen,    O_ZERO },
+       { ")",          N_CLOSEPAREN,   c_closeparen,   O_ZERO },
+       { "-a",         N_AND,          NULL,           O_NONE },
+       { "-and",       N_AND,          NULL,           O_NONE },
+       { "-atime",     N_ATIME,        c_atime,        O_ARGV },
+       { "-ctime",     N_CTIME,        c_ctime,        O_ARGV },
+       { "-depth",     N_DEPTH,        c_depth,        O_ZERO },
+       { "-exec",      N_EXEC,         c_exec,         O_ARGVP },
+       { "-follow",    N_FOLLOW,       c_follow,       O_ZERO },
+       { "-fstype",    N_FSTYPE,       c_fstype,       O_ARGV },
+       { "-group",     N_GROUP,        c_group,        O_ARGV },
+       { "-inum",      N_INUM,         c_inum,         O_ARGV },
+       { "-links",     N_LINKS,        c_links,        O_ARGV },
+       { "-ls",        N_LS,           c_ls,           O_ZERO },
+       { "-mtime",     N_MTIME,        c_mtime,        O_ARGV },
+       { "-name",      N_NAME,         c_name,         O_ARGV },
+       { "-newer",     N_NEWER,        c_newer,        O_ARGV },
+       { "-nogroup",   N_NOGROUP,      c_nogroup,      O_ZERO },
+       { "-nouser",    N_NOUSER,       c_nouser,       O_ZERO },
+       { "-o",         N_OR,           c_or,           O_ZERO },
+       { "-ok",        N_OK,           c_exec,         O_ARGVP },
+       { "-or",        N_OR,           c_or,           O_ZERO },
+       { "-path",      N_PATH,         c_path,         O_ARGV },
+       { "-perm",      N_PERM,         c_perm,         O_ARGV },
+       { "-print",     N_PRINT,        c_print,        O_ZERO },
+       { "-prune",     N_PRUNE,        c_prune,        O_ZERO },
+       { "-size",      N_SIZE,         c_size,         O_ARGV },
+       { "-type",      N_TYPE,         c_type,         O_ARGV },
+       { "-user",      N_USER,         c_user,         O_ARGV },
+       { "-xdev",      N_XDEV,         c_xdev,         O_ZERO },
 };
 
 /*
 };
 
 /*
@@ -107,20 +99,14 @@ find_create(argvp)
        register OPTION *p;
        PLAN *new;
        char **argv;
        register OPTION *p;
        PLAN *new;
        char **argv;
-       OPTION *option();
 
        argv = *argvp;
 
 
        argv = *argvp;
 
-       if ((p = option(*argv)) == NULL) {
-               (void)fprintf(stderr, "find: unknown option %s.\n", *argv);
-               exit(1);
-       }
+       if ((p = option(*argv)) == NULL)
+               errx(1, "%s: unknown option", *argv);
        ++argv;
        ++argv;
-       if (p->flags & (O_ARGV|O_ARGVP) && !*argv) {
-               (void)fprintf(stderr,
-                   "find: %s requires additional arguments.\n", *--argv);
-               exit(1);
-       }
+       if (p->flags & (O_ARGV|O_ARGVP) && !*argv)
+               errx(1, "%s: requires additional arguments", *--argv);
 
        switch(p->flags) {
        case O_NONE:
 
        switch(p->flags) {
        case O_NONE:
@@ -135,9 +121,11 @@ find_create(argvp)
        case O_ARGVP:
                new = (p->create)(&argv, p->token == N_OK);
                break;
        case O_ARGVP:
                new = (p->create)(&argv, p->token == N_OK);
                break;
+       default:
+               abort();
        }
        *argvp = argv;
        }
        *argvp = argv;
-       return(new);
+       return (new);
 }
 
 OPTION *
 }
 
 OPTION *
@@ -148,12 +136,13 @@ option(name)
        int typecompare __P((const void *, const void *));
 
        tmp.name = name;
        int typecompare __P((const void *, const void *));
 
        tmp.name = name;
-       return((OPTION *)bsearch(&tmp, options,
+       return ((OPTION *)bsearch(&tmp, options,
            sizeof(options)/sizeof(OPTION), sizeof(OPTION), typecompare));
 }
            sizeof(options)/sizeof(OPTION), sizeof(OPTION), typecompare));
 }
-       
+
+int
 typecompare(a, b)
        const void *a, *b;
 {
 typecompare(a, b)
        const void *a, *b;
 {
-       return(strcmp(((OPTION *)a)->name, ((OPTION *)b)->name));
+       return (strcmp(((OPTION *)a)->name, ((OPTION *)b)->name));
 }
 }