OLD | NEW |
(Empty) | |
| 1 #include "ToolUtils.h" |
| 2 |
| 3 bool shouldSkip(const SkTDArray<const char*>& strings, const char* name) { |
| 4 int count = strings.count(); |
| 5 size_t testLen = strlen(name); |
| 6 bool anyExclude = count == 0; |
| 7 for (int i = 0; i < strings.count(); ++i) { |
| 8 const char* matchName = strings[i]; |
| 9 size_t matchLen = strlen(matchName); |
| 10 bool matchExclude, matchStart, matchEnd; |
| 11 if ((matchExclude = matchName[0] == '~')) { |
| 12 anyExclude = true; |
| 13 matchName++; |
| 14 matchLen--; |
| 15 } |
| 16 if ((matchStart = matchName[0] == '^')) { |
| 17 matchName++; |
| 18 matchLen--; |
| 19 } |
| 20 if ((matchEnd = matchName[matchLen - 1] == '$')) { |
| 21 matchLen--; |
| 22 } |
| 23 if (matchStart ? (!matchEnd || matchLen == testLen) |
| 24 && strncmp(name, matchName, matchLen) == 0 |
| 25 : matchEnd ? matchLen <= testLen |
| 26 && strncmp(name + testLen - matchLen, matchName, matchLen) == 0 |
| 27 : strstr(name, matchName) != 0) { |
| 28 return matchExclude; |
| 29 } |
| 30 } |
| 31 return !anyExclude; |
| 32 } |
OLD | NEW |