]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Fix issues with matchpattern_with_separator
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 13 Aug 2010 18:42:38 +0000 (18:42 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 13 Aug 2010 18:42:38 +0000 (18:42 +0000)
Wrong results in case wildcard_least_one is:
- false: *rc*.cfg finds quake.rc
- true: quake.*rc finds quake.rc

From: terencehill <piuntn@gmail.com>

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10388 d7cf8633-e32d-0410-b094-e92efae38249

filematch.c

index 54bd2a5c50f13d86bef459c47ed0816a0bb5d84e..9ff8a767514a39667afb4f3c867a15b014ad7d8e 100644 (file)
@@ -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)
                        {