diff --git a/usr.bin/find/Makefile b/usr.bin/find/Makefile index 093fca912684..d4a9560c427d 100644 --- a/usr.bin/find/Makefile +++ b/usr.bin/find/Makefile @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.10 2006/08/26 18:17:42 christos Exp $ +# $NetBSD: Makefile,v 1.11 2006/10/11 19:51:10 apb Exp $ # from: @(#)Makefile 8.1 (Berkeley) 6/6/93 .include PROG= find SRCS= find.c function.c ls.c main.c misc.c operator.c option.c stat_flags.c +WARNS= 4 CPPFLAGS+= -I${NETBSDSRCDIR}/bin/ls .PATH: ${NETBSDSRCDIR}/bin/ls diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index 60e0064ae14e..9460e44ac9f4 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.25 2006/10/07 17:04:02 apb Exp $ */ +/* $NetBSD: extern.h,v 1.26 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -33,65 +33,65 @@ #include -void brace_subst __P((char *, char **, char *, int *)); -PLAN *find_create __P((char ***)); -int find_execute __P((PLAN *, char **)); -PLAN *find_formplan __P((char **)); -int find_traverse __P((PLAN *, int (*)(PLAN *, void *), void *)); -int f_expr __P((PLAN *, FTSENT *)); -PLAN *not_squish __P((PLAN *)); -PLAN *or_squish __P((PLAN *)); -PLAN *paren_squish __P((PLAN *)); +void brace_subst(char *, char **, char *, int *); +PLAN *find_create(char ***); +int find_execute(PLAN *, char **); +PLAN *find_formplan(char **); +int find_traverse(PLAN *, int (*)(PLAN *, void *), void *); +int f_expr(PLAN *, FTSENT *); +PLAN *not_squish(PLAN *); +PLAN *or_squish(PLAN *); +PLAN *paren_squish(PLAN *); int plan_cleanup(PLAN *, void *); -void printlong __P((char *, char *, struct stat *)); -int queryuser __P((char **)); -void show_path __P((int)); +void printlong(char *, char *, struct stat *); +int queryuser(char **); +void show_path(int); -PLAN *c_amin __P((char ***, int)); -PLAN *c_anewer __P((char ***, int)); -PLAN *c_atime __P((char ***, int)); -PLAN *c_cmin __P((char ***, int)); -PLAN *c_cnewer __P((char ***, int)); -PLAN *c_ctime __P((char ***, int)); -PLAN *c_depth __P((char ***, int)); -PLAN *c_empty __P((char ***, int)); -PLAN *c_exec __P((char ***, int)); -PLAN *c_execdir __P((char ***, int)); -PLAN *c_exit __P((char ***, int)); -PLAN *c_false __P((char ***, int)); -PLAN *c_flags __P((char ***, int)); -PLAN *c_follow __P((char ***, int)); -PLAN *c_fprint __P((char ***, int)); -PLAN *c_fstype __P((char ***, int)); -PLAN *c_group __P((char ***, int)); -PLAN *c_iname __P((char ***, int)); -PLAN *c_inum __P((char ***, int)); -PLAN *c_iregex __P((char ***, int)); -PLAN *c_links __P((char ***, int)); -PLAN *c_ls __P((char ***, int)); -PLAN *c_maxdepth __P((char ***, int)); -PLAN *c_mindepth __P((char ***, int)); -PLAN *c_mmin __P((char ***, int)); -PLAN *c_mtime __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_printx __P((char ***, int)); -PLAN *c_prune __P((char ***, int)); -PLAN *c_regex __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_not __P((char ***, int)); -PLAN *c_or __P((char ***, int)); -PLAN *c_null __P((char ***, int)); +PLAN *c_amin(char ***, int); +PLAN *c_anewer(char ***, int); +PLAN *c_atime(char ***, int); +PLAN *c_cmin(char ***, int); +PLAN *c_cnewer(char ***, int); +PLAN *c_ctime(char ***, int); +PLAN *c_depth(char ***, int); +PLAN *c_empty(char ***, int); +PLAN *c_exec(char ***, int); +PLAN *c_execdir(char ***, int); +PLAN *c_exit(char ***, int); +PLAN *c_false(char ***, int); +PLAN *c_flags(char ***, int); +PLAN *c_follow(char ***, int); +PLAN *c_fprint(char ***, int); +PLAN *c_fstype(char ***, int); +PLAN *c_group(char ***, int); +PLAN *c_iname(char ***, int); +PLAN *c_inum(char ***, int); +PLAN *c_iregex(char ***, int); +PLAN *c_links(char ***, int); +PLAN *c_ls(char ***, int); +PLAN *c_maxdepth(char ***, int); +PLAN *c_mindepth(char ***, int); +PLAN *c_mmin(char ***, int); +PLAN *c_mtime(char ***, int); +PLAN *c_name(char ***, int); +PLAN *c_newer(char ***, int); +PLAN *c_nogroup(char ***, int); +PLAN *c_nouser(char ***, int); +PLAN *c_path(char ***, int); +PLAN *c_perm(char ***, int); +PLAN *c_print(char ***, int); +PLAN *c_print0(char ***, int); +PLAN *c_printx(char ***, int); +PLAN *c_prune(char ***, int); +PLAN *c_regex(char ***, int); +PLAN *c_size(char ***, int); +PLAN *c_type(char ***, int); +PLAN *c_user(char ***, int); +PLAN *c_xdev(char ***, int); +PLAN *c_openparen(char ***, int); +PLAN *c_closeparen(char ***, int); +PLAN *c_not(char ***, int); +PLAN *c_or(char ***, int); +PLAN *c_null(char ***, int); extern int ftsoptions, isdeprecated, isdepth, isoutput, issort, isxargs; diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c index 8b2b42c08fef..68a9e36db8d0 100644 --- a/usr.bin/find/find.c +++ b/usr.bin/find/find.c @@ -1,4 +1,4 @@ -/* $NetBSD: find.c,v 1.22 2006/10/07 17:04:02 apb Exp $ */ +/* $NetBSD: find.c,v 1.23 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "from: @(#)find.c 8.5 (Berkeley) 8/5/94"; #else -__RCSID("$NetBSD: find.c,v 1.22 2006/10/07 17:04:02 apb Exp $"); +__RCSID("$NetBSD: find.c,v 1.23 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -54,10 +54,10 @@ __RCSID("$NetBSD: find.c,v 1.22 2006/10/07 17:04:02 apb Exp $"); #include "find.h" -static int ftscompare __P((const FTSENT **, const FTSENT **)); +static int ftscompare(const FTSENT **, const FTSENT **); -static void sig_lock __P((sigset_t *)); -static void sig_unlock __P((const sigset_t *)); +static void sig_lock(sigset_t *); +static void sig_unlock(const sigset_t *); /* * find_formplan -- @@ -65,8 +65,7 @@ static void sig_unlock __P((const sigset_t *)); * command arguments. */ PLAN * -find_formplan(argv) - char **argv; +find_formplan(char **argv) { PLAN *plan, *tail, *new; @@ -149,16 +148,14 @@ find_formplan(argv) } static int -ftscompare(e1, e2) - const FTSENT **e1, **e2; +ftscompare(const FTSENT **e1, const FTSENT **e2) { return (strcoll((*e1)->fts_name, (*e2)->fts_name)); } static void -sig_lock(s) - sigset_t *s; +sig_lock(sigset_t *s) { sigset_t new; @@ -168,8 +165,7 @@ sig_lock(s) } static void -sig_unlock(s) - const sigset_t *s; +sig_unlock(const sigset_t *s) { sigprocmask(SIG_SETMASK, s, NULL); @@ -184,9 +180,7 @@ FTSENT *g_entry; /* shared with SIGINFO handler */ * over all FTSENT's returned for the given search paths. */ int -find_execute(plan, paths) - PLAN *plan; /* search plan */ - char **paths; /* array of pathnames to traverse */ +find_execute(PLAN *plan, char **paths) { PLAN *p; int r, rval, cval; @@ -265,7 +259,7 @@ find_execute(plan, paths) int find_traverse(plan, func, arg) PLAN *plan; - int (*func) __P((PLAN *, void *)); + int (*func)(PLAN *, void *); void *arg; { PLAN *p; diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h index e53bef3f53db..e4afc0f1711d 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -1,4 +1,4 @@ -/* $NetBSD: find.h,v 1.22 2006/10/07 17:04:02 apb Exp $ */ +/* $NetBSD: find.h,v 1.23 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -51,8 +51,8 @@ enum ntype { /* node definition */ typedef struct _plandata { struct _plandata *next; /* next node */ - int (*eval) /* node evaluation function */ - __P((struct _plandata *, FTSENT *)); + int (*eval)(struct _plandata *, FTSENT *); + /* node evaluation function */ #define F_EQUAL 1 /* [acm]time inum links size */ #define F_LESSTHAN 2 #define F_GREATER 3 @@ -126,10 +126,9 @@ typedef struct _plandata { #define fprint_file p_un._fprint_file typedef struct _option { - char *name; /* option name */ + const char *name; /* option name */ enum ntype token; /* token type */ - PLAN *(*create) /* create function */ - __P((char ***, int)); + PLAN *(*create)(char ***, int); /* create function */ int arg; /* function needs arg */ } OPTION; diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 9f1c86ad2763..0b69f285f526 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $NetBSD: function.c,v 1.56 2006/10/07 17:04:02 apb Exp $ */ +/* $NetBSD: function.c,v 1.57 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: function.c,v 1.56 2006/10/07 17:04:02 apb Exp $"); +__RCSID("$NetBSD: function.c,v 1.57 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -78,49 +78,49 @@ __RCSID("$NetBSD: function.c,v 1.56 2006/10/07 17:04:02 apb Exp $"); } \ } -static int64_t find_parsenum __P((PLAN *, char *, char *, char *)); -static void run_f_exec __P((PLAN *)); - int f_always_true __P((PLAN *, FTSENT *)); - int f_amin __P((PLAN *, FTSENT *)); - int f_anewer __P((PLAN *, FTSENT *)); - int f_atime __P((PLAN *, FTSENT *)); - int f_cmin __P((PLAN *, FTSENT *)); - int f_cnewer __P((PLAN *, FTSENT *)); - int f_ctime __P((PLAN *, FTSENT *)); - int f_empty __P((PLAN *, FTSENT *)); - int f_exec __P((PLAN *, FTSENT *)); - int f_execdir __P((PLAN *, FTSENT *)); - int f_false __P((PLAN *, FTSENT *)); - int f_flags __P((PLAN *, FTSENT *)); - int f_fprint __P((PLAN *, FTSENT *)); - int f_fstype __P((PLAN *, FTSENT *)); - int f_group __P((PLAN *, FTSENT *)); - int f_iname __P((PLAN *, FTSENT *)); - int f_inum __P((PLAN *, FTSENT *)); - int f_links __P((PLAN *, FTSENT *)); - int f_ls __P((PLAN *, FTSENT *)); - int f_mindepth __P((PLAN *, FTSENT *)); - int f_maxdepth __P((PLAN *, FTSENT *)); - int f_mmin __P((PLAN *, FTSENT *)); - int f_mtime __P((PLAN *, FTSENT *)); - int f_name __P((PLAN *, FTSENT *)); - int f_newer __P((PLAN *, FTSENT *)); - int f_nogroup __P((PLAN *, FTSENT *)); - int f_nouser __P((PLAN *, FTSENT *)); - int f_path __P((PLAN *, FTSENT *)); - int f_perm __P((PLAN *, FTSENT *)); - int f_print __P((PLAN *, FTSENT *)); - int f_print0 __P((PLAN *, FTSENT *)); - int f_printx __P((PLAN *, FTSENT *)); - int f_prune __P((PLAN *, FTSENT *)); - int f_regex __P((PLAN *, FTSENT *)); - int f_size __P((PLAN *, FTSENT *)); - int f_type __P((PLAN *, FTSENT *)); - int f_user __P((PLAN *, FTSENT *)); - int f_not __P((PLAN *, FTSENT *)); - int f_or __P((PLAN *, FTSENT *)); -static PLAN *c_regex_common __P((char ***, int, enum ntype, int)); -static PLAN *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *)))); +static int64_t find_parsenum(PLAN *, const char *, const char *, char *); +static void run_f_exec(PLAN *); + int f_always_true(PLAN *, FTSENT *); + int f_amin(PLAN *, FTSENT *); + int f_anewer(PLAN *, FTSENT *); + int f_atime(PLAN *, FTSENT *); + int f_cmin(PLAN *, FTSENT *); + int f_cnewer(PLAN *, FTSENT *); + int f_ctime(PLAN *, FTSENT *); + int f_empty(PLAN *, FTSENT *); + int f_exec(PLAN *, FTSENT *); + int f_execdir(PLAN *, FTSENT *); + int f_false(PLAN *, FTSENT *); + int f_flags(PLAN *, FTSENT *); + int f_fprint(PLAN *, FTSENT *); + int f_fstype(PLAN *, FTSENT *); + int f_group(PLAN *, FTSENT *); + int f_iname(PLAN *, FTSENT *); + int f_inum(PLAN *, FTSENT *); + int f_links(PLAN *, FTSENT *); + int f_ls(PLAN *, FTSENT *); + int f_mindepth(PLAN *, FTSENT *); + int f_maxdepth(PLAN *, FTSENT *); + int f_mmin(PLAN *, FTSENT *); + int f_mtime(PLAN *, FTSENT *); + int f_name(PLAN *, FTSENT *); + int f_newer(PLAN *, FTSENT *); + int f_nogroup(PLAN *, FTSENT *); + int f_nouser(PLAN *, FTSENT *); + int f_path(PLAN *, FTSENT *); + int f_perm(PLAN *, FTSENT *); + int f_print(PLAN *, FTSENT *); + int f_print0(PLAN *, FTSENT *); + int f_printx(PLAN *, FTSENT *); + int f_prune(PLAN *, FTSENT *); + int f_regex(PLAN *, FTSENT *); + int f_size(PLAN *, FTSENT *); + int f_type(PLAN *, FTSENT *); + int f_user(PLAN *, FTSENT *); + int f_not(PLAN *, FTSENT *); + int f_or(PLAN *, FTSENT *); +static PLAN *c_regex_common(char ***, int, enum ntype, int); +static PLAN *palloc(enum ntype, int (*)(PLAN *, FTSENT *)); extern int dotfd; extern FTS *tree; @@ -131,13 +131,12 @@ extern time_t now; * Parse a string of the form [+-]# and return the value. */ static int64_t -find_parsenum(plan, option, vp, endch) - PLAN *plan; - char *option, *vp, *endch; +find_parsenum(PLAN *plan, const char *option, const char *vp, char *endch) { int64_t value; - char *endchar, *str; /* Pointer to character ending conversion. */ - + const char *str; + char *endchar; /* Pointer to character ending conversion. */ + /* Determine comparison from leading + or -. */ str = vp; switch (*str) { @@ -153,7 +152,7 @@ find_parsenum(plan, option, vp, endch) plan->flags = F_EQUAL; break; } - + /* * Convert the string with strtol(). Note, if strtol() returns zero * and endchar points to the beginning of the string we know we have @@ -186,18 +185,14 @@ find_parsenum(plan, option, vp, endch) * current time is n 1 minute periods. */ int -f_amin(plan, entry) - PLAN *plan; - FTSENT *entry; +f_amin(PLAN *plan, FTSENT *entry) { COMPARE((now - entry->fts_statp->st_atime + SECSPERMIN - 1) / SECSPERMIN, plan->t_data); } - + PLAN * -c_amin(argvp, isok) - char ***argvp; - int isok; +c_amin(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -226,16 +221,14 @@ f_anewer(plan, entry) return (entry->fts_statp->st_atime > plan->t_data); } - + PLAN * -c_anewer(argvp, isok) - char ***argvp; - int isok; +c_anewer(char ***argvp, int isok) { char *filename = **argvp; PLAN *new; struct stat sb; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -245,7 +238,7 @@ c_anewer(argvp, isok) new->t_data = sb.st_atime; return (new); } - + /* * -atime n functions -- * @@ -253,18 +246,14 @@ c_anewer(argvp, isok) * current time is n 24 hour periods. */ int -f_atime(plan, entry) - PLAN *plan; - FTSENT *entry; +f_atime(PLAN *plan, FTSENT *entry) { COMPARE((now - entry->fts_statp->st_atime + SECSPERDAY - 1) / SECSPERDAY, plan->t_data); } - + PLAN * -c_atime(argvp, isok) - char ***argvp; - int isok; +c_atime(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -284,18 +273,14 @@ c_atime(argvp, isok) * status information and the current time is n 24 hour periods. */ int -f_cmin(plan, entry) - PLAN *plan; - FTSENT *entry; +f_cmin(PLAN *plan, FTSENT *entry) { COMPARE((now - entry->fts_statp->st_ctime + SECSPERMIN - 1) / SECSPERMIN, plan->t_data); } - + PLAN * -c_cmin(argvp, isok) - char ***argvp; - int isok; +c_cmin(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -317,23 +302,19 @@ c_cmin(argvp, isok) * file. */ int -f_cnewer(plan, entry) - PLAN *plan; - FTSENT *entry; +f_cnewer(PLAN *plan, FTSENT *entry) { return (entry->fts_statp->st_ctime > plan->t_data); } - + PLAN * -c_cnewer(argvp, isok) - char ***argvp; - int isok; +c_cnewer(char ***argvp, int isok) { char *filename = **argvp; PLAN *new; struct stat sb; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -343,7 +324,7 @@ c_cnewer(argvp, isok) new->t_data = sb.st_ctime; return (new); } - + /* * -ctime n functions -- * @@ -351,18 +332,14 @@ c_cnewer(argvp, isok) * status information and the current time is n 24 hour periods. */ int -f_ctime(plan, entry) - PLAN *plan; - FTSENT *entry; +f_ctime(PLAN *plan, FTSENT *entry) { COMPARE((now - entry->fts_statp->st_ctime + SECSPERDAY - 1) / SECSPERDAY, plan->t_data); } - + PLAN * -c_ctime(argvp, isok) - char ***argvp; - int isok; +c_ctime(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -384,33 +361,27 @@ c_ctime(argvp, isok) * itself. */ int -f_always_true(plan, entry) - PLAN *plan; - FTSENT *entry; +f_always_true(PLAN *plan, FTSENT *entry) { return (1); } - + PLAN * -c_depth(argvp, isok) - char ***argvp; - int isok; +c_depth(char ***argvp, int isok) { isdepth = 1; return (palloc(N_DEPTH, f_always_true)); } - + /* * -empty functions -- * * True if the file or directory is empty */ int -f_empty(plan, entry) - PLAN *plan; - FTSENT *entry; +f_empty(PLAN *plan, FTSENT *entry) { if (S_ISREG(entry->fts_statp->st_mode) && entry->fts_statp->st_size == 0) @@ -438,9 +409,7 @@ f_empty(plan, entry) } PLAN * -c_empty(argvp, isok) - char ***argvp; - int isok; +c_empty(char ***argvp, int isok) { ftsoptions &= ~FTS_NOSTAT; @@ -469,9 +438,7 @@ c_empty(argvp, isok) * of the user before executing the utility. */ int -f_exec(plan, entry) - PLAN *plan; - FTSENT *entry; +f_exec(PLAN *plan, FTSENT *entry) { int cnt, l; pid_t pid; @@ -539,8 +506,7 @@ f_exec(plan, entry) } static void -run_f_exec(plan) - PLAN *plan; +run_f_exec(PLAN *plan) { pid_t pid; int rval, status; @@ -599,16 +565,14 @@ run_f_exec(plan) * discussion), and then allocate ARG_MAX - 4K of space for args. */ PLAN * -c_exec(argvp, isok) - char ***argvp; - int isok; +c_exec(char ***argvp, int isok) { PLAN *new; /* node returned */ int cnt, brace, lastbrace; char **argv, **ap, *p; isoutput = 1; - + new = palloc(N_EXEC, f_exec); if (isok) new->flags |= F_NEEDOK; @@ -710,9 +674,7 @@ c_exec(argvp, isok) * the directory where the file lives. */ int -f_execdir(plan, entry) - PLAN *plan; - FTSENT *entry; +f_execdir(PLAN *plan, FTSENT *entry) { int cnt; pid_t pid; @@ -746,7 +708,7 @@ f_execdir(plan, entry) pid = waitpid(pid, &status, 0); return (pid != -1 && WIFEXITED(status) && !WEXITSTATUS(status)); } - + /* * c_execdir -- * build three parallel arrays, one with pointers to the strings passed @@ -755,9 +717,7 @@ f_execdir(plan, entry) * strings, but also flags meaning that the string has to be massaged. */ PLAN * -c_execdir(argvp, isok) - char ***argvp; - int isok; +c_execdir(char ***argvp, int isok) { PLAN *new; /* node returned */ int cnt; @@ -765,7 +725,7 @@ c_execdir(argvp, isok) ftsoptions &= ~FTS_NOSTAT; isoutput = 1; - + new = palloc(N_EXECDIR, f_execdir); for (ap = argv = *argvp;; ++ap) { @@ -801,9 +761,7 @@ c_execdir(argvp, isok) } PLAN * -c_exit(argvp, isok) - char ***argvp; - int isok; +c_exit(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -827,30 +785,24 @@ c_exit(argvp, isok) * -false function */ int -f_false(plan, entry) - PLAN *plan; - FTSENT *entry; +f_false(PLAN *plan, FTSENT *entry) { return (0); } - + PLAN * -c_false(argvp, isok) - char ***argvp; - int isok; +c_false(char ***argvp, int isok) { return (palloc(N_FALSE, f_false)); } - + /* * -flags [-]flags functions -- */ int -f_flags(plan, entry) - PLAN *plan; - FTSENT *entry; +f_flags(PLAN *plan, FTSENT *entry) { u_int32_t flags; @@ -861,11 +813,9 @@ f_flags(plan, entry) return (flags == plan->f_data); /* NOTREACHED */ } - + PLAN * -c_flags(argvp, isok) - char ***argvp; - int isok; +c_flags(char ***argvp, int isok) { char *flags = **argvp; PLAN *new; @@ -888,7 +838,7 @@ c_flags(argvp, isok) new->f_data = flagset; return (new); } - + /* * -follow functions -- * @@ -896,24 +846,20 @@ c_flags(argvp, isok) * basis. */ PLAN * -c_follow(argvp, isok) - char ***argvp; - int isok; +c_follow(char ***argvp, int isok) { ftsoptions &= ~FTS_PHYSICAL; ftsoptions |= FTS_LOGICAL; return (palloc(N_FOLLOW, f_always_true)); } - + /* -fprint functions -- * * Causes the current pathame to be written to the defined output file. */ int -f_fprint(plan, entry) - PLAN *plan; - FTSENT *entry; +f_fprint(PLAN *plan, FTSENT *entry) { if (-1 == fprintf(plan->fprint_file, "%s\n", entry->fts_path)) @@ -924,11 +870,9 @@ f_fprint(plan, entry) /* no descriptors are closed; they will be closed by operating system when this find command exits. */ } - + PLAN * -c_fprint(argvp, isok) - char ***argvp; - int isok; +c_fprint(char ***argvp, int isok) { PLAN *new; @@ -949,9 +893,7 @@ c_fprint(argvp, isok) * True if the file is of a certain type. */ int -f_fstype(plan, entry) - PLAN *plan; - FTSENT *entry; +f_fstype(PLAN *plan, FTSENT *entry) { static dev_t curdev; /* need a guaranteed illegal dev value */ static int first = 1; @@ -980,8 +922,8 @@ f_fstype(plan, entry) p[0] = '.'; save[1] = p[1]; p[1] = '\0'; - - } else + + } else p = NULL; if (statvfs(entry->fts_accpath, &sb)) @@ -1003,25 +945,23 @@ f_fstype(plan, entry) } switch (plan->flags) { case F_MTFLAG: - return (val & plan->mt_data); + return (val & plan->mt_data); case F_MTTYPE: return (strncmp(fstype, plan->c_data, MFSNAMELEN) == 0); default: abort(); } } - + PLAN * -c_fstype(argvp, isok) - char ***argvp; - int isok; +c_fstype(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_FSTYPE, f_fstype); switch (*arg) { @@ -1045,7 +985,7 @@ c_fstype(argvp, isok) new->c_data = arg; return (new); } - + /* * -group gname functions -- * @@ -1054,24 +994,20 @@ c_fstype(argvp, isok) * name, gname is taken as a group ID. */ int -f_group(plan, entry) - PLAN *plan; - FTSENT *entry; +f_group(PLAN *plan, FTSENT *entry) { return (entry->fts_statp->st_gid == plan->g_data); } - + PLAN * -c_group(argvp, isok) - char ***argvp; - int isok; +c_group(char ***argvp, int isok) { char *gname = **argvp; PLAN *new; struct group *g; gid_t gid; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -1082,7 +1018,7 @@ c_group(argvp, isok) errx(1, "-group: %s: no such group", gname); } else gid = g->gr_gid; - + new = palloc(N_GROUP, f_group); new->g_data = gid; return (new); @@ -1094,84 +1030,72 @@ c_group(argvp, isok) * True if the file has inode # n. */ int -f_inum(plan, entry) - PLAN *plan; - FTSENT *entry; +f_inum(PLAN *plan, FTSENT *entry) { COMPARE(entry->fts_statp->st_ino, plan->i_data); } - + PLAN * -c_inum(argvp, isok) - char ***argvp; - int isok; +c_inum(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_INUM, f_inum); new->i_data = find_parsenum(new, "-inum", arg, NULL); return (new); } - + /* * -links n functions -- * * True if the file has n links. */ int -f_links(plan, entry) - PLAN *plan; - FTSENT *entry; +f_links(PLAN *plan, FTSENT *entry) { COMPARE(entry->fts_statp->st_nlink, plan->l_data); } - + PLAN * -c_links(argvp, isok) - char ***argvp; - int isok; +c_links(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; - + new = palloc(N_LINKS, f_links); new->l_data = (nlink_t)find_parsenum(new, "-links", arg, NULL); return (new); } - + /* * -ls functions -- * * Always true - prints the current entry to stdout in "ls" format. */ int -f_ls(plan, entry) - PLAN *plan; - FTSENT *entry; +f_ls(PLAN *plan, FTSENT *entry) { printlong(entry->fts_path, entry->fts_accpath, entry->fts_statp); return (1); } - + PLAN * -c_ls(argvp, isok) - char ***argvp; - int isok; +c_ls(char ***argvp, int isok) { ftsoptions &= ~FTS_NOSTAT; isoutput = 1; - + return (palloc(N_LS, f_ls)); } @@ -1182,9 +1106,7 @@ c_ls(argvp, isok) * maximum depth specified */ int -f_maxdepth(plan, entry) - PLAN *plan; - FTSENT *entry; +f_maxdepth(PLAN *plan, FTSENT *entry) { extern FTS *tree; @@ -1194,9 +1116,7 @@ f_maxdepth(plan, entry) } PLAN * -c_maxdepth(argvp, isok) - char ***argvp; - int isok; +c_maxdepth(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -1214,17 +1134,13 @@ c_maxdepth(argvp, isok) * minimum depth specified */ int -f_mindepth(plan, entry) - PLAN *plan; - FTSENT *entry; +f_mindepth(PLAN *plan, FTSENT *entry) { return (entry->fts_level >= plan->min_data); } PLAN * -c_mindepth(argvp, isok) - char ***argvp; - int isok; +c_mindepth(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -1241,18 +1157,14 @@ c_mindepth(argvp, isok) * current time is n 24 hour periods. */ int -f_mmin(plan, entry) - PLAN *plan; - FTSENT *entry; +f_mmin(PLAN *plan, FTSENT *entry) { COMPARE((now - entry->fts_statp->st_mtime + SECSPERMIN - 1) / SECSPERMIN, plan->t_data); } - + PLAN * -c_mmin(argvp, isok) - char ***argvp; - int isok; +c_mmin(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -1272,18 +1184,14 @@ c_mmin(argvp, isok) * current time is n 24 hour periods. */ int -f_mtime(plan, entry) - PLAN *plan; - FTSENT *entry; +f_mtime(PLAN *plan, FTSENT *entry) { COMPARE((now - entry->fts_statp->st_mtime + SECSPERDAY - 1) / SECSPERDAY, plan->t_data); } - + PLAN * -c_mtime(argvp, isok) - char ***argvp; - int isok; +c_mtime(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; @@ -1304,18 +1212,14 @@ c_mtime(argvp, isok) * matches pattern using Pattern Matching Notation S3.14 */ int -f_name(plan, entry) - PLAN *plan; - FTSENT *entry; +f_name(PLAN *plan, FTSENT *entry) { return (!fnmatch(plan->c_data, entry->fts_name, 0)); } - + PLAN * -c_name(argvp, isok) - char ***argvp; - int isok; +c_name(char ***argvp, int isok) { char *pattern = **argvp; PLAN *new; @@ -1325,25 +1229,21 @@ c_name(argvp, isok) new->c_data = pattern; return (new); } - + /* * -iname functions -- * * Similar to -name, but does case insensitive matching - * + * */ int -f_iname(plan, entry) - PLAN *plan; - FTSENT *entry; +f_iname(PLAN *plan, FTSENT *entry) { return (!fnmatch(plan->c_data, entry->fts_name, FNM_CASEFOLD)); } - + PLAN * -c_iname(argvp, isok) - char ***argvp; - int isok; +c_iname(char ***argvp, int isok) { char *pattern = **argvp; PLAN *new; @@ -1353,7 +1253,7 @@ c_iname(argvp, isok) new->c_data = pattern; return (new); } - + /* * -newer file functions -- * @@ -1362,23 +1262,19 @@ c_iname(argvp, isok) * file. */ int -f_newer(plan, entry) - PLAN *plan; - FTSENT *entry; +f_newer(PLAN *plan, FTSENT *entry) { return (entry->fts_statp->st_mtime > plan->t_data); } - + PLAN * -c_newer(argvp, isok) - char ***argvp; - int isok; +c_newer(char ***argvp, int isok) { char *filename = **argvp; PLAN *new; struct stat sb; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -1388,7 +1284,7 @@ c_newer(argvp, isok) new->t_data = sb.st_mtime; return (new); } - + /* * -nogroup functions -- * @@ -1396,24 +1292,20 @@ c_newer(argvp, isok) * of the getgrnam() 9.2.1 [POSIX.1] function returns NULL. */ int -f_nogroup(plan, entry) - PLAN *plan; - FTSENT *entry; +f_nogroup(PLAN *plan, FTSENT *entry) { return (group_from_gid(entry->fts_statp->st_gid, 1) ? 0 : 1); } - + PLAN * -c_nogroup(argvp, isok) - char ***argvp; - int isok; +c_nogroup(char ***argvp, int isok) { ftsoptions &= ~FTS_NOSTAT; return (palloc(N_NOGROUP, f_nogroup)); } - + /* * -nouser functions -- * @@ -1421,24 +1313,20 @@ c_nogroup(argvp, isok) * of the getpwuid() 9.2.2 [POSIX.1] function returns NULL. */ int -f_nouser(plan, entry) - PLAN *plan; - FTSENT *entry; +f_nouser(PLAN *plan, FTSENT *entry) { return (user_from_uid(entry->fts_statp->st_uid, 1) ? 0 : 1); } - + PLAN * -c_nouser(argvp, isok) - char ***argvp; - int isok; +c_nouser(char ***argvp, int isok) { ftsoptions &= ~FTS_NOSTAT; return (palloc(N_NOUSER, f_nouser)); } - + /* * -path functions -- * @@ -1446,18 +1334,14 @@ c_nouser(argvp, isok) * matches pattern using Pattern Matching Notation S3.14 */ int -f_path(plan, entry) - PLAN *plan; - FTSENT *entry; +f_path(PLAN *plan, FTSENT *entry) { return (!fnmatch(plan->c_data, entry->fts_path, 0)); } - + PLAN * -c_path(argvp, isok) - char ***argvp; - int isok; +c_path(char ***argvp, int isok) { char *pattern = **argvp; PLAN *new; @@ -1467,7 +1351,7 @@ c_path(argvp, isok) new->c_data = pattern; return (new); } - + /* * -perm functions -- * @@ -1476,9 +1360,7 @@ c_path(argvp, isok) * symbolic mode. */ int -f_perm(plan, entry) - PLAN *plan; - FTSENT *entry; +f_perm(PLAN *plan, FTSENT *entry) { mode_t mode; @@ -1490,11 +1372,9 @@ f_perm(plan, entry) return (mode == plan->m_data); /* NOTREACHED */ } - + PLAN * -c_perm(argvp, isok) - char ***argvp; - int isok; +c_perm(char ***argvp, int isok) { char *perm = **argvp; PLAN *new; @@ -1517,7 +1397,7 @@ c_perm(argvp, isok) free(set); return (new); } - + /* * -print functions -- * @@ -1525,9 +1405,7 @@ c_perm(argvp, isok) * standard output. */ int -f_print(plan, entry) - PLAN *plan; - FTSENT *entry; +f_print(PLAN *plan, FTSENT *entry) { (void)printf("%s\n", entry->fts_path); @@ -1535,9 +1413,7 @@ f_print(plan, entry) } int -f_print0(plan, entry) - PLAN *plan; - FTSENT *entry; +f_print0(PLAN *plan, FTSENT *entry) { (void)fputs(entry->fts_path, stdout); @@ -1546,9 +1422,7 @@ f_print0(plan, entry) } int -f_printx(plan, entry) - PLAN *plan; - FTSENT *entry; +f_printx(PLAN *plan, FTSENT *entry) { char *cp; @@ -1564,11 +1438,9 @@ f_printx(plan, entry) fputc('\n', stdout); return (1); } - + PLAN * -c_print(argvp, isok) - char ***argvp; - int isok; +c_print(char ***argvp, int isok) { isoutput = 1; @@ -1577,9 +1449,7 @@ c_print(argvp, isok) } PLAN * -c_print0(argvp, isok) - char ***argvp; - int isok; +c_print0(char ***argvp, int isok) { isoutput = 1; @@ -1588,35 +1458,29 @@ c_print0(argvp, isok) } PLAN * -c_printx(argvp, isok) - char ***argvp; - int isok; +c_printx(char ***argvp, int isok) { isoutput = 1; return (palloc(N_PRINTX, f_printx)); } - + /* * -prune functions -- * * Prune a portion of the hierarchy. */ int -f_prune(plan, entry) - PLAN *plan; - FTSENT *entry; +f_prune(PLAN *plan, FTSENT *entry) { if (fts_set(tree, entry, FTS_SKIP)) err(1, "%s", entry->fts_path); return (1); } - + PLAN * -c_prune(argvp, isok) - char ***argvp; - int isok; +c_prune(char ***argvp, int isok) { return (palloc(N_PRUNE, f_prune)); @@ -1630,19 +1494,14 @@ c_prune(argvp, isok) * For -iregex, regexp is a case-insensitive (basic) regular expression. */ int -f_regex(plan, entry) - PLAN *plan; - FTSENT *entry; +f_regex(PLAN *plan, FTSENT *entry) { return (regexec(&plan->regexp_data, entry->fts_path, 0, NULL, 0) == 0); } - + static PLAN * -c_regex_common(argvp, isok, type, regcomp_flags) - char ***argvp; - int isok, regcomp_flags; - enum ntype type; +c_regex_common(char ***argvp, int isok, enum ntype type, int regcomp_flags) { char errbuf[LINE_MAX]; regex_t reg; @@ -1662,25 +1521,21 @@ c_regex_common(argvp, isok, type, regcomp_flags) regerror(rv, ®, errbuf, sizeof errbuf); errx(1, "regexp %s: %s", regexp, errbuf); } - + new = palloc(type, f_regex); new->regexp_data = reg; return (new); } PLAN * -c_regex(argvp, isok) - char ***argvp; - int isok; +c_regex(char ***argvp, int isok) { return (c_regex_common(argvp, isok, N_REGEX, REG_BASIC)); } PLAN * -c_iregex(argvp, isok) - char ***argvp; - int isok; +c_iregex(char ***argvp, int isok) { return (c_regex_common(argvp, isok, N_IREGEX, REG_BASIC|REG_ICASE)); @@ -1697,9 +1552,7 @@ c_iregex(argvp, isok) static int divsize = 1; int -f_size(plan, entry) - PLAN *plan; - FTSENT *entry; +f_size(PLAN *plan, FTSENT *entry) { off_t size; @@ -1707,16 +1560,14 @@ f_size(plan, entry) FIND_SIZE : entry->fts_statp->st_size; COMPARE(size, plan->o_data); } - + PLAN * -c_size(argvp, isok) - char ***argvp; - int isok; +c_size(char ***argvp, int isok) { char *arg = **argvp; PLAN *new; char endch; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -1727,7 +1578,7 @@ c_size(argvp, isok) divsize = 0; return (new); } - + /* * -type c functions -- * @@ -1736,23 +1587,19 @@ c_size(argvp, isok) * regular file or whiteout respectively. */ int -f_type(plan, entry) - PLAN *plan; - FTSENT *entry; +f_type(PLAN *plan, FTSENT *entry) { return ((entry->fts_statp->st_mode & S_IFMT) == plan->m_data); } - + PLAN * -c_type(argvp, isok) - char ***argvp; - int isok; +c_type(char ***argvp, int isok) { char *typestring = **argvp; PLAN *new; mode_t mask = (mode_t)0; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -1790,12 +1637,12 @@ c_type(argvp, isok) default: errx(1, "-type: %s: unknown type", typestring); } - + new = palloc(N_TYPE, f_type); new->m_data = mask; return (new); } - + /* * -user uname functions -- * @@ -1804,24 +1651,20 @@ c_type(argvp, isok) * return a valid user name, uname is taken as a user ID. */ int -f_user(plan, entry) - PLAN *plan; - FTSENT *entry; +f_user(PLAN *plan, FTSENT *entry) { COMPARE(entry->fts_statp->st_uid, plan->u_data); } - + PLAN * -c_user(argvp, isok) - char ***argvp; - int isok; +c_user(char ***argvp, int isok) { char *username = **argvp; PLAN *new; struct passwd *p; uid_t uid; - + (*argvp)++; ftsoptions &= ~FTS_NOSTAT; @@ -1841,7 +1684,7 @@ c_user(argvp, isok) new->u_data = uid; return (new); } - + /* * -xdev functions -- * @@ -1849,9 +1692,7 @@ c_user(argvp, isok) * different device ID (st_dev, see stat() S5.6.2 [POSIX.1]) */ PLAN * -c_xdev(argvp, isok) - char ***argvp; - int isok; +c_xdev(char ***argvp, int isok) { ftsoptions |= FTS_XDEV; @@ -1864,9 +1705,7 @@ c_xdev(argvp, isok) * True if expression is true. */ int -f_expr(plan, entry) - PLAN *plan; - FTSENT *entry; +f_expr(PLAN *plan, FTSENT *entry) { PLAN *p; int state; @@ -1876,39 +1715,33 @@ f_expr(plan, entry) p && (state = (p->eval)(p, entry)); p = p->next); return (state); } - + /* * N_OPENPAREN and N_CLOSEPAREN nodes are temporary place markers. They are * eliminated during phase 2 of find_formplan() --- the '(' node is converted * to a N_EXPR node containing the expression and the ')' node is discarded. */ PLAN * -c_openparen(argvp, isok) - char ***argvp; - int isok; +c_openparen(char ***argvp, int isok) { - return (palloc(N_OPENPAREN, (int (*) __P((PLAN *, FTSENT *)))-1)); + return (palloc(N_OPENPAREN, (int (*)(PLAN *, FTSENT *))-1)); } - + PLAN * -c_closeparen(argvp, isok) - char ***argvp; - int isok; +c_closeparen(char ***argvp, int isok) { - return (palloc(N_CLOSEPAREN, (int (*) __P((PLAN *, FTSENT *)))-1)); + return (palloc(N_CLOSEPAREN, (int (*)(PLAN *, FTSENT *))-1)); } - + /* * ! expression functions -- * * Negation of a primary; the unary NOT operator. */ int -f_not(plan, entry) - PLAN *plan; - FTSENT *entry; +f_not(PLAN *plan, FTSENT *entry) { PLAN *p; int state; @@ -1918,16 +1751,14 @@ f_not(plan, entry) p && (state = (p->eval)(p, entry)); p = p->next); return (!state); } - + PLAN * -c_not(argvp, isok) - char ***argvp; - int isok; +c_not(char ***argvp, int isok) { return (palloc(N_NOT, f_not)); } - + /* * expression -o expression functions -- * @@ -1935,9 +1766,7 @@ c_not(argvp, isok) * not evaluated if the first expression is true. */ int -f_or(plan, entry) - PLAN *plan; - FTSENT *entry; +f_or(PLAN *plan, FTSENT *entry) { PLAN *p; int state; @@ -1955,18 +1784,14 @@ f_or(plan, entry) } PLAN * -c_or(argvp, isok) - char ***argvp; - int isok; +c_or(char ***argvp, int isok) { return (palloc(N_OR, f_or)); } PLAN * -c_null(argvp, isok) - char ***argvp; - int isok; +c_null(char ***argvp, int isok) { return (NULL); @@ -1984,9 +1809,7 @@ c_null(argvp, isok) */ /* ARGSUSED1 */ int -plan_cleanup(plan, arg) - PLAN *plan; - void *arg; +plan_cleanup(PLAN *plan, void *arg) { if (plan->type==N_EXEC && plan->ep_narg) run_f_exec(plan); @@ -1995,9 +1818,7 @@ plan_cleanup(plan, arg) } static PLAN * -palloc(t, f) - enum ntype t; - int (*f) __P((PLAN *, FTSENT *)); +palloc(enum ntype t, int (*f)(PLAN *, FTSENT *)) { PLAN *new; diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c index bf8462451876..71fe959410ec 100644 --- a/usr.bin/find/ls.c +++ b/usr.bin/find/ls.c @@ -1,4 +1,4 @@ -/* $NetBSD: ls.c,v 1.18 2003/08/07 11:13:42 agc Exp $ */ +/* $NetBSD: ls.c,v 1.19 2006/10/11 19:51:10 apb Exp $ */ /* * Copyright (c) 1989, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)ls.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: ls.c,v 1.18 2003/08/07 11:13:42 agc Exp $"); +__RCSID("$NetBSD: ls.c,v 1.19 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -57,14 +57,13 @@ __RCSID("$NetBSD: ls.c,v 1.18 2003/08/07 11:13:42 agc Exp $"); /* Derived from the print routines in the ls(1) source code. */ -static void printlink __P((char *)); -static void printtime __P((time_t)); +static void printlink(char *); +static void printtime(time_t); void -printlong(name, accpath, sb) - char *name; /* filename to print */ - char *accpath; /* current valid path to filename */ - struct stat *sb; /* stat buffer */ +printlong(char *name, /* filename to print */ + char *accpath, /* current valid path to filename */ + struct stat *sb) /* stat buffer */ { char modep[15]; @@ -88,8 +87,7 @@ printlong(name, accpath, sb) } static void -printtime(ftime) - time_t ftime; +printtime(time_t ftime) { int i; char *longstring; @@ -111,8 +109,7 @@ printtime(ftime) } static void -printlink(name) - char *name; +printlink(char *name) { int lnklen; char path[MAXPATHLEN + 1]; diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index f4971e652dc4..f1caade85143 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.24 2005/10/19 12:25:51 elad Exp $ */ +/* $NetBSD: main.c,v 1.25 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95"; #else __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\n\ The Regents of the University of California. All rights reserved.\n"); -__RCSID("$NetBSD: main.c,v 1.24 2005/10/19 12:25:51 elad Exp $"); +__RCSID("$NetBSD: main.c,v 1.25 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -69,13 +69,11 @@ int isoutput; /* user specified output operator */ int issort; /* sort directory entries */ int isxargs; /* don't permit xargs delimiting chars */ -int main __P((int, char **)); -static void usage __P((void)); +int main(int, char **); +static void usage(void); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { struct sigaction sa; char **p, **start; @@ -160,7 +158,7 @@ main(argc, argv) } static void -usage() +usage(void) { (void)fprintf(stderr, diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index 7504da29d3c6..8ba84c0a2d8c 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.13 2006/08/26 18:17:42 christos Exp $ */ +/* $NetBSD: misc.c,v 1.14 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "from: @(#)misc.c 8.2 (Berkeley) 4/1/94"; #else -__RCSID("$NetBSD: misc.c,v 1.13 2006/08/26 18:17:42 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.14 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -53,16 +53,14 @@ __RCSID("$NetBSD: misc.c,v 1.13 2006/08/26 18:17:42 christos Exp $"); #include #include "find.h" - + /* * brace_subst -- * Replace occurrences of {} in orig with path, and place it in a malloced * area of memory set in store. */ void -brace_subst(orig, store, path, len) - char *orig, **store, *path; - int *len; +brace_subst(char *orig, char **store, char *path, int *len) { int nlen, plen, rest; char ch, *p, *ostore; @@ -98,8 +96,7 @@ brace_subst(orig, store, path, len) * input. If the input is 'y' then 1 is returned. */ int -queryuser(argv) - char **argv; +queryuser(char **argv) { int ch, first, nl; @@ -126,15 +123,14 @@ queryuser(argv) } return (first == 'y'); } - + /* * show_path -- * called on SIGINFO */ /* ARGSUSED */ void -show_path(sig) - int sig; +show_path(int sig) { extern FTSENT *g_entry; int errno_bak; diff --git a/usr.bin/find/operator.c b/usr.bin/find/operator.c index 71463d955d51..19e8cb97e925 100644 --- a/usr.bin/find/operator.c +++ b/usr.bin/find/operator.c @@ -1,4 +1,4 @@ -/* $NetBSD: operator.c,v 1.8 2003/08/07 11:13:43 agc Exp $ */ +/* $NetBSD: operator.c,v 1.9 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "from: @(#)operator.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: operator.c,v 1.8 2003/08/07 11:13:43 agc Exp $"); +__RCSID("$NetBSD: operator.c,v 1.9 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -48,27 +48,26 @@ __RCSID("$NetBSD: operator.c,v 1.8 2003/08/07 11:13:43 agc Exp $"); #include #include "find.h" - -static PLAN *yanknode __P((PLAN **)); -static PLAN *yankexpr __P((PLAN **)); + +static PLAN *yanknode(PLAN **); +static PLAN *yankexpr(PLAN **); /* * yanknode -- * destructively removes the top from the plan */ static PLAN * -yanknode(planp) - PLAN **planp; /* pointer to top of plan (modified) */ +yanknode(PLAN **planp) /* pointer to top of plan (modified) */ { PLAN *node; /* top node removed from the plan */ - + if ((node = (*planp)) == NULL) return (NULL); (*planp) = (*planp)->next; node->next = NULL; return (node); } - + /* * yankexpr -- * Removes one expression from the plan. This is used mainly by @@ -76,18 +75,17 @@ yanknode(planp) * simple node or a N_EXPR node containing a list of simple nodes. */ static PLAN * -yankexpr(planp) - PLAN **planp; /* pointer to top of plan (modified) */ +yankexpr(PLAN **planp) /* pointer to top of plan (modified) */ { PLAN *next; /* temp node holding subexpression results */ PLAN *node; /* pointer to returned node or expression */ PLAN *tail; /* pointer to tail of subplan */ PLAN *subplan; /* pointer to head of ( ) expression */ - + /* first pull the top node from the plan */ if ((node = yanknode(planp)) == NULL) return (NULL); - + /* * If the node is an '(' then we recursively slurp up expressions * until we find its associated ')'. If it's a closing paren we @@ -124,19 +122,18 @@ yankexpr(planp) } return (node); } - + /* * paren_squish -- * replaces "parentheisized" plans in our search plan with "expr" nodes. */ PLAN * -paren_squish(plan) - PLAN *plan; /* plan with ( ) nodes */ +paren_squish(PLAN *plan) /* plan with ( ) nodes */ { PLAN *expr; /* pointer to next expression */ PLAN *tail; /* pointer to tail of result plan */ PLAN *result; /* pointer to head of result plan */ - + result = tail = NULL; /* @@ -162,22 +159,21 @@ paren_squish(plan) } return (result); } - + /* * not_squish -- * compresses "!" expressions in our search plan. */ PLAN * -not_squish(plan) - PLAN *plan; /* plan to process */ +not_squish(PLAN *plan) /* plan to process */ { PLAN *next; /* next node being processed */ PLAN *node; /* temporary node used in N_NOT processing */ PLAN *tail; /* pointer to tail of result plan */ PLAN *result; /* pointer to head of result plan */ - + tail = result = next = NULL; - + while ((next = yanknode(&plan)) != NULL) { /* * if we encounter a ( expression ) then look for nots in @@ -222,21 +218,20 @@ not_squish(plan) } return (result); } - + /* * or_squish -- * compresses -o expressions in our search plan. */ PLAN * -or_squish(plan) - PLAN *plan; /* plan with ors to be squished */ +or_squish(PLAN *plan) /* plan with ors to be squished */ { PLAN *next; /* next node being processed */ PLAN *tail; /* pointer to tail of result plan */ PLAN *result; /* pointer to head of result plan */ - + tail = result = next = NULL; - + while ((next = yanknode(&plan)) != NULL) { /* * if we encounter a ( expression ) then look for or's in diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c index 925fdc0137ad..f4b786ce9cc4 100644 --- a/usr.bin/find/option.c +++ b/usr.bin/find/option.c @@ -1,4 +1,4 @@ -/* $NetBSD: option.c,v 1.23 2006/02/20 16:31:03 jschauma Exp $ */ +/* $NetBSD: option.c,v 1.24 2006/10/11 19:51:10 apb Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "from: @(#)option.c 8.2 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: option.c,v 1.23 2006/02/20 16:31:03 jschauma Exp $"); +__RCSID("$NetBSD: option.c,v 1.24 2006/10/11 19:51:10 apb Exp $"); #endif #endif /* not lint */ @@ -52,8 +52,8 @@ __RCSID("$NetBSD: option.c,v 1.23 2006/02/20 16:31:03 jschauma Exp $"); #include "find.h" -int typecompare __P((const void *, const void *)); -static OPTION *option __P((char *)); +int typecompare(const void *, const void *); +static OPTION *option(char *); /* NB: the following table must be sorted lexically. */ static OPTION const options[] = { @@ -117,8 +117,7 @@ static OPTION const options[] = { * this switch stuff. */ PLAN * -find_create(argvp) - char ***argvp; +find_create(char ***argvp) { OPTION *p; PLAN *new; @@ -139,8 +138,7 @@ find_create(argvp) } static OPTION * -option(name) - char *name; +option(char *name) { OPTION tmp; @@ -150,9 +148,8 @@ option(name) } int -typecompare(a, b) - const void *a, *b; +typecompare(const void *a, const void *b) { - return (strcmp(((OPTION *)a)->name, ((OPTION *)b)->name)); + return (strcmp(((const OPTION *)a)->name, ((const OPTION *)b)->name)); }