public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: is_unicode_equiv: fix normalization
Date: Sat, 18 Feb 2023 22:14:56 +0000 (GMT)	[thread overview]
Message-ID: <20230218221456.DFB043858D32@sourceware.org> (raw)

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

commit f0417a620182083fa787eea90e2e1d9884c8e573
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Sat Feb 18 23:14:11 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Sat Feb 18 23:14:11 2023 +0100

    Cygwin: is_unicode_equiv: fix normalization
    
    Change normalization to form KD and make room for longer
    decomposed sequences.

Diff:
---
 winsup/cygwin/nlsfuncs.cc | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/nlsfuncs.cc b/winsup/cygwin/nlsfuncs.cc
index aa7e8434d7cf..d80567737d7b 100644
--- a/winsup/cygwin/nlsfuncs.cc
+++ b/winsup/cygwin/nlsfuncs.cc
@@ -1200,14 +1200,14 @@ __collate_range_cmp (int c1, int c2)
    Note that we only recognize input in Unicode normalization form C, that
    is, we expect all letters to be composed.  A single character is all we
    look at.
-   To check equivalence, decompose pattern letter and input letter and check
-   the base character for equality.  Also, convert all digits to the ASCII
-   digits 0 - 9 and compare. */
+   To check equivalence, decompose pattern letter and input letter into
+   normalization form KD and check the base character for equality.  Also,
+   convert all digits to the ASCII digits 0 - 9 and compare. */
 extern "C" int
 is_unicode_equiv (wint_t test, wint_t eqv)
 {
-	wchar_t decomp_testc[5] = { 0 };
-	wchar_t decomp_eqvc[5] = { 0 };
+	wchar_t decomp_testc[24] = { 0 };
+	wchar_t decomp_eqvc[24] = { 0 };
 	wchar_t testc[3] = { 0 };
 	wchar_t eqvc[3] = { 0 };
 
@@ -1229,8 +1229,10 @@ is_unicode_equiv (wint_t test, wint_t eqv)
 	} else
 		testc[0] = test;
 	/* Convert to denormalized form */
-	FoldStringW (MAP_COMPOSITE | MAP_FOLDDIGITS, eqvc, -1, decomp_eqvc, 5);
-	FoldStringW (MAP_COMPOSITE | MAP_FOLDDIGITS, testc, -1, decomp_testc, 5);
+	FoldStringW (MAP_COMPOSITE | MAP_FOLDCZONE | MAP_FOLDDIGITS,
+		     eqvc, -1, decomp_eqvc, 24);
+	FoldStringW (MAP_COMPOSITE | MAP_FOLDCZONE | MAP_FOLDDIGITS,
+		     testc, -1, decomp_testc, 24);
 	/* If they are equivalent, the base char must be the same. */
 	if (decomp_eqvc[0] != decomp_testc[0])
 		return 0;

                 reply	other threads:[~2023-02-18 22:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230218221456.DFB043858D32@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).