git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] compat/wildmatch: remove static variable force_lower_case

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Sep 26, 2012, 11:25 UTC
Message-ID
<1348658741-8146-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1348658741-8146-1-git-send-email-pclouds@gmail.com>
One place less to worry about thread safety
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 wildmatch.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/wildmatch.c b/wildmatch.c
index f3a1731..e824eb2 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -57,11 +57,10 @@
 int wildmatch_iteration_count;
 #endif
 
-static int force_lower_case = 0;
-
 /* Match pattern "p" against the a virtually-joined string consisting
  * of "text" and any strings in array "a". */
-static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
+static int dowild(const uchar *p, const uchar *text,
+		  const uchar*const *a, int force_lower_case)
 {
     uchar p_ch;
 
@@ -121,7 +120,7 @@ static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
 		    t_ch = *text;
 		    continue;
 		}
-		if ((matched = dowild(p, text, a)) != FALSE) {
+		if ((matched = dowild(p, text, a, force_lower_case)) != FALSE) {
 		    if (!special || matched != ABORT_TO_STARSTAR)
 			return matched;
 		} else if (!special && t_ch == '/')
@@ -291,7 +290,7 @@ int wildmatch(const char *pattern, const char *text)
 #ifdef WILD_TEST_ITERATIONS
     wildmatch_iteration_count = 0;
 #endif
-    return dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
+    return dowild((const uchar*)pattern, (const uchar*)text, nomore, 0) == TRUE;
 }
 
 /* Match the "pattern" against the forced-to-lower-case "text" string. */
@@ -302,9 +301,7 @@ int iwildmatch(const char *pattern, const char *text)
 #ifdef WILD_TEST_ITERATIONS
     wildmatch_iteration_count = 0;
 #endif
-    force_lower_case = 1;
-    ret = dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
-    force_lower_case = 0;
+    ret = dowild((const uchar*)pattern, (const uchar*)text, nomore, 1) == TRUE;
     return ret;
 }
 
@@ -331,7 +328,7 @@ int wildmatch_array(const char *pattern, const char*const *texts, int where)
     if (!text)
 	return FALSE;
 
-    if ((matched = dowild(p, text, a)) != TRUE && where < 0
+    if ((matched = dowild(p, text, a, 0)) != TRUE && where < 0
      && matched != ABORT_ALL) {
 	while (1) {
 	    if (*text == '\0') {
@@ -339,7 +336,7 @@ int wildmatch_array(const char *pattern, const char*const *texts, int where)
 		    return FALSE;
 		continue;
 	    }
-	    if (*text++ == '/' && (matched = dowild(p, text, a)) != FALSE
+	    if (*text++ == '/' && (matched = dowild(p, text, a, 0)) != FALSE
 	     && matched != ABORT_TO_STARSTAR)
 		break;
 	}
-- 
1.7.12.1.406.g6ab07c4
Previous: Ævar Arnfjörð BjarmasonNext: Nguyễn Thái Ngọc Duy
Message 4 of 9 in “wildmatch series update”
  1. 0/5 wildmatch series updateNguyễn Thái Ngọc Duy, Sep 26, 2012
  2. 1/5 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Sep 26, 2012
  3. Ævar Arnfjörð BjarmasonOct 2, 2012
  4. 2/5 compat/wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Sep 26, 2012
  5. 3/5 compat/wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Sep 26, 2012
  6. 4/5 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Sep 26, 2012
  7. 5/5 Support "**" in .gitignore and .gitattributes patterns using wildmatch()Nguyễn Thái Ngọc Duy, Sep 26, 2012
  8. Junio C HamanoSep 27, 2012
  9. Junio C HamanoOct 2, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.