Returns 1 if string contains globbing characters in it
| 45 | |
| 46 | // Returns 1 if string contains globbing characters in it |
| 47 | int PSGlobHasPattern(char *string) { |
| 48 | char *p = string; |
| 49 | char c; |
| 50 | int open = 0; |
| 51 | |
| 52 | while ((c = *p++) != '\0') { |
| 53 | switch (c) { |
| 54 | case '?': |
| 55 | case '*': |
| 56 | return 1; |
| 57 | case '[': // Open brackets must have a matching close bracket in order to be a glob |
| 58 | open++; |
| 59 | continue; |
| 60 | case ']': |
| 61 | if (open) |
| 62 | return 1; |
| 63 | continue; |
| 64 | case '\\': |
| 65 | if (*p++ == '\0') |
| 66 | return 0; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | // PSGlobMatch |
| 74 | // Matches the pattern passed in to the string in text. If the pattern matches |
no outgoing calls
no test coverage detected