Simplify the function calling code and warnsify.
This commit is contained in:
parent
ea04275578
commit
9a80b4fa85
@ -1,7 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.6 1998/02/02 14:02:06 mrg Exp $
|
||||
# $NetBSD: Makefile,v 1.7 1998/02/21 22:47:20 christos Exp $
|
||||
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||
|
||||
WARNS= 0
|
||||
PROG= find
|
||||
SRCS= find.c function.c ls.c main.c misc.c operator.c option.c
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.7 1998/02/02 14:02:12 mrg Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.8 1998/02/21 22:47:20 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -50,33 +50,34 @@ struct stat;
|
||||
void printlong __P((char *, char *, struct stat *));
|
||||
int queryuser __P((char **));
|
||||
|
||||
PLAN *c_atime __P((char *));
|
||||
PLAN *c_ctime __P((char *));
|
||||
PLAN *c_depth __P((void));
|
||||
PLAN *c_atime __P((char ***, int));
|
||||
PLAN *c_ctime __P((char ***, int));
|
||||
PLAN *c_depth __P((char ***, int));
|
||||
PLAN *c_exec __P((char ***, int));
|
||||
PLAN *c_follow __P((void));
|
||||
PLAN *c_fstype __P((char *));
|
||||
PLAN *c_group __P((char *));
|
||||
PLAN *c_inum __P((char *));
|
||||
PLAN *c_links __P((char *));
|
||||
PLAN *c_ls __P((void));
|
||||
PLAN *c_name __P((char *));
|
||||
PLAN *c_newer __P((char *));
|
||||
PLAN *c_nogroup __P((void));
|
||||
PLAN *c_nouser __P((void));
|
||||
PLAN *c_path __P((char *));
|
||||
PLAN *c_perm __P((char *));
|
||||
PLAN *c_print __P((void));
|
||||
PLAN *c_print0 __P((void));
|
||||
PLAN *c_prune __P((void));
|
||||
PLAN *c_size __P((char *));
|
||||
PLAN *c_type __P((char *));
|
||||
PLAN *c_user __P((char *));
|
||||
PLAN *c_xdev __P((void));
|
||||
PLAN *c_openparen __P((void));
|
||||
PLAN *c_closeparen __P((void));
|
||||
PLAN *c_mtime __P((char *));
|
||||
PLAN *c_not __P((void));
|
||||
PLAN *c_or __P((void));
|
||||
PLAN *c_follow __P((char ***, int));
|
||||
PLAN *c_fstype __P((char ***, int));
|
||||
PLAN *c_group __P((char ***, int));
|
||||
PLAN *c_inum __P((char ***, int));
|
||||
PLAN *c_links __P((char ***, int));
|
||||
PLAN *c_ls __P((char ***, int));
|
||||
PLAN *c_name __P((char ***, int));
|
||||
PLAN *c_newer __P((char ***, int));
|
||||
PLAN *c_nogroup __P((char ***, int));
|
||||
PLAN *c_nouser __P((char ***, int));
|
||||
PLAN *c_path __P((char ***, int));
|
||||
PLAN *c_perm __P((char ***, int));
|
||||
PLAN *c_print __P((char ***, int));
|
||||
PLAN *c_print0 __P((char ***, int));
|
||||
PLAN *c_prune __P((char ***, int));
|
||||
PLAN *c_size __P((char ***, int));
|
||||
PLAN *c_type __P((char ***, int));
|
||||
PLAN *c_user __P((char ***, int));
|
||||
PLAN *c_xdev __P((char ***, int));
|
||||
PLAN *c_openparen __P((char ***, int));
|
||||
PLAN *c_closeparen __P((char ***, int));
|
||||
PLAN *c_mtime __P((char ***, int));
|
||||
PLAN *c_not __P((char ***, int));
|
||||
PLAN *c_or __P((char ***, int));
|
||||
PLAN *c_null __P((char ***, int));
|
||||
|
||||
extern int ftsoptions, isdeprecated, isdepth, isoutput, isxargs;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: find.c,v 1.10 1998/02/02 14:02:16 mrg Exp $ */
|
||||
/* $NetBSD: find.c,v 1.11 1998/02/21 22:47:20 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993, 1994
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)find.c 8.5 (Berkeley) 8/5/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: find.c,v 1.10 1998/02/02 14:02:16 mrg Exp $");
|
||||
__RCSID("$NetBSD: find.c,v 1.11 1998/02/21 22:47:20 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -102,16 +102,16 @@ find_formplan(argv)
|
||||
*/
|
||||
if (!isoutput) {
|
||||
if (plan == NULL) {
|
||||
new = c_print();
|
||||
new = c_print(NULL, 0);
|
||||
tail = plan = new;
|
||||
} else {
|
||||
new = c_openparen();
|
||||
new = c_openparen(NULL, 0);
|
||||
new->next = plan;
|
||||
plan = new;
|
||||
new = c_closeparen();
|
||||
new = c_closeparen(NULL, 0);
|
||||
tail->next = new;
|
||||
tail = new;
|
||||
new = c_print();
|
||||
new = c_print(NULL, 0);
|
||||
tail->next = new;
|
||||
tail = new;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: find.h,v 1.7 1998/02/02 14:02:19 mrg Exp $ */
|
||||
/* $NetBSD: find.h,v 1.8 1998/02/21 22:47:20 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -98,12 +98,9 @@ typedef struct _plandata {
|
||||
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;
|
||||
PLAN *(*create) /* create function */
|
||||
__P((char ***, int));
|
||||
int arg; /* function needs arg */
|
||||
} OPTION;
|
||||
|
||||
#include "extern.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: function.c,v 1.23 1998/02/03 01:04:27 mrg Exp $ */
|
||||
/* $NetBSD: function.c,v 1.24 1998/02/21 22:47:20 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: function.c,v 1.23 1998/02/03 01:04:27 mrg Exp $");
|
||||
__RCSID("$NetBSD: function.c,v 1.24 1998/02/21 22:47:20 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -176,11 +176,14 @@ f_atime(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_atime(arg)
|
||||
char *arg;
|
||||
c_atime(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_ATIME, f_atime);
|
||||
@ -206,11 +209,14 @@ f_ctime(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_ctime(arg)
|
||||
char *arg;
|
||||
c_ctime(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_CTIME, f_ctime);
|
||||
@ -235,7 +241,9 @@ f_always_true(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_depth()
|
||||
c_depth(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
isdepth = 1;
|
||||
|
||||
@ -354,7 +362,9 @@ c_exec(argvp, isok)
|
||||
* basis.
|
||||
*/
|
||||
PLAN *
|
||||
c_follow()
|
||||
c_follow(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
ftsoptions &= ~FTS_PHYSICAL;
|
||||
ftsoptions |= FTS_LOGICAL;
|
||||
@ -429,11 +439,14 @@ f_fstype(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_fstype(arg)
|
||||
char *arg;
|
||||
c_fstype(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_FSTYPE, f_fstype);
|
||||
@ -476,13 +489,16 @@ f_group(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_group(gname)
|
||||
char *gname;
|
||||
c_group(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *gname = **argvp;
|
||||
PLAN *new;
|
||||
struct group *g;
|
||||
gid_t gid;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
g = getgrnam(gname);
|
||||
@ -512,11 +528,14 @@ f_inum(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_inum(arg)
|
||||
char *arg;
|
||||
c_inum(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_INUM, f_inum);
|
||||
@ -538,11 +557,14 @@ f_links(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_links(arg)
|
||||
char *arg;
|
||||
c_links(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_LINKS, f_links);
|
||||
@ -565,7 +587,9 @@ f_ls(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_ls()
|
||||
c_ls(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
isoutput = 1;
|
||||
@ -591,11 +615,14 @@ f_mtime(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_mtime(arg)
|
||||
char *arg;
|
||||
c_mtime(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_MTIME, f_mtime);
|
||||
@ -619,11 +646,14 @@ f_name(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_name(pattern)
|
||||
char *pattern;
|
||||
c_name(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *pattern = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
new = palloc(N_NAME, f_name);
|
||||
new->c_data = pattern;
|
||||
return (new);
|
||||
@ -645,12 +675,15 @@ f_newer(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_newer(filename)
|
||||
char *filename;
|
||||
c_newer(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *filename = **argvp;
|
||||
PLAN *new;
|
||||
struct stat sb;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
if (stat(filename, &sb))
|
||||
@ -676,7 +709,9 @@ f_nogroup(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_nogroup()
|
||||
c_nogroup(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
@ -699,7 +734,9 @@ f_nouser(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_nouser()
|
||||
c_nouser(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
@ -721,11 +758,14 @@ f_path(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_path(pattern)
|
||||
char *pattern;
|
||||
c_path(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *pattern = **argvp;
|
||||
PLAN *new;
|
||||
|
||||
(*argvp)++;
|
||||
new = palloc(N_NAME, f_path);
|
||||
new->c_data = pattern;
|
||||
return (new);
|
||||
@ -755,12 +795,15 @@ f_perm(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_perm(perm)
|
||||
char *perm;
|
||||
c_perm(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *perm = **argvp;
|
||||
PLAN *new;
|
||||
mode_t *set;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_PERM, f_perm);
|
||||
@ -803,7 +846,9 @@ f_print0(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_print()
|
||||
c_print(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
isoutput = 1;
|
||||
|
||||
@ -811,7 +856,9 @@ c_print()
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_print0()
|
||||
c_print0(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
isoutput = 1;
|
||||
|
||||
@ -836,7 +883,9 @@ f_prune(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_prune()
|
||||
c_prune(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
return (palloc(N_PRUNE, f_prune));
|
||||
}
|
||||
@ -864,12 +913,15 @@ f_size(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_size(arg)
|
||||
char *arg;
|
||||
c_size(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *arg = **argvp;
|
||||
PLAN *new;
|
||||
char endch;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_SIZE, f_size);
|
||||
@ -896,12 +948,15 @@ f_type(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_type(typestring)
|
||||
char *typestring;
|
||||
c_type(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *typestring = **argvp;
|
||||
PLAN *new;
|
||||
mode_t mask;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
switch (typestring[0]) {
|
||||
@ -965,13 +1020,16 @@ f_user(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_user(username)
|
||||
char *username;
|
||||
c_user(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
char *username = **argvp;
|
||||
PLAN *new;
|
||||
struct passwd *p;
|
||||
uid_t uid;
|
||||
|
||||
(*argvp)++;
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
p = getpwnam(username);
|
||||
@ -994,7 +1052,9 @@ c_user(username)
|
||||
* different device ID (st_dev, see stat() S5.6.2 [POSIX.1])
|
||||
*/
|
||||
PLAN *
|
||||
c_xdev()
|
||||
c_xdev(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
ftsoptions |= FTS_XDEV;
|
||||
|
||||
@ -1026,13 +1086,17 @@ f_expr(plan, entry)
|
||||
* to a N_EXPR node containing the expression and the ')' node is discarded.
|
||||
*/
|
||||
PLAN *
|
||||
c_openparen()
|
||||
c_openparen(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
return (palloc(N_OPENPAREN, (int (*) __P((PLAN *, FTSENT *)))-1));
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_closeparen()
|
||||
c_closeparen(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
return (palloc(N_CLOSEPAREN, (int (*) __P((PLAN *, FTSENT *)))-1));
|
||||
}
|
||||
@ -1057,7 +1121,9 @@ f_not(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_not()
|
||||
c_not(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
return (palloc(N_NOT, f_not));
|
||||
}
|
||||
@ -1089,11 +1155,21 @@ f_or(plan, entry)
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_or()
|
||||
c_or(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
return (palloc(N_OR, f_or));
|
||||
}
|
||||
|
||||
PLAN *
|
||||
c_null(argvp, isok)
|
||||
char ***argvp;
|
||||
int isok;
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static PLAN *
|
||||
palloc(t, f)
|
||||
enum ntype t;
|
||||
@ -1102,7 +1178,7 @@ palloc(t, f)
|
||||
PLAN *new;
|
||||
|
||||
if ((new = malloc(sizeof(PLAN))) == NULL)
|
||||
err(1, NULL);
|
||||
err(1, "%s", "");
|
||||
new->type = t;
|
||||
new->eval = f;
|
||||
new->flags = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: operator.c,v 1.5 1997/10/19 11:52:55 lukem Exp $ */
|
||||
/* $NetBSD: operator.c,v 1.6 1998/02/21 22:47:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)operator.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: operator.c,v 1.5 1997/10/19 11:52:55 lukem Exp $");
|
||||
__RCSID("$NetBSD: operator.c,v 1.6 1998/02/21 22:47:21 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -53,6 +53,9 @@ __RCSID("$NetBSD: operator.c,v 1.5 1997/10/19 11:52:55 lukem Exp $");
|
||||
|
||||
#include "find.h"
|
||||
|
||||
static PLAN *yanknode __P((PLAN **));
|
||||
static PLAN *yankexpr __P((PLAN **));
|
||||
|
||||
/*
|
||||
* yanknode --
|
||||
* destructively removes the top from the plan
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: option.c,v 1.8 1998/02/02 14:02:28 mrg Exp $ */
|
||||
/* $NetBSD: option.c,v 1.9 1998/02/21 22:47:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993, 1994
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "from: @(#)option.c 8.2 (Berkeley) 4/16/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: option.c,v 1.8 1998/02/02 14:02:28 mrg Exp $");
|
||||
__RCSID("$NetBSD: option.c,v 1.9 1998/02/21 22:47:21 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -61,38 +61,38 @@ static OPTION *option __P((char *));
|
||||
|
||||
/* NB: the following table must be sorted lexically. */
|
||||
static OPTION const 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 },
|
||||
{ "-print0", N_PRINT0, c_print0, 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, 0 },
|
||||
{ "(", N_OPENPAREN, c_openparen, 0 },
|
||||
{ ")", N_CLOSEPAREN, c_closeparen, 0 },
|
||||
{ "-a", N_AND, c_null, 0 },
|
||||
{ "-and", N_AND, c_null, 0 },
|
||||
{ "-atime", N_ATIME, c_atime, 1 },
|
||||
{ "-ctime", N_CTIME, c_ctime, 1 },
|
||||
{ "-depth", N_DEPTH, c_depth, 0 },
|
||||
{ "-exec", N_EXEC, c_exec, 1 },
|
||||
{ "-follow", N_FOLLOW, c_follow, 0 },
|
||||
{ "-fstype", N_FSTYPE, c_fstype, 1 },
|
||||
{ "-group", N_GROUP, c_group, 1 },
|
||||
{ "-inum", N_INUM, c_inum, 1 },
|
||||
{ "-links", N_LINKS, c_links, 1 },
|
||||
{ "-ls", N_LS, c_ls, 0 },
|
||||
{ "-mtime", N_MTIME, c_mtime, 1 },
|
||||
{ "-name", N_NAME, c_name, 1 },
|
||||
{ "-newer", N_NEWER, c_newer, 1 },
|
||||
{ "-nogroup", N_NOGROUP, c_nogroup, 0 },
|
||||
{ "-nouser", N_NOUSER, c_nouser, 0 },
|
||||
{ "-o", N_OR, c_or, 0 },
|
||||
{ "-ok", N_OK, c_exec, 1 },
|
||||
{ "-or", N_OR, c_or, 0 },
|
||||
{ "-path", N_PATH, c_path, 1 },
|
||||
{ "-perm", N_PERM, c_perm, 1 },
|
||||
{ "-print", N_PRINT, c_print, 0 },
|
||||
{ "-print0", N_PRINT0, c_print0, 0 },
|
||||
{ "-prune", N_PRUNE, c_prune, 0 },
|
||||
{ "-size", N_SIZE, c_size, 1 },
|
||||
{ "-type", N_TYPE, c_type, 1 },
|
||||
{ "-user", N_USER, c_user, 1 },
|
||||
{ "-xdev", N_XDEV, c_xdev, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
@ -116,25 +116,11 @@ find_create(argvp)
|
||||
if ((p = option(*argv)) == NULL)
|
||||
errx(1, "%s: unknown option", *argv);
|
||||
++argv;
|
||||
if (p->flags & (O_ARGV|O_ARGVP) && !*argv)
|
||||
if (p->arg && !*argv)
|
||||
errx(1, "%s: requires additional arguments", *--argv);
|
||||
|
||||
switch(p->flags) {
|
||||
case O_NONE:
|
||||
new = NULL;
|
||||
break;
|
||||
case O_ZERO:
|
||||
new = (p->create)();
|
||||
break;
|
||||
case O_ARGV:
|
||||
new = (p->create)(*argv++);
|
||||
break;
|
||||
case O_ARGVP:
|
||||
new = (p->create)(&argv, p->token == N_OK);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
*argvp = argv;
|
||||
return (new);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user