summaryrefslogtreecommitdiff
path: root/wildmatch.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2012-10-15 13:25:58 +0700
committerJunio C Hamano <gitster@pobox.com>2012-10-15 14:58:18 -0700
commit9b4edc0a49abd4b5c6505c63c8fa40d527df6ae8 (patch)
treeb802eaecbd4e85aaddffa27435ba292f7c4a904c /wildmatch.c
parent3ae5396cf719000039c5d0d35f9bf934f647b030 (diff)
downloadgit-9b4edc0a49abd4b5c6505c63c8fa40d527df6ae8.tar.gz
wildmatch: remove static variable force_lower_case
One place less to worry about thread safety. Also combine wildmatch and iwildmatch into one. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wildmatch.c')
-rw-r--r--wildmatch.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/wildmatch.c b/wildmatch.c
index 6d992d314a..eef7b13aa4 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -59,10 +59,8 @@ typedef unsigned char uchar;
#define ISUPPER(c) (ISASCII(c) && isupper(c))
#define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
-static int force_lower_case = 0;
-
/* Match pattern "p" against "text" */
-static int dowild(const uchar *p, const uchar *text)
+static int dowild(const uchar *p, const uchar *text, int force_lower_case)
{
uchar p_ch;
@@ -106,7 +104,7 @@ static int dowild(const uchar *p, const uchar *text)
while (1) {
if (t_ch == '\0')
break;
- if ((matched = dowild(p, text)) != NOMATCH) {
+ if ((matched = dowild(p, text, force_lower_case)) != NOMATCH) {
if (!special || matched != ABORT_TO_STARSTAR)
return matched;
} else if (!special && t_ch == '/')
@@ -214,17 +212,8 @@ static int dowild(const uchar *p, const uchar *text)
}
/* Match the "pattern" against the "text" string. */
-int wildmatch(const char *pattern, const char *text)
-{
- return dowild((const uchar*)pattern, (const uchar*)text);
-}
-
-/* Match the "pattern" against the forced-to-lower-case "text" string. */
-int iwildmatch(const char *pattern, const char *text)
+int wildmatch(const char *pattern, const char *text, int flags)
{
- int ret;
- force_lower_case = 1;
- ret = dowild((const uchar*)pattern, (const uchar*)text);
- force_lower_case = 0;
- return ret;
+ return dowild((const uchar*)pattern, (const uchar*)text,
+ flags & FNM_CASEFOLD ? 1 :0);
}