BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.bin / find / function.c
index fe74c70..52f0ea6 100644 (file)
@@ -5,35 +5,51 @@
  * 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.
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)function.c 5.8 (Berkeley) 6/30/90";
+static char sccsid[] = "@(#)function.c 5.17 (Berkeley) 5/24/91";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #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 <errno.h>
 #include <grp.h>
 #include <pwd.h>
 #include <fts.h>
 #include <unistd.h>
 #include <tzfile.h>
 #include <stdio.h>
 #include <grp.h>
 #include <pwd.h>
 #include <fts.h>
 #include <unistd.h>
 #include <tzfile.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include "find.h"
 
 #include <string.h>
 #include "find.h"
 
@@ -53,13 +69,7 @@ static char sccsid[] = "@(#)function.c       5.8 (Berkeley) 6/30/90";
        return(0); \
 }
 
        return(0); \
 }
 
-#define NEW(t, f) { \
-       new = (PLAN *)emalloc(sizeof(PLAN)); \
-       new->type = t; \
-       new->eval = f; \
-       new->flags = 0; \
-       new->next = NULL; \
-}
+static PLAN *palloc __P((enum ntype, int (*)()));
 
 /*
  * find_parsenum --
 
 /*
  * find_parsenum --
@@ -96,7 +106,7 @@ find_parsenum(plan, option, str, endch)
        value = strtol(str, &endchar, 10);
        if (!value && endchar == str ||
            endchar[0] && (!endch || endchar[0] != *endch))
        value = strtol(str, &endchar, 10);
        if (!value && endchar == str ||
            endchar[0] && (!endch || endchar[0] != *endch))
-               bad_arg(option, "illegal numeric value");
+               err("%s: %s", option, "illegal numeric value");
        if (endch)
                *endch = endchar[0];
        return(value);
        if (endch)
                *endch = endchar[0];
        return(value);
@@ -127,8 +137,8 @@ c_atime(arg)
 
        ftsoptions &= ~FTS_NOSTAT;
 
 
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_ATIME, f_atime);
-       new->t_data = find_parsenum(new, "-atime", arg, (char *)NULL);
+       new = palloc(N_ATIME, f_atime);
+       new->t_data = find_parsenum(new, "-atime", arg, NULL);
        return(new);
 }
 /*
        return(new);
 }
 /*
@@ -155,7 +165,7 @@ c_ctime(arg)
 
        ftsoptions &= ~FTS_NOSTAT;
 
 
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_CTIME, f_ctime);
+       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, (char *)NULL);
        return(new);
 }
@@ -178,13 +188,9 @@ f_always_true(plan, entry)
 PLAN *
 c_depth()
 {
 PLAN *
 c_depth()
 {
-       extern int depth;
-       PLAN *new;
-    
-       depth = 1;
+       isdepth = 1;
 
 
-       NEW(T_DEPTH, f_always_true);
-       return(new);
+       return(palloc(N_DEPTH, f_always_true));
 }
  
 /*
 }
  
 /*
@@ -203,33 +209,36 @@ f_exec(plan, entry)
        register PLAN *plan;
        FTSENT *entry;
 {
        register PLAN *plan;
        FTSENT *entry;
 {
+       extern int dotfd;
        register int cnt;
        register int cnt;
-       char *find_subst();
-       union wait pstat;
-       pid_t pid, waitpid();
+       pid_t pid;
+       int status;
 
        for (cnt = 0; plan->e_argv[cnt]; ++cnt)
                if (plan->e_len[cnt])
 
        for (cnt = 0; plan->e_argv[cnt]; ++cnt)
                if (plan->e_len[cnt])
-                       find_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
+                       brace_subst(plan->e_orig[cnt], &plan->e_argv[cnt],
                            entry->fts_path, plan->e_len[cnt]);
 
                            entry->fts_path, plan->e_len[cnt]);
 
-       if (plan->flags && !find_queryuser(plan->e_argv))
+       if (plan->flags && !queryuser(plan->e_argv))
                return(0);
 
        switch(pid = vfork()) {
        case -1:
                return(0);
 
        switch(pid = vfork()) {
        case -1:
-               (void)fprintf(stderr, "find: fork: %s.\n", strerror(errno));
-               exit(1);
+               err("fork: %s", strerror(errno));
                /* NOTREACHED */
        case 0:
                /* NOTREACHED */
        case 0:
