https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2229f42400b992669a99cba9b42b600b0ba01b7f
commit 2229f42400b992669a99cba9b42b600b0ba01b7f Author: Corinna Vinschen <[email protected]> AuthorDate: Wed Feb 22 12:20:32 2023 +0100 Commit: Corinna Vinschen <[email protected]> CommitDate: Wed Feb 22 12:20:32 2023 +0100 Cygwin: __wscollate_range_cmp: workaround wcscoll's case-insensitivity Most locales using latin characters ignore case while sorting. This is what wcscoll does (correctly so). However, there's an internal order of collating sequences compared to the base character, which is case-sensitive, at least in GLibc. There's no way to express this in Windows, because CompareString and LCMapString *always* use case-insensitivity in those locales, even if none of the *IGNORECASE sorting flags are used. We want to follow glibc's behaviour more closely, so we add an extra check for the case and make sure upper and lower cased letters don't comapre as identical. Signed-off-by: Corinna Vinschen <[email protected]> Diff: --- winsup/cygwin/nlsfuncs.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc index eb9948dd37fc..543f20e4437b 100644 --- a/winsup/cygwin/nlsfuncs.cc +++ b/winsup/cygwin/nlsfuncs.cc @@ -1206,6 +1206,12 @@ __wscollate_range_cmp (wint_t *c1, wint_t *c2, wchar_t s1[c1len * 2 + 1] = { 0 }; /* # of chars if all are surrogates */ wchar_t s2[c2len * 2 + 1] = { 0 }; + /* wcscoll() ignores case in many locales. but we don't want that + for filenames... */ + if ((iswupper (*c1) && !iswupper (*c2)) + || (iswlower (*c1) && !iswlower (*c2))) + return *c1 - *c2; + wcintowcs (s1, c1, c1len); wcintowcs (s2, c2, c2len); return wcscoll_l (s1, s2, __get_current_locale ());
