| 695 | } |
| 696 | |
| 697 | void parse_path_pattern(const char **pattern, |
| 698 | int *patternlen, |
| 699 | unsigned *flags, |
| 700 | int *nowildcardlen) |
| 701 | { |
| 702 | const char *p = *pattern; |
| 703 | size_t i, len; |
| 704 | |
| 705 | *flags = 0; |
| 706 | if (*p == '!') { |
| 707 | *flags |= PATTERN_FLAG_NEGATIVE; |
| 708 | p++; |
| 709 | } |
| 710 | len = strlen(p); |
| 711 | if (len && p[len - 1] == '/') { |
| 712 | len--; |
| 713 | *flags |= PATTERN_FLAG_MUSTBEDIR; |
| 714 | } |
| 715 | for (i = 0; i < len; i++) { |
| 716 | if (p[i] == '/') |
| 717 | break; |
| 718 | } |
| 719 | if (i == len) |
| 720 | *flags |= PATTERN_FLAG_NODIR; |
| 721 | *nowildcardlen = simple_length(p); |
| 722 | /* |
| 723 | * we should have excluded the trailing slash from 'p' too, |
| 724 | * but that's one more allocation. Instead just make sure |
| 725 | * nowildcardlen does not exceed real patternlen |
| 726 | */ |
| 727 | if (*nowildcardlen > len) |
| 728 | *nowildcardlen = len; |
| 729 | if (*p == '*' && no_wildcard(p + 1)) |
| 730 | *flags |= PATTERN_FLAG_ENDSWITH; |
| 731 | *pattern = p; |
| 732 | *patternlen = len; |
| 733 | } |
| 734 | |
| 735 | int pl_hashmap_cmp(const void *cmp_data UNUSED, |
| 736 | const struct hashmap_entry *a, |
no test coverage detected