public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: glob: convert wchar_t to wint_t
Date: Tue, 14 Feb 2023 12:10:08 +0000 (GMT)	[thread overview]
Message-ID: <20230214121008.CE0053858C5E@sourceware.org> (raw)

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

commit 0321fb5736545b5535e640b99b550ed6249f0e0c
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Feb 14 12:48:03 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Feb 14 12:48:31 2023 +0100

    Cygwin: glob: convert wchar_t to wint_t
    
    ...thus handling all Unicode values sanely.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/glob.cc | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc
index 0d9f9c88532a..61fa610d60a0 100644
--- a/winsup/cygwin/glob.cc
+++ b/winsup/cygwin/glob.cc
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/05/12 17:44:00 gordon Ex
  *    GLOB_NOCHECK is specified.
  * 2. Illegal byte sequences in filenames are handled by treating them as
  *    single-byte characters with a value of the first byte of the sequence
- *    cast to wchar_t.
+ *    cast to wint_t.
  * 3. State-dependent encodings are not currently supported.
  */
 
@@ -162,7 +162,7 @@ static int	 compare(const void *, const void *);
 static int	 g_Ctoc(const Char *, char *, size_t);
 static int	 g_lstat(Char *, struct stat *, glob_t *);
 static DIR	*g_opendir(Char *, glob_t *);
-static const Char *g_strchr(const Char *, wchar_t);
+static const Char *g_strchr(const Char *, wint_t);
 #ifdef notdef
 static Char	*g_strcat(Char *, const Char *);
 #endif
@@ -188,7 +188,7 @@ glob(const char *__restrict pattern, int flags, int (*errfunc)(const char *, int
 	size_t limit;
 	Char *bufnext, *bufend, patbuf[MAXPATHLEN], prot;
 	mbstate_t mbs;
-	wchar_t wc;
+	wint_t wc;
 	size_t clen;
 
 	patnext = pattern;
@@ -213,7 +213,7 @@ glob(const char *__restrict pattern, int flags, int (*errfunc)(const char *, int
 	if (flags & GLOB_NOESCAPE) {
 		memset(&mbs, 0, sizeof(mbs));
 		while (bufend - bufnext >= MB_CUR_MAX) {
-			clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
+			clen = mbrtowi(&wc, patnext, MB_LEN_MAX, &mbs);
 			if (clen == (size_t)-1 || clen == (size_t)-2)
 				return (GLOB_NOMATCH);
 			else if (clen == 0)
@@ -233,7 +233,7 @@ glob(const char *__restrict pattern, int flags, int (*errfunc)(const char *, int
 				prot = M_PROTECT;
 			} else
 				prot = 0;
-			clen = mbrtowc(&wc, patnext, MB_LEN_MAX, &mbs);
+			clen = mbrtowi(&wc, patnext, MB_LEN_MAX, &mbs);
 			if (clen == (size_t)-1 || clen == (size_t)-2)
 				return (GLOB_NOMATCH);
 			else if (clen == 0)
@@ -663,7 +663,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
 	while ((dp = (*readdirfunc)(dirp))) {
 		char *sc;
 		Char *dc;
-		wchar_t wc;
+		wint_t wc;
 		size_t clen;
 		mbstate_t mbs;
 
@@ -674,7 +674,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pathend_last,
 		dc = pathend;
 		sc = dp->d_name;
 		while (dc < pathend_last) {
-			clen = mbrtowc(&wc, sc, MB_LEN_MAX, &mbs);
+			clen = mbrtowi(&wc, sc, MB_LEN_MAX, &mbs);
 			if (clen == (size_t)-1 || clen == (size_t)-2) {
 				wc = *sc;
 				clen = 1;
@@ -883,7 +883,7 @@ g_stat(Char *fn, struct stat *sb, glob_t *pglob)
 }
 
 static const Char *
-g_strchr(const Char *str, wchar_t ch)
+g_strchr(const Char *str, wint_t ch)
 {
 
 	do {

                 reply	other threads:[~2023-02-14 12:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230214121008.CE0053858C5E@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).