From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id D44C23858D33; Tue, 14 Feb 2023 19:29:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D44C23858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676402962; bh=kQgVmlXBrcnK6wffRRf2GgPmEHMKwZaMGucaAg/mAjg=; h=From:To:Subject:Date:From; b=LluPHx64sA8JDOR52mBh3XPDP8NKg9bezFTKJ7dldJZ4bv6/DPpRVmLw96/36/845 sO9TTVPOwoQrL9R2msVeZolXUbyb18Y+ZZoHdm2JhVYd3dWKsNJ4lI8j/cxZY1J6Rh uSCdLZ+pg3W0pWF1PyzguH9q6gAdcsaWnSGMyxJk= 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: fnmatch: handle named character classes X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 1fc35f30bdc67592150592ea78f808d44c913faf X-Git-Newrev: 7faa6465531637d76e3c0733a4d2608bf7b3a54a Message-Id: <20230214192922.D44C23858D33@sourceware.org> Date: Tue, 14 Feb 2023 19:29:22 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D7faa6465531= 637d76e3c0733a4d2608bf7b3a54a commit 7faa6465531637d76e3c0733a4d2608bf7b3a54a Author: Corinna Vinschen AuthorDate: Tue Feb 14 20:22:54 2023 +0100 Commit: Corinna Vinschen CommitDate: Tue Feb 14 20:22:54 2023 +0100 Cygwin: fnmatch: handle named character classes =20 Handle [::] expressions in range brackets. =20 TODO: Collating symbols [.'.] and Equivalence class expressions [=3D=3D] are recognized but skipped as if they are not present at all. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/libc/fnmatch.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c index 06732426b9c4..9829904f0812 100644 --- a/winsup/cygwin/libc/fnmatch.c +++ b/winsup/cygwin/libc/fnmatch.c @@ -274,6 +274,29 @@ rangematch(const char *pattern, wint_t test, int flags= , char **newp, return (RANGE_NOMATCH); } else if (*pattern =3D=3D '\\' && !(flags & FNM_NOESCAPE)) pattern++; + if (*pattern =3D=3D '[' && (pattern[1] =3D=3D ':' || pattern[1] =3D=3D '= .' + || pattern[1] =3D=3D '=3D')) { + const char ctype =3D *++pattern; + const char *class_p =3D ++pattern; + + while (*pattern + && (*pattern !=3D ctype || pattern[1] !=3D ']')) + ++pattern; + if (!*pattern) + return (RANGE_ERROR); + if (ctype =3D=3D ':') { + size_t clen =3D pattern - class_p; + char class[clen + 1]; + + *stpncpy (class, class_p, clen) =3D '\0'; + if (iswctype (test, wctype (class))) + ok =3D 1; + } + pattern +=3D 2; + /* TODO: [. and [=3D are just ignored for now */ + continue; + + } pclen =3D mbrtowi(&c, pattern, MB_LEN_MAX, patmbs); if (pclen =3D=3D (size_t)-1 || pclen =3D=3D (size_t)-2) return (RANGE_NOMATCH);