From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id B4AE93858438; Wed, 22 Feb 2023 11:21:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4AE93858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677064879; bh=BH26zBMAeoPZsKWP2Uws4CBZxL/6rA50ntEp2yhT/+Q=; h=From:To:Subject:Date:From; b=beek33/NiipEvvrbOa9ou5R4HctpcD+Q8VpyHEBcBWq5atY6urQeyvS8uLr1GYOb0 Z7CoZtBHuRcaV9spQ/jPd6KrLfSEtzpWz9mTed+KPsP4mC79TBwsSElLF8a8Y7bMNu nyPAhO7pvlBXp8sMP2unhRI8HxKBs7wcUsRKAhNI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: glob: perform ignore_case_with_glob on input X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: f3f20038c480e43ae264b760f4d8b14b618ca973 X-Git-Newrev: a51147467e6cf58618433286f93d17043e00b0fc Message-Id: <20230222112119.B4AE93858438@sourceware.org> Date: Wed, 22 Feb 2023 11:21:19 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Da51147467e6= cf58618433286f93d17043e00b0fc commit a51147467e6cf58618433286f93d17043e00b0fc Author: Corinna Vinschen AuthorDate: Wed Feb 22 10:47:54 2023 +0100 Commit: Corinna Vinschen CommitDate: Wed Feb 22 10:47:54 2023 +0100 Cygwin: glob: perform ignore_case_with_glob on input =20 Rather than converting single chars on the fly to lowercase in case ignore_case_with_glob is set, perform the conversion on the entire input (pattern and filenames). Diff: --- winsup/cygwin/glob.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc index 2f86e46985d7..64c3507d891e 100644 --- a/winsup/cygwin/glob.cc +++ b/winsup/cygwin/glob.cc @@ -95,8 +95,9 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/0= 5/12 17:44:00 gordon Ex #include "collate.h" =20 #ifdef __CYGWIN__ -#define CCHAR(c) (ignore_case_with_glob ? towlower (CHAR (c)) : CHAR (c)) #define Cchar(c) (ignore_case_with_glob ? towlower (c) : (c)) +#else +#define Cchar(c) (c) #endif =20 #undef MAXPATHLEN @@ -122,6 +123,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010= /05/12 17:44:00 gordon Ex #define SLASH '/' #define COMMA ',' =20 +#undef DEBUG /* never define */ #ifndef DEBUG =20 #define M_QUOTE 0x40000000U @@ -252,7 +254,7 @@ glob(const char *__restrict pattern, int flags, int (*e= rrfunc)(const char *, int return (GLOB_NOMATCH); else if (clen =3D=3D 0) break; - *bufnext++ =3D wc; + *bufnext++ =3D Cchar(wc); patnext +=3D clen; } } else { @@ -272,7 +274,7 @@ glob(const char *__restrict pattern, int flags, int (*e= rrfunc)(const char *, int return (GLOB_NOMATCH); else if (clen =3D=3D 0) break; - *bufnext++ =3D wc | prot; + *bufnext++ =3D Cchar(wc) | prot; patnext +=3D clen; } } @@ -779,6 +781,19 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last, break; sc +=3D clen; } +#ifdef __CYGWIN__ + if (ignore_case_with_glob) { + wint_t lower_path[MAXPATHLEN]; + wint_t *lp =3D lower_path, *sp =3D pathend; + + while ((*lp++ =3D towlower(*sp++))) + ; + if (!match(lower_path, pattern, restpattern)) { + *pathend =3D EOS; + continue; + } + } else +#endif if (!match(pathend, pattern, restpattern)) { *pathend =3D EOS; continue; @@ -932,7 +947,7 @@ match(Char *name, Char *pat, Char *patend) return(0); break; default: - if (Cchar(*name++) !=3D Cchar(*c)) + if (*name++ !=3D *c) return(0); break; }