/* NOTREACHED */
}
-#ifndef HAVE_CYGWIN /* Cygwin version in openbsd-compat/bsd-cygwin_util.c */
-
/*
* Tries to match the string against the
* comma-separated sequence of subpatterns (each possibly preceded by ! to
return got_positive;
}
-#endif
-
/* Match a list representing users or groups. */
int
match_usergroup_pattern_list(const char *string, const char *pattern)
{
-#ifndef HAVE_CYGWIN
- /* Case sensitive match */
- return match_pattern_list(string, pattern, 0);
+#ifdef HAVE_CYGWIN
+ /* Windows usernames may be Unicode and are not case sensitive */
+ return cygwin_ug_match_pattern_list(string, pattern);
#else
/* Case insensitive match */
- return match_pattern_list(string, pattern, 1);
+ return match_pattern_list(string, pattern, 0);
#endif
}
*/
static int
-__match_pattern (const wchar_t *s, const wchar_t *pattern, int caseinsensitive)
+__match_pattern (const wchar_t *s, const wchar_t *pattern)
{
for (;;) {
/* If at end of pattern, accept if also at end of string. */
*/
for (; *s; s++)
if (*s == *pattern &&
- __match_pattern(s + 1, pattern + 1,
- caseinsensitive))
+ __match_pattern(s + 1, pattern + 1))
return 1;
/* Failed. */
return 0;
* match at each position.
*/
for (; *s; s++)
- if (__match_pattern(s, pattern, caseinsensitive))
+ if (__match_pattern(s, pattern))
return 1;
/* Failed. */
return 0;
return 0;
/* Check if the next character of the string is acceptable. */
- if (*pattern != '?' && (*pattern != *s &&
- (!caseinsensitive || towlower(*pattern) != towlower(*s))))
+ if (*pattern != '?' && towlower(*pattern) != towlower(*s))
return 0;
/* Move to the next character, both in string and in pattern. */
}
static int
-_match_pattern(const char *s, const char *pattern, int caseinsensitive)
+_match_pattern(const char *s, const char *pattern)
{
wchar_t *ws;
wchar_t *wpattern;
return 0;
wpattern = (wchar_t *) alloca((len + 1) * sizeof (wchar_t));
mbstowcs(wpattern, pattern, len + 1);
- return __match_pattern (ws, wpattern, caseinsensitive);
+ return __match_pattern (ws, wpattern);
}
/*
* a positive match, 0 if there is no match at all.
*/
int
-match_pattern_list(const char *string, const char *pattern, int caseinsensitive)
+cygwin_ug_match_pattern_list(const char *string, const char *pattern)
{
char sub[1024];
int negated;
sub[subi] = '\0';
/* Try to match the subpattern against the string. */
- if (_match_pattern(string, sub, caseinsensitive)) {
+ if (_match_pattern(string, sub)) {
if (negated)
return -1; /* Negative */
else