From b0aee41ce927ef164b1e02b466a293172402e77e Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 13 Aug 2010 18:42:38 +0000 Subject: [PATCH] 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 --- filematch.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) { -- 2.39.2