67 {
68 size_t testLen = strlen(
name);
69 bool anyExclude =
count == 0;
70 for (
size_t i = 0; i <
count; ++i) {
71 const char* matchName = rules[i];
72 size_t matchLen = strlen(matchName);
73 bool matchExclude, matchStart, matchEnd;
74 if ((matchExclude = matchName[0] == '~')) {
75 anyExclude = true;
76 matchName++;
77 matchLen--;
78 }
79 if ((matchStart = matchName[0] == '^')) {
80 matchName++;
81 matchLen--;
82 }
83 if ((matchEnd = matchName[matchLen - 1] == '$')) {
84 matchLen--;
85 }
86 if (matchStart ? (!matchEnd || matchLen == testLen)
87 && strncmp(
name, matchName, matchLen) == 0
88 : matchEnd ? matchLen <= testLen
89 && strncmp(
name + testLen - matchLen, matchName, matchLen) == 0
90 : strstr(
name, matchName) != nullptr) {
91 return matchExclude;
92 }
93 }
94 return !anyExclude;
95}