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

[PATCH 5/8] wildmatch: fix case-insensitive matching

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Oct 9, 2012, 03:09 UTC
Message-ID
<1349752147-13314-6-git-send-email-pclouds@gmail.com>
In-Reply-To
<1349752147-13314-1-git-send-email-pclouds@gmail.com>

dowild() does case insensitive matching by lower-casing the text. That means lower case letters in patterns imply case-insensitive matching, but upper case means exact matching.

We do not want that subtlety. Lower case pattern too so iwildmatch() always does what we expect it to do.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 wildmatch.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/wildmatch.c b/wildmatch.c
index 2382873..fdb8cb1 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -72,6 +72,8 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 		return ABORT_ALL;
 	if (force_lower_case && ISUPPER(t_ch))
 	    t_ch = tolower(t_ch);
+	if (force_lower_case && ISUPPER(p_ch))
+	    p_ch = tolower(p_ch);
 	switch (p_ch) {
 	  case '\\':
 	    /* Literal match with following character.  Note that the test
-- 
1.8.0.rc0.29.g1fdd78f
Previous: Nguyen Thai Ngoc DuyNext: Nguyễn Thái Ngọc Duy
Message 10 of 15 in “wildmatch take 3”
  1. 0/8 wildmatch take 3Nguyễn Thái Ngọc Duy, Oct 9, 2012
  2. 1/8 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Oct 9, 2012
  3. 2/8 wildmatch: remove unnecessary functionsNguyễn Thái Ngọc Duy, Oct 9, 2012
  4. 3/8 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Oct 9, 2012
  5. 4/8 wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Oct 9, 2012
  6. Junio C HamanoOct 9, 2012
  7. Nguyen Thai Ngoc DuyOct 10, 2012
  8. Junio C HamanoOct 10, 2012
  9. Nguyen Thai Ngoc DuyOct 10, 2012
  10. 5/8 wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Oct 9, 2012
  11. 6/8 wildmatch: adjust "**" behaviorNguyễn Thái Ngọc Duy, Oct 9, 2012
  12. 7/8 wildmatch: make /**/ match zero or more directoriesNguyễn Thái Ngọc Duy, Oct 9, 2012
  13. 8/8 Support "**" wildcard in .gitignore and .gitattributesNguyễn Thái Ngọc Duy, Oct 9, 2012
  14. Michael HaggertyOct 9, 2012
  15. Nguyen Thai Ngoc DuyOct 10, 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.