From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id BCF5D385840F; Wed, 22 Feb 2023 11:21:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCF5D385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677064884; bh=geS2A7TYES1K95rwbLswrdZtnc03HfMdJ3r1PkI8+KI=; h=From:To:Subject:Date:From; b=SeT3ljbzO1/iIHaUIGDnSBsbpti1RfGf4bl4AeYzXUuFub9knzRp2xy/Ww9XaYaxG LnRZ0XG8/NMYYu4EnklljEseZ4fnOMCV/Y18699zFhs7rDChaWNd7lWrRC1cN0xDLB PQvVEa6NsBE7+IPVEW/52waEuzLg8PoSDbJS8CNQ= 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: __wscollate_range_cmp: workaround wcscoll's case-insensitivity X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: a51147467e6cf58618433286f93d17043e00b0fc X-Git-Newrev: 2229f42400b992669a99cba9b42b600b0ba01b7f Message-Id: <20230222112124.BCF5D385840F@sourceware.org> Date: Wed, 22 Feb 2023 11:21:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D2229f42400b= 992669a99cba9b42b600b0ba01b7f commit 2229f42400b992669a99cba9b42b600b0ba01b7f Author: Corinna Vinschen AuthorDate: Wed Feb 22 12:20:32 2023 +0100 Commit: Corinna Vinschen CommitDate: Wed Feb 22 12:20:32 2023 +0100 Cygwin: __wscollate_range_cmp: workaround wcscoll's case-insensitivity =20 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. =20 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. =20 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. =20 Signed-off-by: Corinna Vinschen 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] =3D { 0 }; /* # of chars if all are surrogates= */ wchar_t s2[c2len * 2 + 1] =3D { 0 }; =20 + /* 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 ());