public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: __wscollate_range_cmp: workaround wcscoll's case-insensitivity
@ 2023-02-22 11:21 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-02-22 11:21 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2229f42400b992669a99cba9b42b600b0ba01b7f
commit 2229f42400b992669a99cba9b42b600b0ba01b7f
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Feb 22 12:20:32 2023 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
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 <corinna@vinschen.de>
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 ());
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-22 11:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 11:21 [newlib-cygwin/main] Cygwin: __wscollate_range_cmp: workaround wcscoll's case-insensitivity 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).