From 403b699b0bdc8ec46d549ac1bc45d2592e294033 Mon Sep 17 00:00:00 2001 From: lukem Date: Sun, 19 Oct 1997 11:52:12 +0000 Subject: [PATCH] fix .Nm usage, deprecate register, mostly WARNSify (needs minor rewrite to fix) --- usr.bin/find/extern.h | 5 +-- usr.bin/find/find.1 | 38 ++++++++++---------- usr.bin/find/find.c | 14 +++++--- usr.bin/find/function.c | 78 ++++++++++++++++++++++++++++------------- usr.bin/find/ls.c | 19 +++++++--- usr.bin/find/main.c | 13 ++++--- usr.bin/find/misc.c | 24 +++++++------ usr.bin/find/operator.c | 27 +++++++------- 8 files changed, 136 insertions(+), 82 deletions(-) diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index 32df1cd9dfb1..131514042938 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.5 1997/01/09 20:19:09 tls Exp $ */ +/* $NetBSD: extern.h,v 1.6 1997/10/19 11:52:12 lukem Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -33,7 +33,7 @@ * SUCH DAMAGE. * * from: @(#)extern.h 8.1 (Berkeley) 6/6/93 - * $NetBSD: extern.h,v 1.5 1997/01/09 20:19:09 tls Exp $ + * $NetBSD: extern.h,v 1.6 1997/10/19 11:52:12 lukem Exp $ */ #include @@ -43,6 +43,7 @@ void *emalloc __P((unsigned int)); PLAN *find_create __P((char ***)); void find_execute __P((PLAN *, char **)); PLAN *find_formplan __P((char **)); +int f_expr __P((PLAN *, FTSENT *)); PLAN *not_squish __P((PLAN *)); OPTION *option __P((char *)); PLAN *or_squish __P((PLAN *)); diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 2cf82a983acc..dcea12774d87 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: find.1,v 1.11 1997/01/09 20:19:09 tls Exp $ +.\" $NetBSD: find.1,v 1.12 1997/10/19 11:52:22 lukem Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)find.1 8.1 (Berkeley) 6/6/93 -.\" $NetBSD: find.1,v 1.11 1997/01/09 20:19:09 tls Exp $ +.\" $NetBSD: find.1,v 1.12 1997/10/19 11:52:22 lukem Exp $ .\" .Dd June 6, 1993 .Dt FIND 1 @@ -44,13 +44,13 @@ .Nm find .Nd walk a file hierarchy .Sh SYNOPSIS -.Nm find +.Nm .Op Fl HdhXx .Op Fl f Ar file .Op Ar file ... .Ar expression .Sh DESCRIPTION -.Nm Find +.Nm recursively descends the directory tree for each .Ar file listed, evaluating an @@ -75,12 +75,12 @@ the command line is that of the link itself. The .Fl d option causes -.Nm find +.Nm to perform a depth\-first traversal, i.e. directories are visited in post\-order and all entries in a directory will be acted on before the directory itself. By default, -.Nm find +.Nm visits directories in pre\-order, i.e. before their contents. Note, the default is .Ar not @@ -89,7 +89,7 @@ a breadth\-first traversal. The .Fl f option specifies a file hierarchy for -.Nm find +.Nm to traverse. File hierarchies may also be specified as the operands immediately following the options. @@ -119,7 +119,7 @@ quotes, backslash (``\e''), space, tab and newline characters. The .Fl x option prevents -.Nm find +.Nm from descending into directories that have a device number different than that of the file from which the descent began. .El @@ -127,14 +127,14 @@ than that of the file from which the descent began. .Bl -tag -width Ds .It Ic -atime Ar n True if the difference between the file last access time and the time -.Nm find +.Nm was started, rounded up to the next full 24\-hour period, is .Ar n 24\-hour periods. .It Ic -ctime Ar n True if the difference between the time of last change of file status information and the time -.Nm find +.Nm was started, rounded up to the next full 24\-hour period, is .Ar n 24\-hour periods. @@ -148,7 +148,7 @@ If the string ``{}'' appears anywhere in the utility name or the arguments it is replaced by the pathname of the current file. .Ar Utility will be executed from the directory from which -.Nm find +.Nm was executed. .It Ic -follow Follow symbolic links. @@ -159,7 +159,7 @@ Two special file system types are recognized: ``local'' and ``rdonly''. These do not describe actual file system types; the former matches any file system physically mounted on the system where the -.Nm find +.Nm is being executed, and the latter matches any file system which is mounted read-only. .It Ic -group Ar gname @@ -189,7 +189,7 @@ displayed preceded by ``\->''. The format is identical to that produced by ``ls \-dgils''. .It Ic -mtime Ar n True if the difference between the file last modification time and the time -.Nm find +.Nm was started, rounded up to the next full 24\-hour period, is .Ar n 24\-hour periods. @@ -199,7 +199,7 @@ The primary is identical to the .Ic -exec primary with the exception that -.Nm find +.Nm requests user affirmation for the execution of the utility by printing a message to the terminal and reading a response. If the response is other than ``y'' the command is not executed and the @@ -279,7 +279,7 @@ by a null character. .It Ic -prune This primary always evaluates to true. It causes -.Nm find +.Nm to not descend into the current file. Note, the .Ic -prune @@ -370,10 +370,10 @@ The second expression is not evaluated if the first expression is true. .El .Pp All operands and primaries must be separate arguments to -.Nm find . +.Nm "" . Primaries which themselves take arguments expect each argument to be a separate argument to -.Nm find . +.Nm "" . .Sh EXAMPLES .Pp The following examples are shown as given to the shell: @@ -401,7 +401,7 @@ that are newer than ``ttt''. .Xr symlink 7 .Sh STANDARDS The -.Nm find +.Nm utility syntax is a superset of the syntax specified by the .St -p1003.2 standard. @@ -445,7 +445,7 @@ This version replaces it no matter where in the utility name or arguments it appears. .Sh BUGS The special characters used by -.Nm find +.Nm are also special characters to many shell programs. In particular, the characters ``*'', ``['', ``]'', ``?'', ``('', ``)'', ``!'', ``\e'' and ``;'' may have to be escaped from the shell. diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c index ad8ab81a5d1c..f983f0c2f3f4 100644 --- a/usr.bin/find/find.c +++ b/usr.bin/find/find.c @@ -1,4 +1,4 @@ -/* $NetBSD: find.c,v 1.8 1997/01/09 20:19:10 tls Exp $ */ +/* $NetBSD: find.c,v 1.9 1997/10/19 11:52:27 lukem Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -36,9 +36,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)find.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$NetBSD: find.c,v 1.8 1997/01/09 20:19:10 tls Exp $"; +#if 0 +static char sccsid[] = "from: @(#)find.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: find.c,v 1.9 1997/10/19 11:52:27 lukem Exp $"); +#endif #endif /* not lint */ #include @@ -157,10 +161,10 @@ find_execute(plan, paths) register FTSENT *entry; PLAN *p; - if (!(tree = fts_open(paths, ftsoptions, (int (*)())NULL))) + if (!(tree = fts_open(paths, ftsoptions, NULL))) err(1, "ftsopen"); - while (entry = fts_read(tree)) { + while ((entry = fts_read(tree)) != NULL) { switch(entry->fts_info) { case FTS_D: if (isdepth) diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index c901d5156757..eddd0646b12d 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $NetBSD: function.c,v 1.20 1997/02/01 09:51:48 matthias Exp $ */ +/* $NetBSD: function.c,v 1.21 1997/10/19 11:52:32 lukem Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -36,9 +36,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$NetBSD: function.c,v 1.20 1997/02/01 09:51:48 matthias Exp $"; +#if 0 +static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: function.c,v 1.21 1997/10/19 11:52:32 lukem Exp $"); +#endif #endif /* not lint */ #include @@ -74,7 +78,32 @@ static char rcsid[] = "$NetBSD: function.c,v 1.20 1997/02/01 09:51:48 matthias E } \ } -static PLAN *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *)))); +static long find_parsenum __P((PLAN *, char *, char *, char *)); + int f_always_true __P((PLAN *, FTSENT *)); + int f_atime __P((PLAN *, FTSENT *)); + int f_ctime __P((PLAN *, FTSENT *)); + int f_exec __P((PLAN *, FTSENT *)); + int f_fstype __P((PLAN *, FTSENT *)); + int f_group __P((PLAN *, FTSENT *)); + int f_inum __P((PLAN *, FTSENT *)); + int f_links __P((PLAN *, FTSENT *)); + int f_ls __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_prune __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 *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *)))); /* * find_parsenum -- @@ -227,11 +256,11 @@ c_depth() */ int f_exec(plan, entry) - register PLAN *plan; + PLAN *plan; FTSENT *entry; { extern int dotfd; - register int cnt; + int cnt; pid_t pid; int status; @@ -277,8 +306,8 @@ c_exec(argvp, isok) int isok; { PLAN *new; /* node returned */ - register int cnt; - register char **argv, **ap, *p; + int cnt; + char **argv, **ap, *p; isoutput = 1; @@ -360,7 +389,7 @@ f_fstype(plan, entry) */ if (entry->fts_info == FTS_SL || entry->fts_info == FTS_SLNONE) { - if (p = strrchr(entry->fts_accpath, '/')) + if ((p = strrchr(entry->fts_accpath, '/')) != NULL) ++p; else p = entry->fts_accpath; @@ -403,7 +432,7 @@ PLAN * c_fstype(arg) char *arg; { - register PLAN *new; + PLAN *new; ftsoptions &= ~FTS_NOSTAT; @@ -641,8 +670,6 @@ f_nogroup(plan, entry) PLAN *plan; FTSENT *entry; { - char *group_from_gid(); - return (group_from_gid(entry->fts_statp->st_gid, 1) ? 0 : 1); } @@ -665,8 +692,6 @@ f_nouser(plan, entry) PLAN *plan; FTSENT *entry; { - char *user_from_uid(); - return (user_from_uid(entry->fts_statp->st_uid, 1) ? 0 : 1); } @@ -764,7 +789,7 @@ f_print(plan, entry) return(1); } -/* ARGSUSED */ +int f_print0(plan, entry) PLAN *plan; FTSENT *entry; @@ -977,9 +1002,10 @@ f_expr(plan, entry) PLAN *plan; FTSENT *entry; { - register PLAN *p; - register int state; + PLAN *p; + int state; + state = 0; for (p = plan->p_data[0]; p && (state = (p->eval)(p, entry)); p = p->next); return (state); @@ -993,13 +1019,13 @@ f_expr(plan, entry) PLAN * c_openparen() { - return (palloc(N_OPENPAREN, (int (*)())-1)); + return (palloc(N_OPENPAREN, (int (*) __P((PLAN *, FTSENT *)))-1)); } PLAN * c_closeparen() { - return (palloc(N_CLOSEPAREN, (int (*)())-1)); + return (palloc(N_CLOSEPAREN, (int (*) __P((PLAN *, FTSENT *)))-1)); } /* @@ -1012,9 +1038,10 @@ f_not(plan, entry) PLAN *plan; FTSENT *entry; { - register PLAN *p; - register int state; + PLAN *p; + int state; + state = 0; for (p = plan->p_data[0]; p && (state = (p->eval)(p, entry)); p = p->next); return (!state); @@ -1037,9 +1064,10 @@ f_or(plan, entry) PLAN *plan; FTSENT *entry; { - register PLAN *p; - register int state; + PLAN *p; + int state; + state = 0; for (p = plan->p_data[0]; p && (state = (p->eval)(p, entry)); p = p->next); @@ -1064,13 +1092,13 @@ palloc(t, f) { PLAN *new; - if (new = malloc(sizeof(PLAN))) { + if ((new = malloc(sizeof(PLAN))) != NULL) { new->type = t; new->eval = f; new->flags = 0; new->next = NULL; return (new); } - err(1, NULL); + err(1, "malloc"); /* NOTREACHED */ } diff --git a/usr.bin/find/ls.c b/usr.bin/find/ls.c index b1a0782c8d45..912fa36e8a4d 100644 --- a/usr.bin/find/ls.c +++ b/usr.bin/find/ls.c @@ -1,4 +1,4 @@ -/* $NetBSD: ls.c,v 1.8 1997/06/30 21:26:57 jtc Exp $ */ +/* $NetBSD: ls.c,v 1.9 1997/10/19 11:52:38 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -33,9 +33,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)ls.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$NetBSD: ls.c,v 1.8 1997/06/30 21:26:57 jtc Exp $"; +#if 0 +static char sccsid[] = "from: @(#)ls.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ls.c,v 1.9 1997/10/19 11:52:38 lukem Exp $"); +#endif #endif /* not lint */ #include @@ -43,6 +47,9 @@ static char rcsid[] = "$NetBSD: ls.c,v 1.8 1997/06/30 21:26:57 jtc Exp $"; #include #include +#include +#include +#include #include #include #include @@ -50,6 +57,8 @@ static char rcsid[] = "$NetBSD: ls.c,v 1.8 1997/06/30 21:26:57 jtc Exp $"; #include #include +#include "find.h" + /* Derived from the print routines in the ls(1) source code. */ static void printlink __P((char *)); @@ -61,9 +70,9 @@ printlong(name, accpath, sb) char *accpath; /* current valid path to filename */ struct stat *sb; /* stat buffer */ { - char modep[15], *user_from_uid(), *group_from_gid(); + char modep[15]; - (void)printf("%6lu %4qd ", sb->st_ino, sb->st_blocks); + (void)printf("%6lu %4qd ", (u_long)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, diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index 237178ce3906..ff03a43305a3 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.7 1997/10/18 14:49:45 lukem Exp $ */ +/* $NetBSD: main.c,v 1.8 1997/10/19 11:52:43 lukem Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -33,9 +33,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$NetBSD: main.c,v 1.7 1997/10/18 14:49:45 lukem Exp $"; +#if 0 +static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: main.c,v 1.8 1997/10/19 11:52:43 lukem Exp $"); +#endif #endif /* not lint */ #include @@ -59,6 +63,7 @@ int isdepth; /* do directories on post-order visit */ int isoutput; /* user specified output operator */ int isxargs; /* don't permit xargs delimiting chars */ +int main __P((int, char **)); static void usage __P((void)); int @@ -66,7 +71,7 @@ main(argc, argv) int argc; char *argv[]; { - register char **p, **start; + char **p, **start; int ch; (void)time(&now); /* initialize the time-of-day */ diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c index a8b6c7b9a9ef..943ed0a1c715 100644 --- a/usr.bin/find/misc.c +++ b/usr.bin/find/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.5 1997/01/09 20:19:15 tls Exp $ */ +/* $NetBSD: misc.c,v 1.6 1997/10/19 11:52:50 lukem Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -36,9 +36,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$NetBSD: misc.c,v 1.5 1997/01/09 20:19:15 tls Exp $"; +#if 0 +static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: misc.c,v 1.6 1997/10/19 11:52:50 lukem Exp $"); +#endif #endif /* not lint */ #include @@ -63,15 +67,15 @@ brace_subst(orig, store, path, len) char *orig, **store, *path; int len; { - register int plen; - register char ch, *p; + int plen; + char ch, *p; plen = strlen(path); - for (p = *store; ch = *orig; ++orig) + for (p = *store; (ch = *orig) != 0; ++orig) if (ch == '{' && orig[1] == '}') { while ((p - *store) + plen > len) if (!(*store = realloc(*store, len *= 2))) - err(1, NULL); + err(1, "realloc"); memmove(p, path, plen); p += plen; ++orig; @@ -87,7 +91,7 @@ brace_subst(orig, store, path, len) */ int queryuser(argv) - register char **argv; + char **argv; { int ch, first, nl; @@ -125,7 +129,7 @@ emalloc(len) { void *p; - if (p = malloc(len)) + if ((p = malloc(len)) != NULL) return (p); - err(1, NULL); + err(1, "malloc"); } diff --git a/usr.bin/find/operator.c b/usr.bin/find/operator.c index b07a74d61cfb..bd717418ce49 100644 --- a/usr.bin/find/operator.c +++ b/usr.bin/find/operator.c @@ -1,4 +1,4 @@ -/* $NetBSD: operator.c,v 1.4 1997/01/09 20:19:15 tls Exp $ */ +/* $NetBSD: operator.c,v 1.5 1997/10/19 11:52:55 lukem Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -36,9 +36,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -/*static char sccsid[] = "from: @(#)operator.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$NetBSD: operator.c,v 1.4 1997/01/09 20:19:15 tls Exp $"; +#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 $"); +#endif #endif /* not lint */ #include @@ -76,11 +80,10 @@ static PLAN * yankexpr(planp) PLAN **planp; /* pointer to top of plan (modified) */ { - register PLAN *next; /* temp node holding subexpression results */ + 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 */ - int f_expr(); /* first pull the top node from the plan */ if ((node = yanknode(planp)) == NULL) @@ -131,8 +134,8 @@ PLAN * paren_squish(plan) PLAN *plan; /* plan with ( ) nodes */ { - register PLAN *expr; /* pointer to next expression */ - register PLAN *tail; /* pointer to tail of result plan */ + 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; @@ -169,9 +172,9 @@ PLAN * not_squish(plan) PLAN *plan; /* plan to process */ { - register PLAN *next; /* next node being processed */ - register PLAN *node; /* temporary node used in N_NOT processing */ - register PLAN *tail; /* pointer to tail of result plan */ + 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; @@ -227,8 +230,8 @@ PLAN * or_squish(plan) PLAN *plan; /* plan with ors to be squished */ { - register PLAN *next; /* next node being processed */ - register PLAN *tail; /* pointer to tail of result plan */ + 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;