| 157 | } |
| 158 | |
| 159 | int git_fnmatch(const struct pathspec_item *item, |
| 160 | const char *pattern, const char *string, |
| 161 | int prefix) |
| 162 | { |
| 163 | if (prefix > 0) { |
| 164 | if (ps_strncmp(item, pattern, string, prefix)) |
| 165 | return WM_NOMATCH; |
| 166 | pattern += prefix; |
| 167 | string += prefix; |
| 168 | } |
| 169 | if (item->flags & PATHSPEC_ONESTAR) { |
| 170 | int pattern_len = strlen(++pattern); |
| 171 | int string_len = strlen(string); |
| 172 | return string_len < pattern_len || |
| 173 | ps_strcmp(item, pattern, |
| 174 | string + string_len - pattern_len); |
| 175 | } |
| 176 | if (item->magic & PATHSPEC_GLOB) |
| 177 | return wildmatch(pattern, string, |
| 178 | WM_PATHNAME | |
| 179 | (item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0)); |
| 180 | else |
| 181 | /* wildmatch has not learned no FNM_PATHNAME mode yet */ |
| 182 | return wildmatch(pattern, string, |
| 183 | item->magic & PATHSPEC_ICASE ? WM_CASEFOLD : 0); |
| 184 | } |
| 185 | |
| 186 | static int fnmatch_icase_mem(const char *pattern, int patternlen, |
| 187 | const char *string, int stringlen, |
no test coverage detected