diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-23 00:40:54 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-05-23 00:40:54 +0200 |
commit | b24ef035bd08919075edd79b906e18909ac44eb9 (patch) | |
tree | 78485aace67fbbf061b339b81af143b074ee4108 /findutils | |
parent | 7948ecb505135c811a44bc8f8e391622d893d383 (diff) |
find: cater for libc w/o FNM_CASEFOLD
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'findutils')
-rw-r--r-- | findutils/find.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/findutils/find.c b/findutils/find.c index 7918240f4..050d6373e 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -330,7 +330,11 @@ #include <fnmatch.h> #include "libbb.h" #if ENABLE_FEATURE_FIND_REGEX -#include "xregex.h" +# include "xregex.h" +#endif +/* GNUism: */ +#ifndef FNM_CASEFOLD +# define FNM_CASEFOLD 0 #endif /* This is a NOEXEC applet. Be very careful! */ @@ -474,6 +478,22 @@ static int exec_actions(action ***appp, const char *fileName, const struct stat } +#if !FNM_CASEFOLD +static char *strcpy_upcase(char *dst, const char *src) +{ + char *d = dst; + while (1) { + unsigned char ch = *src++; + if (ch >= 'a' && ch <= 'z') + ch -= ('a' - 'A'); + *d++ = ch; + if (ch == '\0') + break; + } + return dst; +} +#endif + ACTF(name) { const char *tmp = bb_basename(fileName); @@ -489,13 +509,25 @@ ACTF(name) * but somewhere between 4.1.20 and 4.4.0 GNU find stopped using it. * find -name '*foo' should match .foo too: */ +#if FNM_CASEFOLD return fnmatch(ap->pattern, tmp, (ap->iname ? FNM_CASEFOLD : 0)) == 0; +#else + if (ap->iname) + tmp = strcpy_upcase(alloca(strlen(tmp) + 1), tmp); + return fnmatch(ap->pattern, tmp, 0) == 0; +#endif } #if ENABLE_FEATURE_FIND_PATH ACTF(path) { +# if FNM_CASEFOLD return fnmatch(ap->pattern, fileName, (ap->ipath ? FNM_CASEFOLD : 0)) == 0; +# else + if (ap->ipath) + fileName = strcpy_upcase(alloca(strlen(fileName) + 1), fileName); + return fnmatch(ap->pattern, fileName, 0) == 0; +# endif } #endif #if ENABLE_FEATURE_FIND_REGEX |