From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id C58B93858C30; Tue, 14 Feb 2023 12:10:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C58B93858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676376603; bh=6E/fMqb2kPcatZ/dcv5CiFk02Vf168/sKnDbon6Vm9g=; h=From:To:Subject:Date:From; b=hBQwlx2hTMTAUdsXHcKH/vf7UWM1rzy+yJa6uIfotynMRumPsc3CWLaU7IczcPXOJ nh4UKkGT/azRle5N44ELSWHH6et5Jy04wQS2II+Zr2d4ICfdB2agTHGDMaE5mfuWh6 8vjD8anrEggSmu4/GXkw4ueSh9ibQ/m1UOcd3wC4= 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: convert wchar_t to wint_t X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: eac830e0feac1e5f4fbb9637506bd071e7530a1f X-Git-Newrev: 99da4956c5976770c1c1ce3d284c60c0cb5f1b57 Message-Id: <20230214121003.C58B93858C30@sourceware.org> Date: Tue, 14 Feb 2023 12:10:03 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D99da4956c59= 76770c1c1ce3d284c60c0cb5f1b57 commit 99da4956c5976770c1c1ce3d284c60c0cb5f1b57 Author: Corinna Vinschen AuthorDate: Tue Feb 14 12:47:54 2023 +0100 Commit: Corinna Vinschen CommitDate: Tue Feb 14 12:48:31 2023 +0100 Cygwin: fnmatch: convert wchar_t to wint_t =20 ...thus handling all Unicode values sanely. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/libc/fnmatch.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c index 410254ab86f8..06732426b9c4 100644 --- a/winsup/cygwin/libc/fnmatch.c +++ b/winsup/cygwin/libc/fnmatch.c @@ -52,7 +52,7 @@ __FBSDID("$FreeBSD: head/lib/libc/gen/fnmatch.c 288309 20= 15-09-27 12:52:18Z jill * 1. Patterns with illegal byte sequences match nothing. * 2. Illegal byte sequences in the "string" argument are handled by treat= ing * them as single-byte characters with a value of the first byte of the - * sequence cast to wchar_t. + * sequence cast to wint_t. * 3. Multibyte conversion state objects (mbstate_t) are passed around and * used for most, but not all, conversions. Further work will be requir= ed * to support state-dependent encodings. @@ -72,7 +72,7 @@ __FBSDID("$FreeBSD: head/lib/libc/gen/fnmatch.c 288309 20= 15-09-27 12:52:18Z jill #define RANGE_NOMATCH 0 #define RANGE_ERROR (-1) =20 -static int rangematch(const char *, wchar_t, int, char **, mbstate_t *); +static int rangematch(const char *, wint_t, int, char **, mbstate_t *); static int fnmatch1(const char *, const char *, const char *, int, mbstate= _t, mbstate_t); =20 @@ -92,16 +92,16 @@ fnmatch1(const char *pattern, const char *string, const= char *stringstart, mbstate_t bt_patmbs, bt_strmbs; char *newp; char c; - wchar_t pc, sc; + wint_t pc, sc; size_t pclen, sclen; =20 bt_pattern =3D bt_string =3D NULL; for (;;) { - pclen =3D mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); + pclen =3D mbrtowi(&pc, pattern, MB_LEN_MAX, &patmbs); if (pclen =3D=3D (size_t)-1 || pclen =3D=3D (size_t)-2) return (FNM_NOMATCH); pattern +=3D pclen; - sclen =3D mbrtowc(&sc, string, MB_LEN_MAX, &strmbs); + sclen =3D mbrtowi(&sc, string, MB_LEN_MAX, &strmbs); if (sclen =3D=3D (size_t)-1 || sclen =3D=3D (size_t)-2) { sc =3D (unsigned char)*string; sclen =3D 1; @@ -183,7 +183,7 @@ fnmatch1(const char *pattern, const char *string, const= char *stringstart, break; case '\\': if (!(flags & FNM_NOESCAPE)) { - pclen =3D mbrtowc(&pc, pattern, MB_LEN_MAX, + pclen =3D mbrtowi(&pc, pattern, MB_LEN_MAX, &patmbs); if (pclen =3D=3D (size_t)-1 || pclen =3D=3D (size_t)-2) return (FNM_NOMATCH); @@ -208,7 +208,7 @@ fnmatch1(const char *pattern, const char *string, const= char *stringstart, */ if (bt_pattern =3D=3D NULL) return (FNM_NOMATCH); - sclen =3D mbrtowc(&sc, bt_string, MB_LEN_MAX, + sclen =3D mbrtowi(&sc, bt_string, MB_LEN_MAX, &bt_strmbs); if (sclen =3D=3D (size_t)-1 || sclen =3D=3D (size_t)-2) { @@ -232,11 +232,11 @@ fnmatch1(const char *pattern, const char *string, con= st char *stringstart, } =20 static int -rangematch(const char *pattern, wchar_t test, int flags, char **newp, +rangematch(const char *pattern, wint_t test, int flags, char **newp, mbstate_t *patmbs) { int negate, ok; - wchar_t c, c2; + wint_t c, c2; size_t pclen; const char *origpat; #ifndef __CYGWIN__ @@ -274,7 +274,7 @@ rangematch(const char *pattern, wchar_t test, int flags= , char **newp, return (RANGE_NOMATCH); } else if (*pattern =3D=3D '\\' && !(flags & FNM_NOESCAPE)) pattern++; - pclen =3D mbrtowc(&c, pattern, MB_LEN_MAX, patmbs); + 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); pattern +=3D pclen; @@ -287,7 +287,7 @@ rangematch(const char *pattern, wchar_t test, int flags= , char **newp, if (*++pattern =3D=3D '\\' && !(flags & FNM_NOESCAPE)) if (*pattern !=3D EOS) pattern++; - pclen =3D mbrtowc(&c2, pattern, MB_LEN_MAX, patmbs); + pclen =3D mbrtowi(&c2, pattern, MB_LEN_MAX, patmbs); if (pclen =3D=3D (size_t)-1 || pclen =3D=3D (size_t)-2) return (RANGE_NOMATCH); pattern +=3D pclen;