summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-29 19:03:56 +0000
committerDenis Vlasenko2006-10-29 19:03:56 +0000
commite2fb719ba3463955f349ce63228981943f00bfaa (patch)
tree24e0cd10d80f7d97996e4d92d2f416c6b8b0e97d
parentdf0553bbd2c28336795aea6e723414029390a1c4 (diff)
downloadbusybox-e2fb719ba3463955f349ce63228981943f00bfaa.zip
busybox-e2fb719ba3463955f349ce63228981943f00bfaa.tar.gz
find: small improvement
-rw-r--r--findutils/find.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 7869840..a3cbe66 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -30,6 +30,8 @@
* file.txt file.txt
* file.txt
* /tmp
+ * # find -name '*.c' -o -name '*.h'
+ * [shows files, *.c and *.h intermixed]
*/
#include "busybox.h"
@@ -93,7 +95,6 @@ static char* subst(const char *src, int count, const char* filename)
{
char *buf, *dst, *end;
int flen = strlen(filename);
-//puts(src);
/* we replace each '{}' with filename: growth by strlen-2 */
buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1);
while ((end = strstr(src, "{}"))) {
@@ -104,7 +105,6 @@ static char* subst(const char *src, int count, const char* filename)
dst += flen;
}
strcpy(dst, src);
-//puts(buf);
return buf;
}
@@ -363,16 +363,20 @@ int find_main(int argc, char **argv)
}
if (firstopt == 1) {
- if (!recursive_action(".", TRUE, dereference, FALSE, fileAction,
- fileAction, NULL, 0))
+ static const char *const dot[] = { ".", NULL };
+ firstopt++;
+ argv = (char**)dot - 1;
+ }
+ for (i = 1; i < firstopt; i++) {
+ if (!recursive_action(argv[i],
+ TRUE, // recurse
+ dereference, // follow links
+ FALSE, // depth first
+ fileAction, // file action
+ fileAction, // dir action
+ NULL, // user data
+ 0)) // depth
status = EXIT_FAILURE;
- } else {
- for (i = 1; i < firstopt; i++) {
- if (!recursive_action(argv[i], TRUE, dereference, FALSE,
- fileAction, fileAction, NULL, 0))
- status = EXIT_FAILURE;
- }
}
-
return status;
}