aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/glob.c
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-11-11 05:36:34 +0000
committerChristopher Faylor <me@cgf.cx>2000-11-11 05:36:34 +0000
commit6ccb6bcf3d24550eead6c969f2ac9a5f9f5105d3 (patch)
tree52dca8cef43f7e7420b218991742ed74d7170d55 /winsup/cygwin/glob.c
parent466ebd61d393cffdcb7eda14d5e45eab2cd10ed4 (diff)
downloadnewlib-6ccb6bcf3d24550eead6c969f2ac9a5f9f5105d3.zip
newlib-6ccb6bcf3d24550eead6c969f2ac9a5f9f5105d3.tar.gz
newlib-6ccb6bcf3d24550eead6c969f2ac9a5f9f5105d3.tar.bz2
* dcrt0.cc: New global variable `ignore_case_with_glob'.
(dll_crt0_1): Disable case-insensitive globbing before calling `main'. * environ.cc (glob_init): New static function to set or clear `ignore_case_with_glob'. (known): Changed "glob" entry to call `glob_init'. * glob.c (match): Use case-insensitive globbing if needed.
Diffstat (limited to 'winsup/cygwin/glob.c')
-rw-r--r--winsup/cygwin/glob.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/winsup/cygwin/glob.c b/winsup/cygwin/glob.c
index 2224bc2..59e6bbf 100644
--- a/winsup/cygwin/glob.c
+++ b/winsup/cygwin/glob.c
@@ -72,6 +72,7 @@
#include <sys/param.h>
#include <sys/stat.h>
+#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <glob.h>
@@ -81,6 +82,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <windows.h>
#ifdef __weak_alias
#ifdef __LIBC12_SOURCE__
@@ -174,6 +176,8 @@ static void qprintf __P((const char *, Char *));
#undef MAXPATHLEN
#define MAXPATHLEN 16384
+extern BOOL ignore_case_with_glob;
+
int
glob(pattern, flags, errfunc, pglob)
const char *pattern;
@@ -727,19 +731,41 @@ match(name, pat, patend)
return(0);
if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
++pat;
- while (((c = *pat++) & M_MASK) != M_END)
- if ((*pat & M_MASK) == M_RNG) {
- if (c <= k && k <= pat[1])
- ok = 1;
- pat += 2;
- } else if (c == k)
- ok = 1;
+ if (ignore_case_with_glob)
+ {
+ while (((c = *pat++) & M_MASK) != M_END)
+ if ((*pat & M_MASK) == M_RNG) {
+ if (tolower(c) <= tolower(k) && tolower(k) <= tolower(pat[1]))
+ ok = 1;
+ pat += 2;
+ } else if (tolower(c) == tolower(k))
+ ok = 1;
+ }
+ else
+ {
+ while (((c = *pat++) & M_MASK) != M_END)
+ if ((*pat & M_MASK) == M_RNG) {
+ if (c <= k && k <= pat[1])
+ ok = 1;
+ pat += 2;
+ } else if (c == k)
+ ok = 1;
+ }
if (ok == negate_range)
return(0);
break;
default:
- if (*name++ != c)
- return(0);
+ if (ignore_case_with_glob)
+ {
+ if (tolower(*name) != tolower(c))
+ return(0);
+ ++name;
+ }
+ else
+ {
+ if (*name++ != c)
+ return(0);
+ }
break;
}
}