Chromium Code Reviews| Index: tools/flags/SkCommandLineFlags.cpp |
| diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp |
| index 656a00a76d8f57c226d593e5cafabf6f6bbee201..9b31b657e56f435180b91653bae3edc2f148e3c7 100644 |
| --- a/tools/flags/SkCommandLineFlags.cpp |
| +++ b/tools/flags/SkCommandLineFlags.cpp |
| @@ -8,6 +8,8 @@ |
| #include "SkCommandLineFlags.h" |
| #include "SkTDArray.h" |
| +DEFINE_string(undefok, "", "Silently ignore unknown flags listed here instead of crashing."); |
|
scroggo
2014/03/25 20:09:06
Maybe specify that the use of this flag must follo
|
| + |
| bool SkFlagInfo::CreateStringFlag(const char* name, const char* shortName, |
| SkCommandLineFlags::StringArray* pStrings, |
| const char* defaultValue, const char* helpString) { |
| @@ -285,8 +287,14 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { |
| flag = flag->next(); |
| } |
| if (!flagMatched) { |
| - SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]); |
| - exit(-1); |
| + SkString stripped(argv[i]); |
| + while (stripped.startsWith('-')) { |
| + stripped.remove(0, 1); |
| + } |
| + if (!FLAGS_undefok.contains(stripped.c_str())) { |
| + SkDebugf("Got unknown flag \"%s\". Exiting.\n", argv[i]); |
| + exit(-1); |
| + } |
| } |
| } |
| } |