+               if (fchdir(dotfd)) {
+                       (void)fprintf(stderr,
+                           "find: chdir: %s\n", strerror(errno));
+                       _exit(1);
+               }
                execvp(plan->e_argv[0], plan->e_argv);
                (void)fprintf(stderr,
                execvp(plan->e_argv[0], plan->e_argv);
                (void)fprintf(stderr,
-                   "find: %s: %s.\n", plan->e_argv[0], strerror(errno));
-               exit(1);
-               /* NOTREACHED */
+                   "find: %s: %s\n", plan->e_argv[0], strerror(errno));
+               _exit(1);
        }
        }
-       pid = waitpid(pid, &pstat, 0);
-       return(pid != -1 && !pstat.w_status);
+       pid = waitpid(pid, &status, 0);
+       return(pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status));
 }
  
 /*
 }
  
 /*
@@ -248,15 +257,15 @@ c_exec(argvp, isok)
        register int cnt;
        register char **argv, **ap, *p;
 
        register int cnt;
        register char **argv, **ap, *p;
 
-       ftsoptions |= FTS_NOCHDIR;
-       output_specified = 1;
+       isoutput = 1;
     
     
-       NEW(T_EXEC, f_exec);
+       new = palloc(N_EXEC, f_exec);
        new->flags = isok;
 
        for (ap = argv = *argvp;; ++ap) {
                if (!*ap)
        new->flags = isok;
 
        for (ap = argv = *argvp;; ++ap) {
                if (!*ap)
-                       bad_arg(isok ? "-ok" : "-exec", "no terminating \";\"");
+                       err("%s: %s",
+                           isok ? "-ok" : "-exec", "no terminating \";\"");
                if (**ap == ';')
                        break;
        }
                if (**ap == ';')
                        break;
        }
@@ -264,14 +273,14 @@ c_exec(argvp, isok)
        cnt = ap - *argvp + 1;
        new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
        new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
        cnt = ap - *argvp + 1;
        new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *));
        new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *));
-       new->e_len = (int *)emalloc((u_int)cnt * sizeof(u_char));
+       new->e_len = (int *)emalloc((u_int)cnt * sizeof(int));
 
        for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
                new->e_orig[cnt] = *argv;
                for (p = *argv; *p; ++p)
                        if (p[0] == '{' && p[1] == '}') {
 
        for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
                new->e_orig[cnt] = *argv;
                for (p = *argv; *p; ++p)
                        if (p[0] == '{' && p[1] == '}') {
-                               new->e_argv[cnt] = emalloc((u_int)1024);
-                               new->e_len[cnt] = 1024;
+                               new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN);
+                               new->e_len[cnt] = MAXPATHLEN;
                                break;
                        }
                if (!*p) {
                                break;
                        }
                if (!*p) {
@@ -294,13 +303,10 @@ c_exec(argvp, isok)
 PLAN *
 c_follow()
 {
 PLAN *
 c_follow()
 {
-       PLAN *new;
-    
        ftsoptions &= ~FTS_PHYSICAL;
        ftsoptions |= FTS_LOGICAL;
 
        ftsoptions &= ~FTS_PHYSICAL;
        ftsoptions |= FTS_LOGICAL;
 
-       NEW(T_FOLLOW, f_always_true);
-       return(new);
+       return(palloc(N_FOLLOW, f_always_true));
 }
  
 /*
 }
  
 /*
@@ -316,15 +322,38 @@ f_fstype(plan, entry)
        static int first = 1;
        struct statfs sb;
        static short val;
        static int first = 1;
        struct statfs sb;
        static short val;
+       char *p, save[2];
 
        /* only check when we cross mount point */
        if (first || curdev != entry->fts_statb.st_dev) {
                curdev = entry->fts_statb.st_dev;
 
        /* only check when we cross mount point */
        if (first || curdev != entry->fts_statb.st_dev) {
                curdev = entry->fts_statb.st_dev;
-               if (statfs(entry->fts_accpath, &sb)) {
-                       (void)fprintf(stderr, "find: %s: %s.\n",
-                           entry->fts_accpath, strerror(errno));
-                       exit(1);
+
+               /*
+                * Statfs follows symlinks; find wants the link's file system,
+                * not where it points.
+                */
+               if (entry->fts_info == FTS_SL ||
+                   entry->fts_info == FTS_SLNONE) {
+                       if (p = rindex(entry->fts_accpath, '/'))
+                               ++p;
+                       else
+                               p = entry->fts_accpath;
+                       save[0] = p[0];
+                       p[0] = '.';
+                       save[1] = p[1];
+                       p[1] = '\0';
+                       
+               } else 
+                       p = NULL;
+
+               if (statfs(entry->fts_accpath, &sb))
+                       err("%s: %s", entry->fts_accpath, strerror(errno));
+
+               if (p) {
+                       p[0] = save[0];
+                       p[1] = save[1];
                }
                }
+
                first = 0;
                val = plan->flags == MOUNT_NONE ? sb.f_flags : sb.f_type;
        }
                first = 0;
                val = plan->flags == MOUNT_NONE ? sb.f_flags : sb.f_type;
        }
