* 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

@ -1,3 +1,12 @@
Fri Nov 10 13:48:44 2000 Bradley A. Town <townba@pobox.com>
* 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.
Thu Nov 9 14:30:00 2000 Corinna Vinschen <corinna@vinschen.de> Thu Nov 9 14:30:00 2000 Corinna Vinschen <corinna@vinschen.de>
* dir.cc (readdir): Avoid reading from the beginning when * dir.cc (readdir): Avoid reading from the beginning when

View File

@ -106,6 +106,7 @@ extern "C"
/* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf, /* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf,
/* impure_ptr */ &reent_data, /* impure_ptr */ &reent_data,
}; };
BOOL ignore_case_with_glob = FALSE;
}; };
char *old_title = NULL; char *old_title = NULL;
@ -835,6 +836,9 @@ dll_crt0_1 ()
return; return;
} }
/* Disable case-insensitive globbing */
ignore_case_with_glob = FALSE;
/* Flush signals and ensure that signal thread is up and running. Can't /* Flush signals and ensure that signal thread is up and running. Can't
do this for noncygwin case since the signal thread is blocked due to do this for noncygwin case since the signal thread is blocked due to
LoadLibrary serialization. */ LoadLibrary serialization. */

View File

@ -27,6 +27,7 @@ details. */
#include "perprocess.h" #include "perprocess.h"
extern BOOL allow_glob; extern BOOL allow_glob;
extern BOOL ignore_case_with_glob;
extern BOOL allow_ntea; extern BOOL allow_ntea;
extern BOOL strip_title_path; extern BOOL strip_title_path;
extern DWORD chunksize; extern DWORD chunksize;
@ -380,6 +381,31 @@ enum settings
set_process_state, set_process_state,
}; };
/* When BUF is:
* null or empty: disables globbing
* "ignorecase": enables case-insensitive globbing
* anything else: enables case-sensitive globbing
*/
static void
glob_init (const char *buf)
{
if (!buf || !*buf)
{
allow_glob = FALSE;
ignore_case_with_glob = FALSE;
}
else if (strncasematch (buf, "ignorecase", 10))
{
allow_glob = TRUE;
ignore_case_with_glob = TRUE;
}
else
{
allow_glob = TRUE;
ignore_case_with_glob = FALSE;
}
}
/* The structure below is used to set up an array which is used to /* The structure below is used to set up an array which is used to
* parse the CYGWIN environment variable or, if enabled, options from * parse the CYGWIN environment variable or, if enabled, options from
* the registry. * the registry.
@ -409,7 +435,7 @@ struct parse_thing
{"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}}, {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, {0}}},
{"export", {&export_settings}, justset, NULL, {{FALSE}, {TRUE}}}, {"export", {&export_settings}, justset, NULL, {{FALSE}, {TRUE}}},
{"forkchunk", {x: &chunksize}, justset, NULL, {{8192}, {0}}}, {"forkchunk", {x: &chunksize}, justset, NULL, {{8192}, {0}}},
{"glob", {&allow_glob}, justset, NULL, {{FALSE}, {TRUE}}}, {"glob", {func: &glob_init}, isfunc, NULL, {{0}, {s: "normal"}}},
{"ntea", {&allow_ntea}, justset, NULL, {{FALSE}, {TRUE}}}, {"ntea", {&allow_ntea}, justset, NULL, {{FALSE}, {TRUE}}},
{"ntsec", {&allow_ntsec}, justset, NULL, {{FALSE}, {TRUE}}}, {"ntsec", {&allow_ntsec}, justset, NULL, {{FALSE}, {TRUE}}},
{"reset_com", {&reset_com}, justset, NULL, {{FALSE}, {TRUE}}}, {"reset_com", {&reset_com}, justset, NULL, {{FALSE}, {TRUE}}},

View File

@ -72,6 +72,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <glob.h> #include <glob.h>
@ -81,6 +82,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <windows.h>
#ifdef __weak_alias #ifdef __weak_alias
#ifdef __LIBC12_SOURCE__ #ifdef __LIBC12_SOURCE__
@ -174,6 +176,8 @@ static void qprintf __P((const char *, Char *));
#undef MAXPATHLEN #undef MAXPATHLEN
#define MAXPATHLEN 16384 #define MAXPATHLEN 16384
extern BOOL ignore_case_with_glob;
int int
glob(pattern, flags, errfunc, pglob) glob(pattern, flags, errfunc, pglob)
const char *pattern; const char *pattern;
@ -727,6 +731,18 @@ match(name, pat, patend)
return(0); return(0);
if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
++pat; ++pat;
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) while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) { if ((*pat & M_MASK) == M_RNG) {
if (c <= k && k <= pat[1]) if (c <= k && k <= pat[1])
@ -734,12 +750,22 @@ match(name, pat, patend)
pat += 2; pat += 2;
} else if (c == k) } else if (c == k)
ok = 1; ok = 1;
}
if (ok == negate_range) if (ok == negate_range)
return(0); return(0);
break; break;
default: default:
if (ignore_case_with_glob)
{
if (tolower(*name) != tolower(c))
return(0);
++name;
}
else
{
if (*name++ != c) if (*name++ != c)
return(0); return(0);
}
break; break;
} }
} }