OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |