Merge branch 'ar/wildmatch-foldcase' into maint
The wildmatch engine did not honor WM_CASEFOLD option correctly. * ar/wildmatch-foldcase: wildmatch: properly fold case everywhere
This commit is contained in:
@ -6,20 +6,20 @@ test_description='wildmatch tests'
|
|||||||
|
|
||||||
match() {
|
match() {
|
||||||
if [ $1 = 1 ]; then
|
if [ $1 = 1 ]; then
|
||||||
test_expect_success "wildmatch: match '$3' '$4'" "
|
test_expect_success "wildmatch: match '$3' '$4'" "
|
||||||
test-wildmatch wildmatch '$3' '$4'
|
test-wildmatch wildmatch '$3' '$4'
|
||||||
"
|
"
|
||||||
else
|
else
|
||||||
test_expect_success "wildmatch: no match '$3' '$4'" "
|
test_expect_success "wildmatch: no match '$3' '$4'" "
|
||||||
! test-wildmatch wildmatch '$3' '$4'
|
! test-wildmatch wildmatch '$3' '$4'
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
if [ $2 = 1 ]; then
|
if [ $2 = 1 ]; then
|
||||||
test_expect_success "fnmatch: match '$3' '$4'" "
|
test_expect_success "fnmatch: match '$3' '$4'" "
|
||||||
test-wildmatch fnmatch '$3' '$4'
|
test-wildmatch fnmatch '$3' '$4'
|
||||||
"
|
"
|
||||||
elif [ $2 = 0 ]; then
|
elif [ $2 = 0 ]; then
|
||||||
test_expect_success "fnmatch: no match '$3' '$4'" "
|
test_expect_success "fnmatch: no match '$3' '$4'" "
|
||||||
! test-wildmatch fnmatch '$3' '$4'
|
! test-wildmatch fnmatch '$3' '$4'
|
||||||
"
|
"
|
||||||
# else
|
# else
|
||||||
@ -29,13 +29,25 @@ match() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imatch() {
|
||||||
|
if [ $1 = 1 ]; then
|
||||||
|
test_expect_success "iwildmatch: match '$2' '$3'" "
|
||||||
|
test-wildmatch iwildmatch '$2' '$3'
|
||||||
|
"
|
||||||
|
else
|
||||||
|
test_expect_success "iwildmatch: no match '$2' '$3'" "
|
||||||
|
! test-wildmatch iwildmatch '$2' '$3'
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
pathmatch() {
|
pathmatch() {
|
||||||
if [ $1 = 1 ]; then
|
if [ $1 = 1 ]; then
|
||||||
test_expect_success "pathmatch: match '$2' '$3'" "
|
test_expect_success "pathmatch: match '$2' '$3'" "
|
||||||
test-wildmatch pathmatch '$2' '$3'
|
test-wildmatch pathmatch '$2' '$3'
|
||||||
"
|
"
|
||||||
else
|
else
|
||||||
test_expect_success "pathmatch: no match '$2' '$3'" "
|
test_expect_success "pathmatch: no match '$2' '$3'" "
|
||||||
! test-wildmatch pathmatch '$2' '$3'
|
! test-wildmatch pathmatch '$2' '$3'
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
@ -235,4 +247,35 @@ pathmatch 1 abcXdefXghi '*X*i'
|
|||||||
pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'
|
pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'
|
||||||
pathmatch 1 ab/cXd/efXg/hi '*Xg*i'
|
pathmatch 1 ab/cXd/efXg/hi '*Xg*i'
|
||||||
|
|
||||||
|
# Case-sensitivy features
|
||||||
|
match 0 x 'a' '[A-Z]'
|
||||||
|
match 1 x 'A' '[A-Z]'
|
||||||
|
match 0 x 'A' '[a-z]'
|
||||||
|
match 1 x 'a' '[a-z]'
|
||||||
|
match 0 x 'a' '[[:upper:]]'
|
||||||
|
match 1 x 'A' '[[:upper:]]'
|
||||||
|
match 0 x 'A' '[[:lower:]]'
|
||||||
|
match 1 x 'a' '[[:lower:]]'
|
||||||
|
match 0 x 'A' '[B-Za]'
|
||||||
|
match 1 x 'a' '[B-Za]'
|
||||||
|
match 0 x 'A' '[B-a]'
|
||||||
|
match 1 x 'a' '[B-a]'
|
||||||
|
match 0 x 'z' '[Z-y]'
|
||||||
|
match 1 x 'Z' '[Z-y]'
|
||||||
|
|
||||||
|
imatch 1 'a' '[A-Z]'
|
||||||
|
imatch 1 'A' '[A-Z]'
|
||||||
|
imatch 1 'A' '[a-z]'
|
||||||
|
imatch 1 'a' '[a-z]'
|
||||||
|
imatch 1 'a' '[[:upper:]]'
|
||||||
|
imatch 1 'A' '[[:upper:]]'
|
||||||
|
imatch 1 'A' '[[:lower:]]'
|
||||||
|
imatch 1 'a' '[[:lower:]]'
|
||||||
|
imatch 1 'A' '[B-Za]'
|
||||||
|
imatch 1 'a' '[B-Za]'
|
||||||
|
imatch 1 'A' '[B-a]'
|
||||||
|
imatch 1 'a' '[B-a]'
|
||||||
|
imatch 1 'z' '[Z-y]'
|
||||||
|
imatch 1 'Z' '[Z-y]'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -196,6 +196,11 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
|
|||||||
}
|
}
|
||||||
if (t_ch <= p_ch && t_ch >= prev_ch)
|
if (t_ch <= p_ch && t_ch >= prev_ch)
|
||||||
matched = 1;
|
matched = 1;
|
||||||
|
else if ((flags & WM_CASEFOLD) && ISLOWER(t_ch)) {
|
||||||
|
uchar t_ch_upper = toupper(t_ch);
|
||||||
|
if (t_ch_upper <= p_ch && t_ch_upper >= prev_ch)
|
||||||
|
matched = 1;
|
||||||
|
}
|
||||||
p_ch = 0; /* This makes "prev_ch" get set to 0. */
|
p_ch = 0; /* This makes "prev_ch" get set to 0. */
|
||||||
} else if (p_ch == '[' && p[1] == ':') {
|
} else if (p_ch == '[' && p[1] == ':') {
|
||||||
const uchar *s;
|
const uchar *s;
|
||||||
@ -245,6 +250,8 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
|
|||||||
} else if (CC_EQ(s,i, "upper")) {
|
} else if (CC_EQ(s,i, "upper")) {
|
||||||
if (ISUPPER(t_ch))
|
if (ISUPPER(t_ch))
|
||||||
matched = 1;
|
matched = 1;
|
||||||
|
else if ((flags & WM_CASEFOLD) && ISLOWER(t_ch))
|
||||||
|
matched = 1;
|
||||||
} else if (CC_EQ(s,i, "xdigit")) {
|
} else if (CC_EQ(s,i, "xdigit")) {
|
||||||
if (ISXDIGIT(t_ch))
|
if (ISXDIGIT(t_ch))
|
||||||
matched = 1;
|
matched = 1;
|
||||||
|
Reference in New Issue
Block a user