@@ -340,7 +369,7 @@ c_fstype(arg)
     
        ftsoptions &= ~FTS_NOSTAT;
     
     
        ftsoptions &= ~FTS_NOSTAT;
     
-       NEW(T_FSTYPE, f_fstype);
+       new = palloc(N_FSTYPE, f_fstype);
        switch(*arg) {
        case 'l':
                if (!strcmp(arg, "local")) {
        switch(*arg) {
        case 'l':
                if (!strcmp(arg, "local")) {
@@ -373,8 +402,7 @@ c_fstype(arg)
                }
                break;
        }
                }
                break;
        }
-       (void)fprintf(stderr, "find: unknown file type %s.\n", arg);
-       exit(1);
+       err("unknown file type %s", arg);
        /* NOTREACHED */
 }
  
        /* NOTREACHED */
 }
  
@@ -406,11 +434,11 @@ 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')
-                       bad_arg("-group", "no such group");
+                       err("%s: %s", "-group", "no such group");
        } else
                gid = g->gr_gid;
     
        } else
                gid = g->gr_gid;
     
-       NEW(T_GROUP, f_group);
+       new = palloc(N_GROUP, f_group);
        new->g_data = gid;
        return(new);
 }
        new->g_data = gid;
        return(new);
 }
@@ -435,7 +463,7 @@ c_inum(arg)
     
        ftsoptions &= ~FTS_NOSTAT;
     
     
        ftsoptions &= ~FTS_NOSTAT;
     
-       NEW(T_INUM, f_inum);
+       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, (char *)NULL);
        return(new);
 }
@@ -460,8 +488,8 @@ c_links(arg)
     
        ftsoptions &= ~FTS_NOSTAT;
     
     
        ftsoptions &= ~FTS_NOSTAT;
     
-       NEW(T_LINKS, f_links);
-       new->l_data = find_parsenum(new, "-links", arg, (char *)NULL);
+       new = palloc(N_LINKS, f_links);
+       new->l_data = (nlink_t)find_parsenum(new, "-links", arg, (char *)NULL);
        return(new);
 }
  
        return(new);
 }
  
