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

commit 20162667de8c0029c974420230f2dcc903159e66
Author:     Corinna Vinschen <[email protected]>
AuthorDate: Wed Feb 15 22:31:49 2023 +0100
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Wed Feb 15 22:31:49 2023 +0100

    Cygwin: fnmatch: handle equivalence class expressions
    
    Handle [=x=] expressions in range brackets.  Use the new
    is_unicode_equiv() function to perform the check.
    
    Signed-off-by: Corinna Vinschen <[email protected]>

Diff:
---
 winsup/cygwin/libc/fnmatch.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c
index 9829904f0812..40c1f2d59859 100644
--- a/winsup/cygwin/libc/fnmatch.c
+++ b/winsup/cygwin/libc/fnmatch.c
@@ -284,16 +284,25 @@ rangematch(const char *pattern, wint_t test, int flags, 
char **newp,
                                ++pattern;
                        if (!*pattern)
                                return (RANGE_ERROR);
-                       if (ctype == ':') {
+                       if (ctype == ':') { /* named character class */
                                size_t clen = pattern - class_p;
                                char class[clen + 1];
 
                                *stpncpy (class, class_p, clen) = '\0';
                                if (iswctype (test, wctype (class)))
                                        ok = 1;
+                       } else if (ctype == '=') { /* equivalence class */
+                               size_t elen = pattern - class_p;
+                               char equiv[elen + 1];
+                               wint_t eqv;
+
+                               *stpncpy (equiv, class_p, elen) = '\0';
+                               if (mbrtowi(&eqv, equiv, elen, patmbs) == elen
+                                   && is_unicode_equiv (test, eqv))
+                                       ok = 1;
                        }
+                       /* TODO: [. is just ignored for now */
                        pattern += 2;
-                       /* TODO: [. and [= are just ignored for now */
                        continue;
 
                }

Reply via email to