Compare commits
2 Commits
ad0a18e8a9
...
a4f28850de
Author | SHA1 | Date |
---|---|---|
Nick Chambers | a4f28850de | |
Nick Chambers | 652e40da30 |
10
c/cosmic.c
10
c/cosmic.c
|
@ -1,5 +1,5 @@
|
||||||
int match(const char *needle, const char *haystack) {
|
int match(const char *needle, const char *haystack) {
|
||||||
while(*haystack) {
|
while(*haystack || *needle) {
|
||||||
if(*needle == '*' && *(needle + 1) == '*') {
|
if(*needle == '*' && *(needle + 1) == '*') {
|
||||||
needle += 1;
|
needle += 1;
|
||||||
} else if(*needle == '*') {
|
} else if(*needle == '*') {
|
||||||
|
@ -7,6 +7,8 @@ int match(const char *needle, const char *haystack) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if(*(needle + 1) == *haystack) {
|
} else if(*(needle + 1) == *haystack) {
|
||||||
needle += 1;
|
needle += 1;
|
||||||
|
} else if(*haystack == '\0') {
|
||||||
|
needle += 1;
|
||||||
} else {
|
} else {
|
||||||
haystack += 1;
|
haystack += 1;
|
||||||
}
|
}
|
||||||
|
@ -18,11 +20,7 @@ int match(const char *needle, const char *haystack) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(*needle == '*') {
|
return 1;
|
||||||
needle += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *needle == '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
Loading…
Reference in New Issue