@@ -482,13 +510,10 @@ f_ls(plan, entry)
 PLAN *
 c_ls()
 {
 PLAN *
 c_ls()
 {
-       PLAN *new;
-    
        ftsoptions &= ~FTS_NOSTAT;
        ftsoptions &= ~FTS_NOSTAT;
-       output_specified = 1;
+       isoutput = 1;
     
     
-       NEW(T_LS, f_ls);
-       return(new);
+       return(palloc(N_LS, f_ls));
 }
 
 /*
 }
 
 /*
@@ -510,7 +535,7 @@ c_name(pattern)
 {
        PLAN *new;
 
 {
        PLAN *new;
 
-       NEW(T_NAME, f_name);
+       new = palloc(N_NAME, f_name);
        new->c_data = pattern;
        return(new);
 }
        new->c_data = pattern;
        return(new);
 }
@@ -538,12 +563,9 @@ c_newer(filename)
     
        ftsoptions &= ~FTS_NOSTAT;
 
     
        ftsoptions &= ~FTS_NOSTAT;
 
-       if (stat(filename, &sb)) {
-               (void)fprintf(stderr, "find: %s: %s.\n",
-                   filename, strerror(errno));
-               exit(1);
-       }
-       NEW(T_NEWER, f_newer);
+       if (stat(filename, &sb))
+               err("%s: %s", filename, strerror(errno));
+       new = palloc(N_NEWER, f_newer);
        new->t_data = sb.st_mtime;
        return(new);
 }
        new->t_data = sb.st_mtime;
        return(new);
 }
@@ -559,18 +581,17 @@ f_nogroup(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        PLAN *plan;
        FTSENT *entry;
 {
-       return(group_from_gid(entry->fts_statb.st_gid, 1));
+       char *group_from_gid();
+
+       return(group_from_gid(entry->fts_statb.st_gid, 1) ? 1 : 0);
 }
  
 PLAN *
 c_nogroup()
 {
 }
  
 PLAN *
 c_nogroup()
 {
-       PLAN *new;
-    
        ftsoptions &= ~FTS_NOSTAT;
 
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_NOGROUP, f_nogroup);
-       return(new);
+       return(palloc(N_NOGROUP, f_nogroup));
 }
  
 /*
 }
  
 /*
@@ -584,18 +605,17 @@ f_nouser(plan, entry)
        PLAN *plan;
        FTSENT *entry;
 {
        PLAN *plan;
        FTSENT *entry;
 {
-       return(user_from_uid(entry->fts_statb.st_uid, 1));
+       char *user_from_uid();
+
+       return(user_from_uid(entry->fts_statb.st_uid, 1) ? 1 : 0);
 }
  
 PLAN *
 c_nouser()
 {
 }
  
 PLAN *
 c_nouser()
 {
-       PLAN *new;
-    
        ftsoptions &= ~FTS_NOSTAT;
 
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_NOUSER, f_nouser);
-       return(new);
+       return(palloc(N_NOUSER, f_nouser));
 }
  
 /*
 }
  
 /*
@@ -625,11 +645,11 @@ c_perm(perm)
        char *perm;
 {
        PLAN *new;
        char *perm;
 {
        PLAN *new;
-       mode_t *set, *setmode();
+       mode_t *set;
 
        ftsoptions &= ~FTS_NOSTAT;
 
 
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_PERM, f_perm);
+       new = palloc(N_PERM, f_perm);
 
        if (*perm == '-') {
                new->flags = 1;
 
        if (*perm == '-') {
                new->flags = 1;
@@ -637,7 +657,7 @@ c_perm(perm)
        }
 
        if ((set = setmode(perm)) == NULL)
        }
 
        if ((set = setmode(perm)) == NULL)
-               bad_arg("-perm", "illegal mode string");
+               err("%s: %s", "-perm", "illegal mode string");
 
        new->m_data = getmode(set, 0);
        return(new);
 
        new->m_data = getmode(set, 0);
        return(new);
@@ -661,12 +681,9 @@ f_print(plan, entry)
 PLAN *
 c_print()
 {
 PLAN *
 c_print()
 {
-       PLAN *new;
-    
-       output_specified = 1;
+       isoutput = 1;
 
 
-       NEW(T_PRINT, f_print);
-       return(new);
+       return(palloc(N_PRINT, f_print));
 }
  
 /*
 }
  
 /*
@@ -681,21 +698,15 @@ f_prune(plan, entry)
 {
        extern FTS *tree;
 
 {
        extern FTS *tree;
 
-       if (ftsset(tree, entry, FTS_SKIP)) {
-               (void)fprintf(stderr,
-                   "find: %s: %s.\n", entry->fts_path, strerror(errno));
-               exit(1);
-       }
+       if (fts_set(tree, entry, FTS_SKIP))
+               err("%s: %s", entry->fts_path, strerror(errno));
        return(1);
 }
  
 PLAN *
 c_prune()
 {
        return(1);
 }
  
 PLAN *
 c_prune()
 {
-       PLAN *new;
-
-       NEW(T_PRUNE, f_prune);
-       return(new);
+       return(palloc(N_PRUNE, f_prune));
 }
  
 /*
 }
  
 /*
@@ -728,7 +739,7 @@ c_size(arg)
     
        ftsoptions &= ~FTS_NOSTAT;
 
     
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_SIZE, f_size);
+       new = palloc(N_SIZE, f_size);
        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;
@@ -781,10 +792,10 @@ c_type(typestring)
                mask = S_IFSOCK;
                break;
        default:
                mask = S_IFSOCK;
                break;
        default:
-               bad_arg("-type", "unknown type");
+               err("%s: %s", "-type", "unknown type");
        }
     
        }
     
-       NEW(T_TYPE, f_type);
+       new = palloc(N_TYPE, f_type);
        new->m_data = mask;
        return(new);
 }
        new->m_data = mask;
        return(new);
 }
@@ -817,11 +828,11 @@ 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')
-                       bad_arg("-user", "no such user");
+                       err("%s: %s", "-user", "no such user");
        } else
                uid = p->pw_uid;
 
        } else
                uid = p->pw_uid;
 
-       NEW(T_USER, f_user);
+       new = palloc(N_USER, f_user);
        new->u_data = uid;
        return(new);
 }
        new->u_data = uid;
        return(new);
 }
@@ -835,13 +846,9 @@ c_user(username)
 PLAN *
 c_xdev()
 {
 PLAN *
 c_xdev()
 {
-       PLAN *new;
-    
-       ftsoptions &= ~FTS_NOSTAT;
        ftsoptions |= FTS_XDEV;
 
        ftsoptions |= FTS_XDEV;
 
-       NEW(T_XDEV, f_always_true);
-       return(new);
+       return(palloc(N_XDEV, f_always_true));
 }
 
 /*
 }
 
 /*
@@ -862,26 +869,20 @@ f_expr(plan, entry)
 }
  
 /*
 }
  
 /*
- * T_OPENPAREN and T_CLOSEPAREN nodes are temporary place markers.  They are
+ * N_OPENPAREN and N_CLOSEPAREN nodes are temporary place markers.  They are
  * eliminated during phase 2 of find_formplan() --- the '(' node is converted
  * eliminated during phase 2 of find_formplan() --- the '(' node is converted
- * to a T_EXPR node containing the expression and the ')' node is discarded.
+ * to a N_EXPR node containing the expression and the ')' node is discarded.
  */
 PLAN *
 c_openparen()
 {
  */
 PLAN *
 c_openparen()
 {
-       PLAN *new;
-
-       NEW(T_OPENPAREN, (int (*)())-1);
-       return(new);
+       return(palloc(N_OPENPAREN, (int (*)())-1));
 }
  
 PLAN *
 c_closeparen()
 {
 }
  
 PLAN *
 c_closeparen()
 {
-       PLAN *new;
-
-       NEW(T_CLOSEPAREN, (int (*)())-1);
-       return(new);
+       return(palloc(N_CLOSEPAREN, (int (*)())-1));
 }
  
 /*
 }
  
 /*
@@ -908,7 +909,7 @@ c_mtime(arg)
 
        ftsoptions &= ~FTS_NOSTAT;
 
 
        ftsoptions &= ~FTS_NOSTAT;
 
-       NEW(T_MTIME, f_mtime);
+       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, (char *)NULL);
        return(new);
 }
@@ -933,10 +934,7 @@ f_not(plan, entry)
 PLAN *
 c_not()
 {
 PLAN *
 c_not()
 {
-       PLAN *new;
-
-       NEW(T_NOT, f_not);
-       return(new);
+       return(palloc(N_NOT, f_not));
 }
  
 /*
 }
  
 /*
@@ -965,9 +963,24 @@ f_or(plan, entry)
 
 PLAN *
 c_or()
 
 PLAN *
 c_or()
+{
+       return(palloc(N_OR, f_or));
+}
+
+static PLAN *
+palloc(t, f)
+       enum ntype t;
+       int (*f)();
 {
        PLAN *new;
 
 {
        PLAN *new;
 
-       NEW(T_OR, f_or);
-       return(new);
+       if (new = malloc(sizeof(PLAN))) {
+               new->type = t;
+               new->eval = f;
+               new->flags = 0;
+               new->next = NULL;
+               return(new);
+       }
+       err("%s", strerror(errno));
+       /* NOTREACHED */
 }
 }