public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_5-branch] Revert "Cygwin: glob: perform ignore_case_with_glob on input"
@ 2024-03-18 10:26 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2024-03-18 10:26 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=70375b2205ba7cf5eddf4180b3d80ac8264c0e0a

commit 70375b2205ba7cf5eddf4180b3d80ac8264c0e0a
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Mon Mar 18 10:50:30 2024 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Mon Mar 18 11:10:20 2024 +0100

    Revert "Cygwin: glob: perform ignore_case_with_glob on input"
    
    This reverts commit a51147467e6cf58618433286f93d17043e00b0fc.
    
    Dumb thinko on my part.  What was supposed to be an optimization
    actually broke caseinsensitive globbing in that the entire input
    of globbed expressions were downcased.
    
    Drop the unused CCHAR() macro nevertheless.
    
    Fixes: a51147467e6cf ("Cygwin: glob: perform ignore_case_with_glob on input")
    Reported-by: Michael Goldshteyn <mgold10000@gmail.com>
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/glob.cc       | 22 +++-------------------
 winsup/cygwin/release/3.5.2 |  4 ++++
 2 files changed, 7 insertions(+), 19 deletions(-)

diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc
index 4730d09f5590..90ec473aea55 100644
--- a/winsup/cygwin/glob.cc
+++ b/winsup/cygwin/glob.cc
@@ -96,8 +96,6 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/05/12 17:44:00 gordon Ex
 
 #ifdef __CYGWIN__
 #define Cchar(c)	(ignore_case_with_glob ? towlower (c) : (c))
-#else
-#define Cchar(c)	(c)
 #endif
 
 #undef MAXPATHLEN
@@ -123,7 +121,6 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/05/12 17:44:00 gordon Ex
 #define	SLASH		'/'
 #define	COMMA		','
 
-#undef DEBUG /* never define */
 #ifndef DEBUG
 
 #define	M_QUOTE		0x40000000U
@@ -251,7 +248,7 @@ glob(const char *__restrict pattern, int flags, int (*errfunc)(const char *, int
 				return (GLOB_NOMATCH);
 			else if (clen == 0)
 				break;
-			*bufnext++ = Cchar(wc);
+			*bufnext++ = wc;
 			patnext += clen;
 		}
 	} else {
@@ -271,7 +268,7 @@ glob(const char *__restrict pattern, int flags, int (*errfunc)(const char *, int
 				return (GLOB_NOMATCH);
 			else if (clen == 0)
 				break;
-			*bufnext++ = Cchar(wc) | prot;
+			*bufnext++ = wc | prot;
 			patnext += clen;
 		}
 	}
@@ -772,19 +769,6 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
 				break;
 			sc += clen;
 		}
-#ifdef __CYGWIN__
-		if (ignore_case_with_glob) {
-			wint_t lower_path[MAXPATHLEN];
-			wint_t *lp = lower_path, *sp = pathend;
-
-			while ((*lp++ = towlower(*sp++)))
-				;
-			if (!match(lower_path, pattern, restpattern)) {
-				*pathend = EOS;
-				continue;
-			}
-		} else
-#endif
 		if (!match(pathend, pattern, restpattern)) {
 			*pathend = EOS;
 			continue;
@@ -938,7 +922,7 @@ match(Char *name, Char *pat, Char *patend)
 				return(0);
 			break;
 		default:
-			if (*name++ != *c)
+			if (Cchar(*name++) != Cchar(*c))
 				return(0);
 			break;
 		}
diff --git a/winsup/cygwin/release/3.5.2 b/winsup/cygwin/release/3.5.2
index 449047d9c276..32137c2e6807 100644
--- a/winsup/cygwin/release/3.5.2
+++ b/winsup/cygwin/release/3.5.2
@@ -20,3 +20,7 @@ Fixes:
 
 - Don't skip inadvertently some local SAM accounts on domain member
   machines.
+
+- Revert ill-advised optimization of glob(3) in case of caseinsensitive
+  globbing.
+  Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255675.html

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-18 10:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18 10:26 [newlib-cygwin/cygwin-3_5-branch] Revert "Cygwin: glob: perform ignore_case_with_glob on input" Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).