summaryrefslogtreecommitdiff
path: root/findutils/find.c
diff options
context:
space:
mode:
authorEric Andersen1999-10-22 04:30:20 +0000
committerEric Andersen1999-10-22 04:30:20 +0000
commitaa0765e11bdeba5c5abf745369a8430c8311d60c (patch)
tree3593c1a2ff03bfa79982fa12b55c9489f969e057 /findutils/find.c
parentc49960189a04b73e033016bd0f43fbb950f800e1 (diff)
downloadbusybox-aa0765e11bdeba5c5abf745369a8430c8311d60c.zip
busybox-aa0765e11bdeba5c5abf745369a8430c8311d60c.tar.gz
Added regexp support, fixed Changelog.
Diffstat (limited to 'findutils/find.c')
-rw-r--r--findutils/find.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/findutils/find.c b/findutils/find.c
index 1db3322..c154cf4 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -21,14 +21,15 @@
*
*/
+#include "internal.h"
+#include "regexp.h"
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
-#include "internal.h"
static char* pattern=NULL;
-static char* directory=NULL;
+static char* directory=".";
static int dereferenceFlag=FALSE;
static const char find_usage[] = "find [path...] [expression]\n"
@@ -41,7 +42,7 @@ static int fileAction(const char *fileName, struct stat* statbuf)
{
if (pattern==NULL)
fprintf(stdout, "%s\n", fileName);
- else if (match(fileName, pattern) == TRUE)
+ else if (find_match(fileName, pattern, TRUE) == TRUE)
fprintf(stdout, "%s\n", fileName);
return( TRUE);
}
@@ -53,7 +54,7 @@ static int dirAction(const char *fileName, struct stat* statbuf)
if (pattern==NULL)
fprintf(stdout, "%s\n", fileName);
- else if (match(fileName, pattern) == TRUE)
+ else if (find_match(fileName, pattern, TRUE) == TRUE)
fprintf(stdout, "%s\n", fileName);
dir = opendir( fileName);
@@ -71,22 +72,18 @@ static int dirAction(const char *fileName, struct stat* statbuf)
int find_main(int argc, char **argv)
{
- if (argc <= 1) {
- dirAction( ".", NULL);
- }
-
/* peel off the "find" */
argc--;
argv++;
- if (**argv != '-') {
+ if ( argc > 0 && **argv != '-') {
directory=*argv;
argc--;
argv++;
}
/* Parse any options */
- while (**argv == '-') {
+ while (argc > 0 && **argv == '-') {
int stopit=FALSE;
while (*++(*argv) && stopit==FALSE) switch (**argv) {
case 'f':
@@ -120,6 +117,10 @@ int find_main(int argc, char **argv)
break;
}
- dirAction( directory, NULL);
+ if (recursiveAction(directory, TRUE, FALSE, FALSE,
+ fileAction, fileAction) == FALSE) {
+ exit( FALSE);
+ }
+
exit(TRUE);
}