Account for needles that end in a *
This commit is contained in:
parent
201e9b0eae
commit
a573539ac8
|
@ -4,7 +4,7 @@ int match(const char *needle, const char *haystack) {
|
||||||
needle += 1;
|
needle += 1;
|
||||||
} else if(*needle == '*') {
|
} else if(*needle == '*') {
|
||||||
if(*(needle + 1) == '\0') {
|
if(*(needle + 1) == '\0') {
|
||||||
return 0;
|
return 1;
|
||||||
} else if(*(needle + 1) == *haystack) {
|
} else if(*(needle + 1) == *haystack) {
|
||||||
needle += 1;
|
needle += 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,10 +14,14 @@ int match(const char *needle, const char *haystack) {
|
||||||
needle += 1;
|
needle += 1;
|
||||||
haystack += 1;
|
haystack += 1;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(*needle == '*') {
|
||||||
|
needle += 1;
|
||||||
|
}
|
||||||
|
|
||||||
return *needle == '\0';
|
return *needle == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue