public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: glob: fix conversion from UTF-32 to multibyte
@ 2023-03-03 17:20 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-03-03 17:20 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 6bc687e35d6a74b4b9d8531c73b3f6cc571bc744
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Mar 3 11:32:31 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Mar 3 18:19:17 2023 +0100

    Cygwin: glob: fix conversion from UTF-32 to multibyte
    
    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.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

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
 
 typedef wint_t Char;
 
@@ -1030,7 +1030,7 @@ g_Ctoc(const Char *str, char *buf, size_t len)
 
 	memset(&mbs, 0, sizeof(mbs));
 	while (len >= (size_t) MB_CUR_MAX) {
-		clen = wirtomb(buf, *str, &mbs);
+		clen = wirtomb(buf, CHAR (*str), &mbs);
 		if (clen == (size_t)-1)
 			return (1);
 		if (*str == L'\0')

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-03 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 17:20 [newlib-cygwin/main] Cygwin: glob: fix conversion from UTF-32 to multibyte Corinna Vinschen

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).