summaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-09-01 04:30:18 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-09-01 04:30:18 +0000
commit8dad430db90288ee99638aaf3f18fb518bba269c (patch)
treed088b5867f5ddf5598930427c41ed880f59f3ae2 /usr.bin/find
parent10a0f9a6e2e02a8c66e4031ad1b040cd89267df7 (diff)
Add support for -mindepth while at it
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/extern.h5
-rw-r--r--usr.bin/find/find.17
-rw-r--r--usr.bin/find/find.h43
-rw-r--r--usr.bin/find/function.c43
-rw-r--r--usr.bin/find/option.c8
5 files changed, 71 insertions, 35 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h
index d3d3578cb8e..993f2d7ad67 100644
--- a/usr.bin/find/extern.h
+++ b/usr.bin/find/extern.h
@@ -1,4 +1,4 @@
-/* * $OpenBSD: extern.h,v 1.3 1996/08/31 22:40:18 tholo Exp $*/
+/* * $OpenBSD: extern.h,v 1.4 1996/09/01 04:30:15 tholo Exp $*/
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -59,7 +59,8 @@ PLAN *c_group __P((char *));
PLAN *c_inum __P((char *));
PLAN *c_links __P((char *));
PLAN *c_ls __P((void));
-PLAN *c_mdepth __P((char *));
+PLAN *c_maxdepth __P((char *));
+PLAN *c_mindepth __P((char *));
PLAN *c_name __P((char *));
PLAN *c_newer __P((char *));
PLAN *c_nogroup __P((void));
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1
index 2bb96ee1c50..18ef89b48fb 100644
--- a/usr.bin/find/find.1
+++ b/usr.bin/find/find.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: find.1,v 1.6 1996/08/31 22:40:19 tholo Exp $
+.\" $OpenBSD: find.1,v 1.7 1996/09/01 04:30:16 tholo Exp $
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -192,7 +192,10 @@ If the file is a symbolic link, the pathname of the linked\-to file will be
displayed preceded by ``\->''.
The format is identical to that produced by ``ls \-dgils''.
.It Ic -maxdepth Ar n
-True if the current search depth is less than what is specified in
+True if the current search depth is less than or equal to what is specified in
+.Ar n .
+.It Ic -mindepth Ar n
+True if the current search depth is at least what is specified in
.Ar n .
.It Ic -mtime Ar n
True if the difference between the file last modification time and the time
diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h
index 829e504c68c..20a41d6f7a5 100644
--- a/usr.bin/find/find.h
+++ b/usr.bin/find/find.h
@@ -1,4 +1,4 @@
-/* * $OpenBSD: find.h,v 1.3 1996/08/31 22:40:20 tholo Exp $*/
+/* * $OpenBSD: find.h,v 1.4 1996/09/01 04:30:16 tholo Exp $*/
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -41,9 +41,10 @@
enum ntype {
N_AND = 1, /* must start > 0 */
N_ATIME, N_CLOSEPAREN, N_CTIME, N_DEPTH, N_EXEC, N_EXPR, N_FOLLOW,
- N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MDEPTH, N_MTIME, N_NAME,
- N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
- N_PERM, N_PRINT, N_PRINT0, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
+ N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MAXDEPTH, N_MINDEPTH,
+ N_MTIME, N_NAME, N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK,
+ N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRUNE,
+ N_SIZE, N_TYPE, N_USER, N_XDEV,
};
/* node definition */
@@ -77,24 +78,26 @@ typedef struct _plandata {
} ex;
char *_a_data[2]; /* array of char pointers */
char *_c_data; /* char pointer */
- int _d_data; /* tree depth */
+ int _max_data; /* tree depth */
+ int _min_data; /* tree depth */
} p_un;
} PLAN;
-#define a_data p_un._a_data
-#define c_data p_un._c_data
-#define d_data p_un._d_data
-#define i_data p_un._i_data
-#define g_data p_un._g_data
-#define l_data p_un._l_data
-#define m_data p_un._m_data
-#define mt_data p_un._mt_data
-#define o_data p_un._o_data
-#define p_data p_un._p_data
-#define t_data p_un._t_data
-#define u_data p_un._u_data
-#define e_argv p_un.ex._e_argv
-#define e_orig p_un.ex._e_orig
-#define e_len p_un.ex._e_len
+#define a_data p_un._a_data
+#define c_data p_un._c_data
+#define i_data p_un._i_data
+#define g_data p_un._g_data
+#define l_data p_un._l_data
+#define m_data p_un._m_data
+#define max_data p_un._max_data
+#define min_data p_un._min_data
+#define mt_data p_un._mt_data
+#define o_data p_un._o_data
+#define p_data p_un._p_data
+#define t_data p_un._t_data
+#define u_data p_un._u_data
+#define e_argv p_un.ex._e_argv
+#define e_orig p_un.ex._e_orig
+#define e_len p_un.ex._e_len
typedef struct _option {
char *name; /* option name */
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 707a925b24c..42a4506d022 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: function.c,v 1.5 1996/08/31 22:40:21 tholo Exp $ */
+/* $OpenBSD: function.c,v 1.6 1996/09/01 04:30:17 tholo Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: function.c,v 1.5 1996/08/31 22:40:21 tholo Exp $";
+static char rcsid[] = "$OpenBSD: function.c,v 1.6 1996/09/01 04:30:17 tholo Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -550,25 +550,52 @@ c_ls()
* maximum depth specified
*/
int
-f_mdepth(plan, entry)
+f_maxdepth(plan, entry)
PLAN *plan;
FTSENT *entry;
{
extern FTS *tree;
- if (entry->fts_level >= plan->d_data)
+ if (entry->fts_level >= plan->max_data)
fts_set(tree, entry, FTS_SKIP);
- return (entry->fts_level <= plan->d_data);
+ return (entry->fts_level <= plan->max_data);
}
PLAN *
-c_mdepth(arg)
+c_maxdepth(arg)
char *arg;
{
PLAN *new;
- new = palloc(N_MDEPTH, f_mdepth);
- new->d_data = atoi(arg);
+ new = palloc(N_MAXDEPTH, f_maxdepth);
+ new->max_data = atoi(arg);
+ return (new);
+}
+
+/*
+ * - mindepth n functions --
+ *
+ * True if the current search depth is greater than or equal to the
+ * minimum depth specified
+ */
+int
+f_mindepth(plan, entry)
+ PLAN *plan;
+ FTSENT *entry;
+{
+ extern FTS *tree;
+
+ return (entry->fts_level >= plan->min_data);
+}
+
+PLAN *
+c_mindepth(arg)
+ char *arg;
+{
+ PLAN *new;
+
+ new = palloc(N_MINDEPTH, f_mindepth);
+ new->min_data = atoi(arg);
return (new);
}
diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c
index f9ceb16986a..6d7d123dfd8 100644
--- a/usr.bin/find/option.c
+++ b/usr.bin/find/option.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: option.c,v 1.3 1996/08/31 22:40:22 tholo Exp $ */
+/* $OpenBSD: option.c,v 1.4 1996/09/01 04:30:17 tholo Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)option.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: option.c,v 1.3 1996/08/31 22:40:22 tholo Exp $";
+static char rcsid[] = "$OpenBSD: option.c,v 1.4 1996/09/01 04:30:17 tholo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -69,7 +69,9 @@ static OPTION options[] = {
{ "-inum", N_INUM, c_inum, O_ARGV },
{ "-links", N_LINKS, c_links, O_ARGV },
{ "-ls", N_LS, c_ls, O_ZERO },
- { "-maxdepth", N_MDEPTH, c_mdepth, O_ARGV },
+ { "-maxdepth", N_MAXDEPTH, c_maxdepth, O_ARGV },
+ { "-mindepth", N_MINDEPTH, c_mindepth, O_ARGV },
+ { "-mount", N_XDEV, c_xdev, O_ZERO },
{ "-mtime", N_MTIME, c_mtime, O_ARGV },
{ "-name", N_NAME, c_name, O_ARGV },
{ "-newer", N_NEWER, c_newer, O_ARGV },