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

Side by Side Diff: tools/flags/SkCommandLineFlags.cpp

Issue 19807005: refactor duplication (shouldSkip and skip_name) into a utility function (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Forced linking is required, shouldn't have removed it Created 7 years, 4 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
« no previous file with comments | « tools/flags/SkCommandLineFlags.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
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkTDArray.h" 9 #include "SkTDArray.h"
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 gHead = NULL; 296 gHead = NULL;
297 while (flag != NULL) { 297 while (flag != NULL) {
298 SkFlagInfo* next = flag->next(); 298 SkFlagInfo* next = flag->next();
299 SkDELETE(flag); 299 SkDELETE(flag);
300 flag = next; 300 flag = next;
301 } 301 }
302 if (helpPrinted) { 302 if (helpPrinted) {
303 exit(0); 303 exit(0);
304 } 304 }
305 } 305 }
306
307 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) {
308 int count = strings.count();
309 size_t testLen = strlen(name);
310 bool anyExclude = count == 0;
311 for (int i = 0; i < strings.count(); ++i) {
312 const char* matchName = strings[i];
313 size_t matchLen = strlen(matchName);
314 bool matchExclude, matchStart, matchEnd;
315 if ((matchExclude = matchName[0] == '~')) {
316 anyExclude = true;
317 matchName++;
318 matchLen--;
319 }
320 if ((matchStart = matchName[0] == '^')) {
321 matchName++;
322 matchLen--;
323 }
324 if ((matchEnd = matchName[matchLen - 1] == '$')) {
325 matchLen--;
326 }
327 if (matchStart ? (!matchEnd || matchLen == testLen)
328 && strncmp(name, matchName, matchLen) == 0
329 : matchEnd ? matchLen <= testLen
330 && strncmp(name + testLen - matchLen, matchName, matchLen) == 0
331 : strstr(name, matchName) != 0) {
332 return matchExclude;
333 }
334 }
335 return !anyExclude;
336 }
OLDNEW
« no previous file with comments | « tools/flags/SkCommandLineFlags.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698