1 diff --git a/match.c b/match.c
2 index 6cd656f..4e569f5 100644
5 @@ -190,10 +190,10 @@ char *___tmp_ptr;
9 -static int recmatch(p, s, cs)
10 +static int recmatch(p, s, ci)
11 ZCONST char *p; /* sh pattern to match */
12 ZCONST char *s; /* string to match it to */
13 -int cs; /* flag: force case-sensitive matching */
14 +int ci; /* flag: force case-insensitive matching */
15 /* Recursively compare the sh pattern p with the string s and return 1 if
16 they match, and 0 or 2 if they don't or if there is a syntax error in the
17 pattern. This routine recurses on itself no deeper than the number of
18 @@ -214,7 +214,7 @@ int cs; /* flag: force case-sensitive matching */
21 return (*p == *s && *(p+1) == *(s+1)) ?
22 - recmatch(p + 2, s + 2, cs) : 0;
23 + recmatch(p + 2, s + 2, ci) : 0;
27 @@ -230,9 +230,9 @@ int cs; /* flag: force case-sensitive matching */
28 /* '?' (or '%' or '#') matches any character (but not an empty string) */
29 if (c == WILDCHR_SINGLE) {
31 - return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), cs) : 0;
32 + return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), ci) : 0;
34 - return *s ? recmatch(p, s + CLEN(s), cs) : 0;
35 + return *s ? recmatch(p, s + CLEN(s), ci) : 0;
38 /* WILDCHR_MULTI ('*') matches any number of characters, including zero */
39 @@ -253,14 +253,14 @@ int cs; /* flag: force case-sensitive matching */
41 /* Single WILDCHR_MULTI ('*'): this doesn't match slashes */
42 for (; *s && *s != DIRSEP_CHR; INCSTR(s))
43 - if ((c = recmatch(p, s, cs)) != 0)
44 + if ((c = recmatch(p, s, ci)) != 0)
46 /* end of pattern: matched if at end of string, else continue */
49 /* continue to match if at DIRSEP_CHR in pattern, else give up */
50 return (*p == DIRSEP_CHR || (*p == '\\' && p[1] == DIRSEP_CHR))
51 - ? recmatch(p, s, cs) : 2;
52 + ? recmatch(p, s, ci) : 2;
54 /* Two consecutive WILDCHR_MULTI ("**"): this matches DIRSEP_CHR ('/') */
55 p++; /* move p past the second WILDCHR_MULTI */
56 @@ -308,17 +308,17 @@ int cs; /* flag: force case-sensitive matching */
60 - return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
61 + return ((!ci ? strcmp(p, q) : namecmp(p, q)) == 0);
64 - return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
65 + return ((!ci ? strcmp(p, srest) : namecmp(p, srest)) == 0);
70 /* pattern contains more wildcards, continue with recursion... */
72 - if ((c = recmatch(p, s, cs)) != 0)
73 + if ((c = recmatch(p, s, ci)) != 0)
75 return 2; /* 2 means give up--shmatch will return false */
77 @@ -353,17 +353,17 @@ int cs; /* flag: force case-sensitive matching */
81 - uch cc = (cs ? (uch)*s : case_map((uch)*s));
82 + uch cc = (!ci ? (uch)*s : to_up((uch)*s));
85 for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
87 - if ((cs ? uc : case_map(uc)) == cc)
88 - return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
89 + if ((!ci ? uc : to_up(uc)) == cc)
90 + return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), ci);
91 c = e = 0; /* clear range, escape flags */
94 - return r ? recmatch(q + CLEN(q), s + CLEN(s), cs) : 0;
95 + return r ? recmatch(q + CLEN(q), s + CLEN(s), ci) : 0;
96 /* bracket match failed */
99 @@ -382,18 +382,18 @@ int cs; /* flag: force case-sensitive matching */
101 /* Match "...]" with "]". Continue after "]" in both. */
102 if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
103 - return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
104 + return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
106 /* Else, look for a reduced match in s, until "]" in or end of s. */
107 for (; *s && (*s != ']'); INCSTR(s))
109 /* If reduced match, then continue after "..." in p, "." in s. */
110 - if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
111 + if ((c = recmatch( (p+ CLEN( p)), s, ci)) != 0)
114 /* Match "...]" with "]". Continue after "]" in both. */
115 if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
116 - return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
117 + return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
119 /* No reduced match. Quit. */
121 @@ -402,8 +402,8 @@ int cs; /* flag: force case-sensitive matching */
124 /* Just a character--compare it */
125 - return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
126 - recmatch(p, s + CLEN(s), cs) : 0;
127 + return (!ci ? c == *s : to_up((uch)c) == to_up((uch)*s)) ?
128 + recmatch(p, s + CLEN(s), ci) : 0;