X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=filematch.c;h=9ff8a767514a39667afb4f3c867a15b014ad7d8e;hb=d896dc4570e9eea6e50367f9a1c13a8d2a16b865;hp=c88c704e309057386b673d4221a8bc815f6f6e97;hpb=31c60f86f584447beac6b654e54587229f2c9496;p=xonotic%2Fdarkplaces.git diff --git a/filematch.c b/filematch.c index c88c704e..9ff8a767 100644 --- a/filematch.c +++ b/filematch.c @@ -8,6 +8,8 @@ int matchpattern(const char *in, const char *pattern, int caseinsensitive) return matchpattern_with_separator(in, pattern, caseinsensitive, "/\\:", false); } +// wildcard_least_one: if true * matches 1 or more characters +// if false * matches 0 or more characters int matchpattern_with_separator(const char *in, const char *pattern, int caseinsensitive, const char *separators, qboolean wildcard_least_one) { int c1, c2; @@ -25,17 +27,18 @@ int matchpattern_with_separator(const char *in, const char *pattern, int caseins break; case '*': // match anything until following string if(wildcard_least_one) + { if (*in == 0 || strchr(separators, *in)) return 0; // no match - if (!*in) - return 1; // match + in++; + } pattern++; while (*in) { if (strchr(separators, *in)) break; // see if pattern matches at this offset - if (matchpattern(in, pattern, caseinsensitive)) + if (matchpattern_with_separator(in, pattern, caseinsensitive, separators, wildcard_least_one)) return 1; // nope, advance to next offset in++;