aboutsummaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorGravatar Denis Vlasenko <vda.linux@googlemail.com>2009-03-20 22:17:13 +0000
committerGravatar Denis Vlasenko <vda.linux@googlemail.com>2009-03-20 22:17:13 +0000
commit83518d18a34a3ddfcaac1739930d8469f5bc2442 (patch)
tree2af665365a69f2689288cc13bb65efbb59e7d520 /findutils/find.c
parent0b28103cc774eb1ee62362cf61d52c32d44ec2cf (diff)
downloadbusybox-83518d18a34a3ddfcaac1739930d8469f5bc2442.tar.gz
busybox-83518d18a34a3ddfcaac1739930d8469f5bc2442.tar.bz2
Compatibility fixes:
grep: support -z find: support --mindepth together +45 bytes cpio: support -p (configurable, +230 bytes) libbb: tweaks for cpio
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/findutils/find.c b/findutils/find.c
index f2b89746f..df632f219 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -381,9 +381,11 @@ static int FAST_FUNC fileAction(const char *fileName,
{
int i;
#if ENABLE_FEATURE_FIND_MAXDEPTH
- int maxdepth = (int)(ptrdiff_t)userData;
+#define minmaxdepth ((int*)userData)
- if (depth > maxdepth) return SKIP;
+ if (depth < minmaxdepth[0]) return TRUE;
+ if (depth > minmaxdepth[1]) return SKIP;
+#undef minmaxdepth
#endif
#if ENABLE_FEATURE_FIND_XDEV
@@ -812,19 +814,21 @@ int find_main(int argc, char **argv)
static const char options[] ALIGN1 =
"-follow\0"
USE_FEATURE_FIND_XDEV( "-xdev\0" )
-USE_FEATURE_FIND_MAXDEPTH("-maxdepth\0")
+USE_FEATURE_FIND_MAXDEPTH("-mindepth\0""-maxdepth\0")
;
enum {
OPT_FOLLOW,
USE_FEATURE_FIND_XDEV( OPT_XDEV ,)
-USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
+USE_FEATURE_FIND_MAXDEPTH(OPT_MINDEPTH,)
};
char *arg;
char **argp;
int i, firstopt, status = EXIT_SUCCESS;
#if ENABLE_FEATURE_FIND_MAXDEPTH
- int maxdepth = INT_MAX;
+ int minmaxdepth[2] = { 0, INT_MAX };
+#else
+#define minmaxdepth NULL
#endif
for (firstopt = 1; firstopt < argc; firstopt++) {
@@ -875,10 +879,10 @@ USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
}
#endif
#if ENABLE_FEATURE_FIND_MAXDEPTH
- if (opt == OPT_MAXDEPTH) {
+ if (opt == OPT_MINDEPTH || opt == OPT_MINDEPTH + 1) {
if (!argp[1])
bb_show_usage();
- maxdepth = xatoi_u(argp[1]);
+ minmaxdepth[opt - OPT_MINDEPTH] = xatoi_u(argp[1]);
argp[0] = (char*)"-a";
argp[1] = (char*)"-a";
argp++;
@@ -895,9 +899,7 @@ USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
fileAction, /* file action */
fileAction, /* dir action */
#if ENABLE_FEATURE_FIND_MAXDEPTH
- /* double cast suppresses
- * "cast to ptr from int of different size" */
- (void*)(ptrdiff_t)maxdepth,/* user data */
+ minmaxdepth, /* user data */
#else
NULL, /* user data */
#endif