diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-22 04:30:20 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-22 04:30:20 +0000 |
commit | aa0765e11bdeba5c5abf745369a8430c8311d60c (patch) | |
tree | 3593c1a2ff03bfa79982fa12b55c9489f969e057 /findutils/find.c | |
parent | c49960189a04b73e033016bd0f43fbb950f800e1 (diff) | |
download | busybox-w32-aa0765e11bdeba5c5abf745369a8430c8311d60c.tar.gz busybox-w32-aa0765e11bdeba5c5abf745369a8430c8311d60c.tar.bz2 busybox-w32-aa0765e11bdeba5c5abf745369a8430c8311d60c.zip |
Added regexp support, fixed Changelog.
Diffstat (limited to 'findutils/find.c')
-rw-r--r-- | findutils/find.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/findutils/find.c b/findutils/find.c index 1db332297..c154cf4e7 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -21,14 +21,15 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "internal.h" | ||
25 | #include "regexp.h" | ||
24 | #include <stdio.h> | 26 | #include <stdio.h> |
25 | #include <unistd.h> | 27 | #include <unistd.h> |
26 | #include <dirent.h> | 28 | #include <dirent.h> |
27 | #include "internal.h" | ||
28 | 29 | ||
29 | 30 | ||
30 | static char* pattern=NULL; | 31 | static char* pattern=NULL; |
31 | static char* directory=NULL; | 32 | static char* directory="."; |
32 | static int dereferenceFlag=FALSE; | 33 | static int dereferenceFlag=FALSE; |
33 | 34 | ||
34 | static const char find_usage[] = "find [path...] [expression]\n" | 35 | static const char find_usage[] = "find [path...] [expression]\n" |
@@ -41,7 +42,7 @@ static int fileAction(const char *fileName, struct stat* statbuf) | |||
41 | { | 42 | { |
42 | if (pattern==NULL) | 43 | if (pattern==NULL) |
43 | fprintf(stdout, "%s\n", fileName); | 44 | fprintf(stdout, "%s\n", fileName); |
44 | else if (match(fileName, pattern) == TRUE) | 45 | else if (find_match(fileName, pattern, TRUE) == TRUE) |
45 | fprintf(stdout, "%s\n", fileName); | 46 | fprintf(stdout, "%s\n", fileName); |
46 | return( TRUE); | 47 | return( TRUE); |
47 | } | 48 | } |
@@ -53,7 +54,7 @@ static int dirAction(const char *fileName, struct stat* statbuf) | |||
53 | 54 | ||
54 | if (pattern==NULL) | 55 | if (pattern==NULL) |
55 | fprintf(stdout, "%s\n", fileName); | 56 | fprintf(stdout, "%s\n", fileName); |
56 | else if (match(fileName, pattern) == TRUE) | 57 | else if (find_match(fileName, pattern, TRUE) == TRUE) |
57 | fprintf(stdout, "%s\n", fileName); | 58 | fprintf(stdout, "%s\n", fileName); |
58 | 59 | ||
59 | dir = opendir( fileName); | 60 | dir = opendir( fileName); |
@@ -71,22 +72,18 @@ static int dirAction(const char *fileName, struct stat* statbuf) | |||
71 | 72 | ||
72 | int find_main(int argc, char **argv) | 73 | int find_main(int argc, char **argv) |
73 | { | 74 | { |
74 | if (argc <= 1) { | ||
75 | dirAction( ".", NULL); | ||
76 | } | ||
77 | |||
78 | /* peel off the "find" */ | 75 | /* peel off the "find" */ |
79 | argc--; | 76 | argc--; |
80 | argv++; | 77 | argv++; |
81 | 78 | ||
82 | if (**argv != '-') { | 79 | if ( argc > 0 && **argv != '-') { |
83 | directory=*argv; | 80 | directory=*argv; |
84 | argc--; | 81 | argc--; |
85 | argv++; | 82 | argv++; |
86 | } | 83 | } |
87 | 84 | ||
88 | /* Parse any options */ | 85 | /* Parse any options */ |
89 | while (**argv == '-') { | 86 | while (argc > 0 && **argv == '-') { |
90 | int stopit=FALSE; | 87 | int stopit=FALSE; |
91 | while (*++(*argv) && stopit==FALSE) switch (**argv) { | 88 | while (*++(*argv) && stopit==FALSE) switch (**argv) { |
92 | case 'f': | 89 | case 'f': |
@@ -120,6 +117,10 @@ int find_main(int argc, char **argv) | |||
120 | break; | 117 | break; |
121 | } | 118 | } |
122 | 119 | ||
123 | dirAction( directory, NULL); | 120 | if (recursiveAction(directory, TRUE, FALSE, FALSE, |
121 | fileAction, fileAction) == FALSE) { | ||
122 | exit( FALSE); | ||
123 | } | ||
124 | |||
124 | exit(TRUE); | 125 | exit(TRUE); |
125 | } | 126 | } |