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 15, 2012, 12:02 UTC
Message-ID
<1347710524-15404-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1347710524-15404-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>
---
 compat/wildmatch.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/compat/wildmatch.c b/compat/wildmatch.c
index f3a1731..e824eb2 100644
--- a/compat/wildmatch.c
+++ b/compat/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.403.gce5cf6f.dirty
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 4 of 34 in “Support matching "**" in .gitattributes and .gitignore”
  1. 0/5 Support matching "**" in .gitattributes and .gitignoreNguyễn Thái Ngọc Duy, Sep 15, 2012
  2. 1/5 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Sep 15, 2012
  3. Junio C HamanoSep 16, 2012
  4. 2/5 compat/wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Sep 15, 2012
  5. 3/5 compat/wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Sep 15, 2012
  6. 4/5 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Sep 15, 2012
  7. 5/5 Support "**" in .gitignore and .gitattributes patterns using wildmatch()Nguyễn Thái Ngọc Duy, Sep 15, 2012
  8. How to create the " [PATCH 0/5]" first email?Philip Oakley, Sep 15, 2012
  9. Junio C HamanoSep 15, 2012
  10. Philip OakleySep 17, 2012
  11. Junio C HamanoSep 17, 2012
  12. Jeff KingSep 18, 2012
  13. Junio C HamanoSep 18, 2012
  14. Jeff KingSep 18, 2012
  15. Junio C HamanoSep 18, 2012
  16. Jeff KingSep 18, 2012
  17. Junio C HamanoSep 18, 2012
  18. Philip OakleySep 18, 2012
  19. Jeff KingSep 18, 2012
  20. Jeff KingSep 18, 2012
  21. Wesley J. LandakerSep 18, 2012
  22. Jan EngelhardtSep 23, 2012
  23. 0/5 Support matching "**" in .gitattributes and .gitignoreNguyễn Thái Ngọc Duy, Sep 16, 2012
  24. 1/5 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Sep 16, 2012
  25. 2/5 compat/wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Sep 16, 2012
  26. 3/5 compat/wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Sep 16, 2012
  27. 4/5 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Sep 16, 2012
  28. Junio C HamanoSep 17, 2012
  29. Junio C HamanoSep 17, 2012
  30. Nguyen Thai Ngoc DuySep 17, 2012
  31. Nguyen Thai Ngoc DuySep 17, 2012
  32. Junio C HamanoSep 17, 2012
  33. 5/5 Support "**" in .gitignore and .gitattributes patterns using wildmatch()Nguyễn Thái Ngọc Duy, Sep 16, 2012
  34. 6/5 side-step a make rule that builds t3070-wildmatchJohannes Sixt, Sep 25, 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.