From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id D5C5B3858D37; Fri, 3 Mar 2023 17:20:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5C5B3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677864029; bh=BqNi8rU01RZKhrDjChSw46TQ0GH/iFJhjag6i3YgE1g=; h=From:To:Subject:Date:From; b=dMpRgeJMPWleDTXzInWYgmHoL4/XgdclNNMbecSjxdE3fokG4O6Vc7Yyuow1OhQ+q sgxJwN8SyPkTxrW5y4PZT+xaeafoPBirijTsNbSMBOeMJaDeCBXcMpWS8ubFs7RwM0 WWuhwiNe9HXGJXKZyoqU3nlFI114JGyf5LLDzJVY= 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: glob: fix conversion from UTF-32 to multibyte X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 1d3d2ba54bf7fb7f47510b70cc71489b293ff60d X-Git-Newrev: 6bc687e35d6a74b4b9d8531c73b3f6cc571bc744 Message-Id: <20230303172029.D5C5B3858D37@sourceware.org> Date: Fri, 3 Mar 2023 17:20:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D6bc687e35d6= a74b4b9d8531c73b3f6cc571bc744 commit 6bc687e35d6a74b4b9d8531c73b3f6cc571bc744 Author: Corinna Vinschen AuthorDate: Fri Mar 3 11:32:31 2023 +0100 Commit: Corinna Vinschen CommitDate: Fri Mar 3 18:19:17 2023 +0100 Cygwin: glob: fix conversion from UTF-32 to multibyte =20 The conversion function g_Ctoc missed to drop the flag values from the wint_t value. That wasn't noticable with the original version because it used a 64 bit Char type and the flags were in the upper 32 bit region. So the flag values were silently dropped when wcrtomb was called. After converting Char to wint_t, we have to do drop the flags explicitely. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/glob.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc index dadc67e4c10a..4730d09f5590 100644 --- a/winsup/cygwin/glob.cc +++ b/winsup/cygwin/glob.cc @@ -130,7 +130,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010= /05/12 17:44:00 gordon Ex #define M_PROTECT 0x20000000U #define M_MASK 0x70ffffffU #define M_COLL_MASK 0x700000ffU -#define M_CHAR 0x0fffffffU +#define M_CHAR 0x00ffffffU =20 typedef wint_t Char; =20 @@ -1030,7 +1030,7 @@ g_Ctoc(const Char *str, char *buf, size_t len) =20 memset(&mbs, 0, sizeof(mbs)); while (len >=3D (size_t) MB_CUR_MAX) { - clen =3D wirtomb(buf, *str, &mbs); + clen =3D wirtomb(buf, CHAR (*str), &mbs); if (clen =3D=3D (size_t)-1) return (1); if (*str =3D=3D L'\0')