diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-29 19:03:56 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-29 19:03:56 +0000 |
commit | e2fb719ba3463955f349ce63228981943f00bfaa (patch) | |
tree | 24e0cd10d80f7d97996e4d92d2f416c6b8b0e97d /findutils/find.c | |
parent | df0553bbd2c28336795aea6e723414029390a1c4 (diff) | |
download | busybox-w32-e2fb719ba3463955f349ce63228981943f00bfaa.tar.gz busybox-w32-e2fb719ba3463955f349ce63228981943f00bfaa.tar.bz2 busybox-w32-e2fb719ba3463955f349ce63228981943f00bfaa.zip |
find: small improvement
Diffstat (limited to 'findutils/find.c')
-rw-r--r-- | findutils/find.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/findutils/find.c b/findutils/find.c index 7869840e2..a3cbe668d 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -30,6 +30,8 @@ | |||
30 | * file.txt file.txt | 30 | * file.txt file.txt |
31 | * file.txt | 31 | * file.txt |
32 | * /tmp | 32 | * /tmp |
33 | * # find -name '*.c' -o -name '*.h' | ||
34 | * [shows files, *.c and *.h intermixed] | ||
33 | */ | 35 | */ |
34 | 36 | ||
35 | #include "busybox.h" | 37 | #include "busybox.h" |
@@ -93,7 +95,6 @@ static char* subst(const char *src, int count, const char* filename) | |||
93 | { | 95 | { |
94 | char *buf, *dst, *end; | 96 | char *buf, *dst, *end; |
95 | int flen = strlen(filename); | 97 | int flen = strlen(filename); |
96 | //puts(src); | ||
97 | /* we replace each '{}' with filename: growth by strlen-2 */ | 98 | /* we replace each '{}' with filename: growth by strlen-2 */ |
98 | buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1); | 99 | buf = dst = xmalloc(strlen(src) + count*(flen-2) + 1); |
99 | while ((end = strstr(src, "{}"))) { | 100 | while ((end = strstr(src, "{}"))) { |
@@ -104,7 +105,6 @@ static char* subst(const char *src, int count, const char* filename) | |||
104 | dst += flen; | 105 | dst += flen; |
105 | } | 106 | } |
106 | strcpy(dst, src); | 107 | strcpy(dst, src); |
107 | //puts(buf); | ||
108 | return buf; | 108 | return buf; |
109 | } | 109 | } |
110 | 110 | ||
@@ -363,16 +363,20 @@ int find_main(int argc, char **argv) | |||
363 | } | 363 | } |
364 | 364 | ||
365 | if (firstopt == 1) { | 365 | if (firstopt == 1) { |
366 | if (!recursive_action(".", TRUE, dereference, FALSE, fileAction, | 366 | static const char *const dot[] = { ".", NULL }; |
367 | fileAction, NULL, 0)) | 367 | firstopt++; |
368 | argv = (char**)dot - 1; | ||
369 | } | ||
370 | for (i = 1; i < firstopt; i++) { | ||
371 | if (!recursive_action(argv[i], | ||
372 | TRUE, // recurse | ||
373 | dereference, // follow links | ||
374 | FALSE, // depth first | ||
375 | fileAction, // file action | ||
376 | fileAction, // dir action | ||
377 | NULL, // user data | ||
378 | 0)) // depth | ||
368 | status = EXIT_FAILURE; | 379 | status = EXIT_FAILURE; |
369 | } else { | ||
370 | for (i = 1; i < firstopt; i++) { | ||
371 | if (!recursive_action(argv[i], TRUE, dereference, FALSE, | ||
372 | fileAction, fileAction, NULL, 0)) | ||
373 | status = EXIT_FAILURE; | ||
374 | } | ||
375 | } | 380 | } |
376 | |||
377 | return status; | 381 | return status; |
378 | } | 382 | } |