4 // LordHavoc: some portable directory listing code I wrote for lmp2pcx, now used in darkplaces to load id1/*.pak and such...
6 int matchpattern(const char *in, const char *pattern, int caseinsensitive)
8 return matchpattern_with_separator(in, pattern, caseinsensitive, "/\\:", 0);
11 // wildcard_least_one: if true * matches 1 or more characters
12 // if false * matches 0 or more characters
13 int matchpattern_with_separator(const char *in, const char *pattern, int caseinsensitive, const char *separators, int wildcard_least_one)
21 return 1; // end of pattern
22 case '?': // match any single character
23 if (*in == 0 || strchr(separators, *in))
28 case '*': // match anything until following string
29 if(wildcard_least_one)
31 if (*in == 0 || strchr(separators, *in))
38 if (strchr(separators, *in))
40 // see if pattern matches at this offset
41 if (matchpattern_with_separator(in, pattern, caseinsensitive, separators, wildcard_least_one))
43 // nope, advance to next offset
53 if (c1 >= 'A' && c1 <= 'Z')
56 if (c2 >= 'A' && c2 <= 'Z')
67 return 0; // reached end of pattern but not end of input