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>
This commit is contained in:
Corinna Vinschen 2023-03-03 11:32:31 +01:00
parent 1d3d2ba54b
commit 6bc687e35d
1 changed files with 2 additions and 2 deletions

View File

@ -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')