* 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.
This commit is contained in:
Christopher Faylor
2000-11-11 05:36:34 +00:00
parent 466ebd61d3
commit 6ccb6bcf3d
4 changed files with 75 additions and 10 deletions

View File

@@ -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;
}
}