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 |
11 DEFINE_string(undefok, "", "Silently ignore unknown flags listed here instead of
crashing."); | 11 DEFINE_bool(undefok, false, "Silently ignore unknown flags instead of crashing."
); |
12 | 12 |
13 bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, | 13 bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, |
14 SkCommandLineFlags::StringArray* pStrings, | 14 SkCommandLineFlags::StringArray* pStrings, |
15 const char* defaultValue, const char* helpStri
ng) { | 15 const char* defaultValue, const char* helpStri
ng) { |
16 SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType
, helpString)); | 16 SkFlagInfo* info = SkNEW_ARGS(SkFlagInfo, (name, shortName, kString_FlagType
, helpString)); |
17 info->fDefaultString.set(defaultValue); | 17 info->fDefaultString.set(defaultValue); |
18 | 18 |
19 info->fStrings = pStrings; | 19 info->fStrings = pStrings; |
20 SetDefaultStrings(pStrings, defaultValue); | 20 SetDefaultStrings(pStrings, defaultValue); |
21 return true; | 21 return true; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 break; | 285 break; |
286 } | 286 } |
287 flag = flag->next(); | 287 flag = flag->next(); |
288 } | 288 } |
289 if (!flagMatched) { | 289 if (!flagMatched) { |
290 SkString stripped(argv[i]); | 290 SkString stripped(argv[i]); |
291 while (stripped.startsWith('-')) { | 291 while (stripped.startsWith('-')) { |
292 stripped.remove(0, 1); | 292 stripped.remove(0, 1); |
293 } | 293 } |
294 if (!FLAGS_undefok.contains(stripped.c_str())) { | 294 if (!FLAGS_undefok) { |
295 SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]); | 295 SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]); |
296 exit(-1); | 296 exit(-1); |
297 } | 297 } |
298 } | 298 } |
299 } | 299 } |
300 } | 300 } |
301 // Since all of the flags have been set, release the memory used by each | 301 // Since all of the flags have been set, release the memory used by each |
302 // flag. FLAGS_x can still be used after this. | 302 // flag. FLAGS_x can still be used after this. |
303 SkFlagInfo* flag = gHead; | 303 SkFlagInfo* flag = gHead; |
304 gHead = NULL; | 304 gHead = NULL; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 347 } |
348 | 348 |
349 } // namespace | 349 } // namespace |
350 | 350 |
351 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const
char* name) { | 351 bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const
char* name) { |
352 return ShouldSkipImpl(strings, name); | 352 return ShouldSkipImpl(strings, name); |
353 } | 353 } |
354 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name
) { | 354 bool SkCommandLineFlags::ShouldSkip(const StringArray& strings, const char* name
) { |
355 return ShouldSkipImpl(strings, name); | 355 return ShouldSkipImpl(strings, name); |
356 } | 356 } |
OLD | NEW |