From: divverent Date: Fri, 13 Aug 2010 18:42:38 +0000 (+0000) Subject: Fix issues with matchpattern_with_separator X-Git-Tag: xonotic-v0.1.0preview~282 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9d47e6a8c4fe99c2d0906fd99be5495aa154b6d4;p=xonotic%2Fdarkplaces.git Fix issues with matchpattern_with_separator Wrong results in case wildcard_least_one is: - false: *rc*.cfg finds quake.rc - true: quake.*rc finds quake.rc From: terencehill git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10388 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=b0aee41ce927ef164b1e02b466a293172402e77e --- diff --git a/filematch.c b/filematch.c index 54bd2a5c..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,10 +27,11 @@ 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) {