aboutsummaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-03-20 22:17:13 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-03-20 22:17:13 +0000
commit83518d18a34a3ddfcaac1739930d8469f5bc2442 (patch)
tree2af665365a69f2689288cc13bb65efbb59e7d520 /findutils/find.c
parent0b28103cc774eb1ee62362cf61d52c32d44ec2cf (diff)
downloadbusybox-w32-83518d18a34a3ddfcaac1739930d8469f5bc2442.tar.gz
busybox-w32-83518d18a34a3ddfcaac1739930d8469f5bc2442.tar.bz2
busybox-w32-83518d18a34a3ddfcaac1739930d8469f5bc2442.zip
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,
381{ 381{
382 int i; 382 int i;
383#if ENABLE_FEATURE_FIND_MAXDEPTH 383#if ENABLE_FEATURE_FIND_MAXDEPTH
384 int maxdepth = (int)(ptrdiff_t)userData; 384#define minmaxdepth ((int*)userData)
385 385
386 if (depth > maxdepth) return SKIP; 386 if (depth < minmaxdepth[0]) return TRUE;
387 if (depth > minmaxdepth[1]) return SKIP;
388#undef minmaxdepth
387#endif 389#endif
388 390
389#if ENABLE_FEATURE_FIND_XDEV 391#if ENABLE_FEATURE_FIND_XDEV
@@ -812,19 +814,21 @@ int find_main(int argc, char **argv)
812 static const char options[] ALIGN1 = 814 static const char options[] ALIGN1 =
813 "-follow\0" 815 "-follow\0"
814USE_FEATURE_FIND_XDEV( "-xdev\0" ) 816USE_FEATURE_FIND_XDEV( "-xdev\0" )
815USE_FEATURE_FIND_MAXDEPTH("-maxdepth\0") 817USE_FEATURE_FIND_MAXDEPTH("-mindepth\0""-maxdepth\0")
816 ; 818 ;
817 enum { 819 enum {
818 OPT_FOLLOW, 820 OPT_FOLLOW,
819USE_FEATURE_FIND_XDEV( OPT_XDEV ,) 821USE_FEATURE_FIND_XDEV( OPT_XDEV ,)
820USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,) 822USE_FEATURE_FIND_MAXDEPTH(OPT_MINDEPTH,)
821 }; 823 };
822 824
823 char *arg; 825 char *arg;
824 char **argp; 826 char **argp;
825 int i, firstopt, status = EXIT_SUCCESS; 827 int i, firstopt, status = EXIT_SUCCESS;
826#if ENABLE_FEATURE_FIND_MAXDEPTH 828#if ENABLE_FEATURE_FIND_MAXDEPTH
827 int maxdepth = INT_MAX; 829 int minmaxdepth[2] = { 0, INT_MAX };
830#else
831#define minmaxdepth NULL
828#endif 832#endif
829 833
830 for (firstopt = 1; firstopt < argc; firstopt++) { 834 for (firstopt = 1; firstopt < argc; firstopt++) {
@@ -875,10 +879,10 @@ USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
875 } 879 }
876#endif 880#endif
877#if ENABLE_FEATURE_FIND_MAXDEPTH 881#if ENABLE_FEATURE_FIND_MAXDEPTH
878 if (opt == OPT_MAXDEPTH) { 882 if (opt == OPT_MINDEPTH || opt == OPT_MINDEPTH + 1) {
879 if (!argp[1]) 883 if (!argp[1])
880 bb_show_usage(); 884 bb_show_usage();
881 maxdepth = xatoi_u(argp[1]); 885 minmaxdepth[opt - OPT_MINDEPTH] = xatoi_u(argp[1]);
882 argp[0] = (char*)"-a"; 886 argp[0] = (char*)"-a";
883 argp[1] = (char*)"-a"; 887 argp[1] = (char*)"-a";
884 argp++; 888 argp++;
@@ -895,9 +899,7 @@ USE_FEATURE_FIND_MAXDEPTH(OPT_MAXDEPTH,)
895 fileAction, /* file action */ 899 fileAction, /* file action */
896 fileAction, /* dir action */ 900 fileAction, /* dir action */
897#if ENABLE_FEATURE_FIND_MAXDEPTH 901#if ENABLE_FEATURE_FIND_MAXDEPTH
898 /* double cast suppresses 902 minmaxdepth, /* user data */
899 * "cast to ptr from int of different size" */
900 (void*)(ptrdiff_t)maxdepth,/* user data */
901#else 903#else
902 NULL, /* user data */ 904 NULL, /* user data */
903#endif 905#endif