|
|
5c40ff |
diff --git a/match.c b/match.c
|
|
|
5c40ff |
index 6cd656f..4e569f5 100644
|
|
|
5c40ff |
--- a/match.c
|
|
|
5c40ff |
+++ b/match.c
|
|
|
5c40ff |
@@ -190,10 +190,10 @@ char *___tmp_ptr;
|
|
|
5c40ff |
|
|
|
5c40ff |
#endif
|
|
|
5c40ff |
|
|
|
5c40ff |
-static int recmatch(p, s, cs)
|
|
|
5c40ff |
+static int recmatch(p, s, ci)
|
|
|
5c40ff |
ZCONST char *p; /* sh pattern to match */
|
|
|
5c40ff |
ZCONST char *s; /* string to match it to */
|
|
|
5c40ff |
-int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
+int ci; /* flag: force case-insensitive matching */
|
|
|
5c40ff |
/* Recursively compare the sh pattern p with the string s and return 1 if
|
|
|
5c40ff |
they match, and 0 or 2 if they don't or if there is a syntax error in the
|
|
|
5c40ff |
pattern. This routine recurses on itself no deeper than the number of
|
|
|
5c40ff |
@@ -214,7 +214,7 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
if (CLEN(p) == 2) {
|
|
|
5c40ff |
if (CLEN(s) == 2) {
|
|
|
5c40ff |
return (*p == *s && *(p+1) == *(s+1)) ?
|
|
|
5c40ff |
- recmatch(p + 2, s + 2, cs) : 0;
|
|
|
5c40ff |
+ recmatch(p + 2, s + 2, ci) : 0;
|
|
|
5c40ff |
} else {
|
|
|
5c40ff |
return 0;
|
|
|
5c40ff |
}
|
|
|
5c40ff |
@@ -230,9 +230,9 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
/* '?' (or '%' or '#') matches any character (but not an empty string) */
|
|
|
5c40ff |
if (c == WILDCHR_SINGLE) {
|
|
|
5c40ff |
if (wild_stop_at_dir)
|
|
|
5c40ff |
- return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), cs) : 0;
|
|
|
5c40ff |
+ return (*s && *s != DIRSEP_CHR) ? recmatch(p, s + CLEN(s), ci) : 0;
|
|
|
5c40ff |
else
|
|
|
5c40ff |
- return *s ? recmatch(p, s + CLEN(s), cs) : 0;
|
|
|
5c40ff |
+ return *s ? recmatch(p, s + CLEN(s), ci) : 0;
|
|
|
5c40ff |
}
|
|
|
5c40ff |
|
|
|
5c40ff |
/* WILDCHR_MULTI ('*') matches any number of characters, including zero */
|
|
|
5c40ff |
@@ -253,14 +253,14 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
# endif /* ?AMIGA */
|
|
|
5c40ff |
/* Single WILDCHR_MULTI ('*'): this doesn't match slashes */
|
|
|
5c40ff |
for (; *s && *s != DIRSEP_CHR; INCSTR(s))
|
|
|
5c40ff |
- if ((c = recmatch(p, s, cs)) != 0)
|
|
|
5c40ff |
+ if ((c = recmatch(p, s, ci)) != 0)
|
|
|
5c40ff |
return c;
|
|
|
5c40ff |
/* end of pattern: matched if at end of string, else continue */
|
|
|
5c40ff |
if (*p == 0)
|
|
|
5c40ff |
return (*s == 0);
|
|
|
5c40ff |
/* continue to match if at DIRSEP_CHR in pattern, else give up */
|
|
|
5c40ff |
return (*p == DIRSEP_CHR || (*p == '\\' && p[1] == DIRSEP_CHR))
|
|
|
5c40ff |
- ? recmatch(p, s, cs) : 2;
|
|
|
5c40ff |
+ ? recmatch(p, s, ci) : 2;
|
|
|
5c40ff |
}
|
|
|
5c40ff |
/* Two consecutive WILDCHR_MULTI ("**"): this matches DIRSEP_CHR ('/') */
|
|
|
5c40ff |
p++; /* move p past the second WILDCHR_MULTI */
|
|
|
5c40ff |
@@ -308,17 +308,17 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
*/
|
|
|
5c40ff |
if (q != srest)
|
|
|
5c40ff |
return 0;
|
|
|
5c40ff |
- return ((cs ? strcmp(p, q) : namecmp(p, q)) == 0);
|
|
|
5c40ff |
+ return ((!ci ? strcmp(p, q) : namecmp(p, q)) == 0);
|
|
|
5c40ff |
}
|
|
|
5c40ff |
#else /* !_MBCS */
|
|
|
5c40ff |
- return ((cs ? strcmp(p, srest) : namecmp(p, srest)) == 0);
|
|
|
5c40ff |
+ return ((!ci ? strcmp(p, srest) : namecmp(p, srest)) == 0);
|
|
|
5c40ff |
#endif /* ?_MBCS */
|
|
|
5c40ff |
}
|
|
|
5c40ff |
else
|
|
|
5c40ff |
{
|
|
|
5c40ff |
/* pattern contains more wildcards, continue with recursion... */
|
|
|
5c40ff |
for (; *s; INCSTR(s))
|
|
|
5c40ff |
- if ((c = recmatch(p, s, cs)) != 0)
|
|
|
5c40ff |
+ if ((c = recmatch(p, s, ci)) != 0)
|
|
|
5c40ff |
return c;
|
|
|
5c40ff |
return 2; /* 2 means give up--shmatch will return false */
|
|
|
5c40ff |
}
|
|
|
5c40ff |
@@ -353,17 +353,17 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
c = *(p-1);
|
|
|
5c40ff |
else
|
|
|
5c40ff |
{
|
|
|
5c40ff |
- uch cc = (cs ? (uch)*s : case_map((uch)*s));
|
|
|
5c40ff |
+ uch cc = (!ci ? (uch)*s : to_up((uch)*s));
|
|
|
5c40ff |
uch uc = (uch) c;
|
|
|
5c40ff |
if (*(p+1) != '-')
|
|
|
5c40ff |
for (uc = uc ? uc : (uch)*p; uc <= (uch)*p; uc++)
|
|
|
5c40ff |
/* compare range */
|
|
|
5c40ff |
- if ((cs ? uc : case_map(uc)) == cc)
|
|
|
5c40ff |
- return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), cs);
|
|
|
5c40ff |
+ if ((!ci ? uc : to_up(uc)) == cc)
|
|
|
5c40ff |
+ return r ? 0 : recmatch(q + CLEN(q), s + CLEN(s), ci);
|
|
|
5c40ff |
c = e = 0; /* clear range, escape flags */
|
|
|
5c40ff |
}
|
|
|
5c40ff |
}
|
|
|
5c40ff |
- return r ? recmatch(q + CLEN(q), s + CLEN(s), cs) : 0;
|
|
|
5c40ff |
+ return r ? recmatch(q + CLEN(q), s + CLEN(s), ci) : 0;
|
|
|
5c40ff |
/* bracket match failed */
|
|
|
5c40ff |
}
|
|
|
5c40ff |
#endif /* !VMS */
|
|
|
5c40ff |
@@ -382,18 +382,18 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
{
|
|
|
5c40ff |
/* Match "...]" with "]". Continue after "]" in both. */
|
|
|
5c40ff |
if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
|
|
|
5c40ff |
- return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
|
|
|
5c40ff |
+ return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
|
|
|
5c40ff |
|
|
|
5c40ff |
/* Else, look for a reduced match in s, until "]" in or end of s. */
|
|
|
5c40ff |
for (; *s && (*s != ']'); INCSTR(s))
|
|
|
5c40ff |
if (*s == '.')
|
|
|
5c40ff |
/* If reduced match, then continue after "..." in p, "." in s. */
|
|
|
5c40ff |
- if ((c = recmatch( (p+ CLEN( p)), s, cs)) != 0)
|
|
|
5c40ff |
+ if ((c = recmatch( (p+ CLEN( p)), s, ci)) != 0)
|
|
|
5c40ff |
return (int)c;
|
|
|
5c40ff |
|
|
|
5c40ff |
/* Match "...]" with "]". Continue after "]" in both. */
|
|
|
5c40ff |
if ((*(p+ 2* CLEN( p)) == ']') && (*s == ']'))
|
|
|
5c40ff |
- return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), cs);
|
|
|
5c40ff |
+ return recmatch( (p+ 3* CLEN( p)), (s+ CLEN( s)), ci);
|
|
|
5c40ff |
|
|
|
5c40ff |
/* No reduced match. Quit. */
|
|
|
5c40ff |
return 2;
|
|
|
5c40ff |
@@ -402,8 +402,8 @@ int cs; /* flag: force case-sensitive matching */
|
|
|
5c40ff |
#endif /* def VMS */
|
|
|
5c40ff |
|
|
|
5c40ff |
/* Just a character--compare it */
|
|
|
5c40ff |
- return (cs ? c == *s : case_map((uch)c) == case_map((uch)*s)) ?
|
|
|
5c40ff |
- recmatch(p, s + CLEN(s), cs) : 0;
|
|
|
5c40ff |
+ return (!ci ? c == *s : to_up((uch)c) == to_up((uch)*s)) ?
|
|
|
5c40ff |
+ recmatch(p, s + CLEN(s), ci) : 0;
|
|
|
5c40ff |
}
|
|
|
5c40ff |
|
|
|
5c40ff |
|