mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Use collate for alpha character ranges
This commit is contained in:
parent
89e85b2828
commit
b92a8919d1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17528
@ -147,6 +147,7 @@ static int match __P((Char *, Char *, Char *));
|
||||
#ifdef DEBUG
|
||||
static void qprintf __P((const char *, Char *));
|
||||
#endif
|
||||
static int collcmp __P((int, int));
|
||||
|
||||
int
|
||||
glob(pattern, flags, errfunc, pglob)
|
||||
@ -668,6 +669,37 @@ globextend(path, pglob)
|
||||
return(copy == NULL ? GLOB_NOSPACE : 0);
|
||||
}
|
||||
|
||||
static int
|
||||
collcmp (c1, c2)
|
||||
int c1, c2;
|
||||
{
|
||||
static char s1[2], s2[2];
|
||||
|
||||
if (c1 == c2)
|
||||
return (0);
|
||||
if ( (isascii(c1) && isascii(c2))
|
||||
|| (!isalpha(c1) && !isalpha(c2))
|
||||
)
|
||||
return (c1 - c2);
|
||||
if (isalpha(c1) && !isalpha(c2)) {
|
||||
if (isupper(c1))
|
||||
return ('A' - c2);
|
||||
else
|
||||
return ('a' - c2);
|
||||
} else if (isalpha(c2) && !isalpha(c1)) {
|
||||
if (isupper(c2))
|
||||
return (c1 - 'A');
|
||||
else
|
||||
return (c1 - 'a');
|
||||
}
|
||||
if (isupper(c1) && islower(c2))
|
||||
return (-1);
|
||||
else if (islower(c1) && isupper(c2))
|
||||
return (1);
|
||||
s1[0] = c1;
|
||||
s2[0] = c2;
|
||||
return strcoll(s1, s2);
|
||||
}
|
||||
|
||||
/*
|
||||
* pattern matching function for filenames. Each occurrence of the *
|
||||
@ -703,7 +735,9 @@ match(name, pat, patend)
|
||||
++pat;
|
||||
while (((c = *pat++) & M_MASK) != M_END)
|
||||
if ((*pat & M_MASK) == M_RNG) {
|
||||
if (c <= k && k <= pat[1])
|
||||
if ( collcmp(CHAR(c), CHAR(k)) <= 0
|
||||
&& collcmp(CHAR(k), CHAR(pat[1])) <= 0
|
||||
)
|
||||
ok = 1;
|
||||
pat += 2;
|
||||
} else if (c == k)
|
||||
|
Loading…
Reference in New Issue
Block a user