Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: From: "Town, Brad" To: "'cygwin AT sources DOT redhat DOT com'" Subject: RE: Case-insensitive globbing (was RE: Cygnus question) Date: Thu, 9 Nov 2000 11:09:16 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C04A67.68C5BC10" ------_=_NextPart_000_01C04A67.68C5BC10 Content-Type: text/plain > The problem is that the glob() function is exported from the > DLL. I don't > know if its operation should be under the control of the > CYGWIN environment > variable when it is called by the program directly. I don't > think it should > be actually. I agree. I've made the change and attached new patches. > I'd appreciate it if you would test that glob's operation > when called from > a program is unchanged, too. Source to the program I used to test is attached. So, for those of you just joining us, adding "glob" to the CYGWIN environment variable enables case-sensitive globbing for arguments passed on the command line when the program is called from a Windows shell. With the patches, "glob:ignorecase" would make the globbing case-insensitive. Brad Town ------_=_NextPart_000_01C04A67.68C5BC10 Content-Type: application/octet-stream; name="dcrt0.cc.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="dcrt0.cc.patch" --- dcrt0.cc.orig Wed Nov 8 10:15:22 2000=0A= +++ dcrt0.cc Thu Nov 9 10:44:01 2000=0A= @@ -106,6 +106,7 @@=0A= /* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf,=0A= /* impure_ptr */ &reent_data,=0A= };=0A= + BOOL ignore_case_with_glob =3D FALSE;=0A= };=0A= =0A= char *old_title =3D NULL;=0A= @@ -488,6 +489,9 @@=0A= }=0A= =0A= argv[argc] =3D NULL;=0A= +=0A= + /* Disable case-insensitive globbing */=0A= + ignore_case_with_glob =3D FALSE;=0A= =0A= debug_printf ("argc %d", argc);=0A= }=0A= ------_=_NextPart_000_01C04A67.68C5BC10 Content-Type: application/octet-stream; name="environ.cc.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="environ.cc.patch" --- environ.cc.orig Thu Nov 9 09:04:53 2000=0A= +++ environ.cc Thu Nov 9 10:16:41 2000=0A= @@ -27,6 +27,7 @@=0A= #include "perprocess.h"=0A= =0A= extern BOOL allow_glob;=0A= +extern BOOL ignore_case_with_glob;=0A= extern BOOL allow_ntea;=0A= extern BOOL strip_title_path;=0A= extern DWORD chunksize;=0A= @@ -380,6 +381,31 @@=0A= set_process_state,=0A= };=0A= =0A= +/* When BUF is:=0A= + * null or empty: disables globbing=0A= + * "ignorecase": enables case-insensitive globbing=0A= + * anything else: enables case-sensitive globbing=0A= + */=0A= +static void=0A= +glob_init (const char *buf)=0A= +{=0A= + if (!buf || !*buf)=0A= + {=0A= + allow_glob =3D FALSE;=0A= + ignore_case_with_glob =3D FALSE;=0A= + }=0A= + else if (strncasematch (buf, "ignorecase", 10))=0A= + {=0A= + allow_glob =3D TRUE;=0A= + ignore_case_with_glob =3D TRUE;=0A= + }=0A= + else=0A= + {=0A= + allow_glob =3D TRUE;=0A= + ignore_case_with_glob =3D FALSE;=0A= + }=0A= +}=0A= +=0A= /* The structure below is used to set up an array which is used to=0A= * parse the CYGWIN environment variable or, if enabled, options = from=0A= * the registry.=0A= @@ -409,7 +435,7 @@=0A= {"error_start", {func: &error_start_init}, isfunc, NULL, {{0}, = {0}}},=0A= {"export", {&export_settings}, justset, NULL, {{FALSE}, {TRUE}}},=0A= {"forkchunk", {x: &chunksize}, justset, NULL, {{8192}, {0}}},=0A= - {"glob", {&allow_glob}, justset, NULL, {{FALSE}, {TRUE}}},=0A= + {"glob", {func: &glob_init}, isfunc, NULL, {{0}, {s: "normal"}}},=0A= {"ntea", {&allow_ntea}, justset, NULL, {{FALSE}, {TRUE}}},=0A= {"ntsec", {&allow_ntsec}, justset, NULL, {{FALSE}, {TRUE}}},=0A= {"reset_com", {&reset_com}, justset, NULL, {{FALSE}, {TRUE}}},=0A= ------_=_NextPart_000_01C04A67.68C5BC10 Content-Type: application/octet-stream; name="glob.c.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="glob.c.patch" --- glob.c.orig Mon Nov 6 10:02:50 2000=0A= +++ glob.c Thu Nov 9 10:03:56 2000=0A= @@ -72,6 +72,7 @@=0A= #include =0A= #include =0A= =0A= +#include =0A= #include =0A= #include =0A= #include =0A= @@ -81,6 +82,7 @@=0A= #include =0A= #include =0A= #include =0A= +#include =0A= =0A= #ifdef __weak_alias=0A= #ifdef __LIBC12_SOURCE__=0A= @@ -174,6 +176,8 @@=0A= #undef MAXPATHLEN=0A= #define MAXPATHLEN 16384=0A= =0A= +extern BOOL ignore_case_with_glob;=0A= +=0A= int=0A= glob(pattern, flags, errfunc, pglob)=0A= const char *pattern;=0A= @@ -727,19 +731,41 @@=0A= return(0);=0A= if ((negate_range =3D ((*pat & M_MASK) =3D=3D M_NOT)) !=3D EOS)=0A= ++pat;=0A= - while (((c =3D *pat++) & M_MASK) !=3D M_END)=0A= - if ((*pat & M_MASK) =3D=3D M_RNG) {=0A= - if (c <=3D k && k <=3D pat[1])=0A= - ok =3D 1;=0A= - pat +=3D 2;=0A= - } else if (c =3D=3D k)=0A= - ok =3D 1;=0A= + if (ignore_case_with_glob)=0A= + {=0A= + while (((c =3D *pat++) & M_MASK) !=3D M_END)=0A= + if ((*pat & M_MASK) =3D=3D M_RNG) {=0A= + if (tolower(c) <=3D tolower(k) && tolower(k) <=3D = tolower(pat[1]))=0A= + ok =3D 1;=0A= + pat +=3D 2;=0A= + } else if (tolower(c) =3D=3D tolower(k))=0A= + ok =3D 1;=0A= + }=0A= + else=0A= + {=0A= + while (((c =3D *pat++) & M_MASK) !=3D M_END)=0A= + if ((*pat & M_MASK) =3D=3D M_RNG) {=0A= + if (c <=3D k && k <=3D pat[1])=0A= + ok =3D 1;=0A= + pat +=3D 2;=0A= + } else if (c =3D=3D k)=0A= + ok =3D 1;=0A= + }=0A= if (ok =3D=3D negate_range)=0A= return(0);=0A= break;=0A= default:=0A= - if (*name++ !=3D c)=0A= - return(0);=0A= + if (ignore_case_with_glob)=0A= + {=0A= + if (tolower(*name) !=3D tolower(c))=0A= + return(0);=0A= + ++name;=0A= + }=0A= + else=0A= + {=0A= + if (*name++ !=3D c)=0A= + return(0);=0A= + }=0A= break;=0A= }=0A= }=0A= ------_=_NextPart_000_01C04A67.68C5BC10 Content-Type: application/octet-stream; name="globtest.cc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="globtest.cc" #include =0A= #include =0A= #include =0A= =0A= int main(int argc, char * argv[])=0A= {=0A= for (int i =3D 0; i !=3D argc; ++i)=0A= std::cout << "argv[" << i << "] =3D '" << argv[i] << "'\n";=0A= =0A= {=0A= glob_t gl =3D {0};=0A= if (glob("g*", GLOB_TILDE|GLOB_NOCHECK|GLOB_BRACE|GLOB_QUOTE, 0, &gl) = || !gl.gl_pathc)=0A= std::cerr << "glob 1 failed.\n";=0A= else {=0A= std::cout << "gl.gl_pathc =3D " << gl.gl_pathc << '\n';=0A= std::cout << "gl.gl_pathv[0] =3D '" << gl.gl_pathv[0] << "'\n";=0A= }=0A= =0A= free(gl.gl_pathv);=0A= }=0A= =0A= {=0A= glob_t gl =3D {0};=0A= if (glob("G*", GLOB_TILDE|GLOB_NOCHECK|GLOB_BRACE|GLOB_QUOTE, 0, &gl) = || !gl.gl_pathc)=0A= std::cerr << "glob 2 failed.\n";=0A= else {=0A= std::cout << "gl.gl_pathc =3D " << gl.gl_pathc << '\n';=0A= std::cout << "gl.gl_pathv[0] =3D '" << gl.gl_pathv[0] << "'\n";=0A= }=0A= =0A= free(gl.gl_pathv);=0A= }=0A= =0A= return 0;=0A= }=0A= ------_=_NextPart_000_01C04A67.68C5BC10 Content-Type: text/plain; charset=us-ascii -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com ------_=_NextPart_000_01C04A67.68C5BC10--