diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-09 10:07:39 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-09 10:07:39 +0000 |
commit | 75aa615bef478622cd0695b95adcf182fbbc3d95 (patch) | |
tree | 32fce466a6cefda67db2289b306a111e573b9a09 | |
parent | 9cb220be9dea5417c1ad0091bb7eeb1371891f89 (diff) | |
download | busybox-w32-75aa615bef478622cd0695b95adcf182fbbc3d95.tar.gz busybox-w32-75aa615bef478622cd0695b95adcf182fbbc3d95.tar.bz2 busybox-w32-75aa615bef478622cd0695b95adcf182fbbc3d95.zip |
find: add -iname support (Alexander Griesser <alexander.griesser@lkh-vil.or.at>)
-rw-r--r-- | findutils/find.c | 10 | ||||
-rw-r--r-- | include/usage.h | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/findutils/find.c b/findutils/find.c index 9efe2db40..8c0397798 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -76,7 +76,7 @@ typedef struct { | |||
76 | #define ACTS(name, arg...) typedef struct { action a; arg; } action_##name; | 76 | #define ACTS(name, arg...) typedef struct { action a; arg; } action_##name; |
77 | #define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap) | 77 | #define ACTF(name) static int func_##name(const char *fileName, struct stat *statbuf, action_##name* ap) |
78 | ACTS(print) | 78 | ACTS(print) |
79 | ACTS(name, const char *pattern;) | 79 | ACTS(name, const char *pattern; bool iname;) |
80 | USE_FEATURE_FIND_PATH( ACTS(path, const char *pattern;)) | 80 | USE_FEATURE_FIND_PATH( ACTS(path, const char *pattern;)) |
81 | USE_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;)) | 81 | USE_FEATURE_FIND_REGEX( ACTS(regex, regex_t compiled_pattern;)) |
82 | USE_FEATURE_FIND_PRINT0( ACTS(print0)) | 82 | USE_FEATURE_FIND_PRINT0( ACTS(print0)) |
@@ -188,8 +188,9 @@ ACTF(name) | |||
188 | if (*tmp == '/') | 188 | if (*tmp == '/') |
189 | tmp++; | 189 | tmp++; |
190 | } | 190 | } |
191 | return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0; | 191 | return fnmatch(ap->pattern, tmp, FNM_PERIOD | (ap->iname ? FNM_CASEFOLD : 0)) == 0; |
192 | } | 192 | } |
193 | |||
193 | #if ENABLE_FEATURE_FIND_PATH | 194 | #if ENABLE_FEATURE_FIND_PATH |
194 | ACTF(path) | 195 | ACTF(path) |
195 | { | 196 | { |
@@ -458,6 +459,7 @@ static action*** parse_params(char **argv) | |||
458 | USE_FEATURE_FIND_PAREN( PARM_char_brace,) | 459 | USE_FEATURE_FIND_PAREN( PARM_char_brace,) |
459 | /* All options starting from here require argument */ | 460 | /* All options starting from here require argument */ |
460 | PARM_name , | 461 | PARM_name , |
462 | PARM_iname , | ||
461 | USE_FEATURE_FIND_PATH( PARM_path ,) | 463 | USE_FEATURE_FIND_PATH( PARM_path ,) |
462 | USE_FEATURE_FIND_REGEX( PARM_regex ,) | 464 | USE_FEATURE_FIND_REGEX( PARM_regex ,) |
463 | USE_FEATURE_FIND_TYPE( PARM_type ,) | 465 | USE_FEATURE_FIND_TYPE( PARM_type ,) |
@@ -490,6 +492,7 @@ static action*** parse_params(char **argv) | |||
490 | USE_FEATURE_FIND_PAREN( "(\0" ) | 492 | USE_FEATURE_FIND_PAREN( "(\0" ) |
491 | /* All options starting from here require argument */ | 493 | /* All options starting from here require argument */ |
492 | "-name\0" | 494 | "-name\0" |
495 | "-iname\0" | ||
493 | USE_FEATURE_FIND_PATH( "-path\0" ) | 496 | USE_FEATURE_FIND_PATH( "-path\0" ) |
494 | USE_FEATURE_FIND_REGEX( "-regex\0" ) | 497 | USE_FEATURE_FIND_REGEX( "-regex\0" ) |
495 | USE_FEATURE_FIND_TYPE( "-type\0" ) | 498 | USE_FEATURE_FIND_TYPE( "-type\0" ) |
@@ -654,10 +657,11 @@ static action*** parse_params(char **argv) | |||
654 | argv = endarg; | 657 | argv = endarg; |
655 | } | 658 | } |
656 | #endif | 659 | #endif |
657 | else if (parm == PARM_name) { | 660 | else if (parm == PARM_name || parm == PARM_iname) { |
658 | action_name *ap; | 661 | action_name *ap; |
659 | ap = ALLOC_ACTION(name); | 662 | ap = ALLOC_ACTION(name); |
660 | ap->pattern = arg1; | 663 | ap->pattern = arg1; |
664 | ap->iname = (parm == PARM_iname); | ||
661 | } | 665 | } |
662 | #if ENABLE_FEATURE_FIND_PATH | 666 | #if ENABLE_FEATURE_FIND_PATH |
663 | else if (parm == PARM_path) { | 667 | else if (parm == PARM_path) { |
diff --git a/include/usage.h b/include/usage.h index 0ae819a1a..f6506b4f8 100644 --- a/include/usage.h +++ b/include/usage.h | |||
@@ -1008,6 +1008,7 @@ | |||
1008 | "\n -maxdepth N Descend at most N levels. -maxdepth 0 applies" \ | 1008 | "\n -maxdepth N Descend at most N levels. -maxdepth 0 applies" \ |
1009 | "\n tests/actions to command line arguments only") \ | 1009 | "\n tests/actions to command line arguments only") \ |
1010 | "\n -name PATTERN File name (w/o directory name) matches PATTERN" \ | 1010 | "\n -name PATTERN File name (w/o directory name) matches PATTERN" \ |
1011 | "\n -iname PATTERN Case insensitive -name" \ | ||
1011 | USE_FEATURE_FIND_PATH( \ | 1012 | USE_FEATURE_FIND_PATH( \ |
1012 | "\n -path PATTERN Path matches PATTERN") \ | 1013 | "\n -path PATTERN Path matches PATTERN") \ |
1013 | USE_FEATURE_FIND_REGEX( \ | 1014 | USE_FEATURE_FIND_REGEX( \ |