Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: tools/ToolUtils.cpp

Issue 19807005: refactor duplication (shouldSkip and skip_name) into a utility function (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Forgot to add new files.. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« tools/ToolUtils.h ('K') | « tools/ToolUtils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« tools/ToolUtils.h ('K') | « tools/ToolUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698