| Index: tools/ToolUtils.cpp
|
| diff --git a/tools/ToolUtils.cpp b/tools/ToolUtils.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..45dae438ad36647e9aa073a950dac33700707326
|
| --- /dev/null
|
| +++ b/tools/ToolUtils.cpp
|
| @@ -0,0 +1,32 @@
|
| +#include "ToolUtils.h"
|
| +
|
| +bool shouldSkip(const SkTDArray<const char*>& strings, const char* name) {
|
| + int count = strings.count();
|
| + size_t testLen = strlen(name);
|
| + bool anyExclude = count == 0;
|
| + for (int i = 0; i < strings.count(); ++i) {
|
| + const char* matchName = strings[i];
|
| + size_t matchLen = strlen(matchName);
|
| + bool matchExclude, matchStart, matchEnd;
|
| + if ((matchExclude = matchName[0] == '~')) {
|
| + anyExclude = true;
|
| + matchName++;
|
| + matchLen--;
|
| + }
|
| + if ((matchStart = matchName[0] == '^')) {
|
| + matchName++;
|
| + matchLen--;
|
| + }
|
| + if ((matchEnd = matchName[matchLen - 1] == '$')) {
|
| + matchLen--;
|
| + }
|
| + if (matchStart ? (!matchEnd || matchLen == testLen)
|
| + && strncmp(name, matchName, matchLen) == 0
|
| + : matchEnd ? matchLen <= testLen
|
| + && strncmp(name + testLen - matchLen, matchName, matchLen) == 0
|
| + : strstr(name, matchName) != 0) {
|
| + return matchExclude;
|
| + }
|
| + }
|
| + return !anyExclude;
|
| +}
|
|
|