public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: fnmatch: drop static variable
@ 2023-02-28 15:46 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-02-28 15:46 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 0d2ad77c40b641ebe2965568945a622f3f6dbd5c
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Feb 28 16:45:52 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Feb 28 16:45:52 2023 +0100

    Cygwin: fnmatch: drop static variable
    
    fnmatch calls fnmatch1 with a static mbstate_t.  This breaks
    calling fnmatch from multiple threads.  Fix it by folding
    fnmatch1 into fnmatch and moving all mbstates to local variables.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/libc/fnmatch.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c
index beb67f01e5d1..d109c2124aba 100644
--- a/winsup/cygwin/libc/fnmatch.c
+++ b/winsup/cygwin/libc/fnmatch.c
@@ -73,22 +73,13 @@ __FBSDID("$FreeBSD: head/lib/libc/gen/fnmatch.c 288309 2015-09-27 12:52:18Z jill
 #define RANGE_ERROR     (-1)
 
 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);
 
 int
 fnmatch(const char *pattern, const char *string, int flags)
 {
-	static const mbstate_t initial;
-
-	return (fnmatch1(pattern, string, string, flags, initial, initial));
-}
-
-static int
-fnmatch1(const char *pattern, const char *string, const char *stringstart,
-    int flags, mbstate_t patmbs, mbstate_t strmbs)
-{
+	const char *stringstart = string;
 	const char *bt_pattern, *bt_string;
+	mbstate_t patmbs, strmbs;
 	mbstate_t bt_patmbs, bt_strmbs;
 	char *newp;
 	char c;

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

only message in thread, other threads:[~2023-02-28 15:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 15:46 [newlib-cygwin/main] Cygwin: fnmatch: drop static variable 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).