diff options
author | Brian Osman <brianosman@google.com> | 2016-10-24 14:53:08 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-24 19:32:55 +0000 |
commit | 49f57123eb053b82c95078592ad82f2a628964f7 (patch) | |
tree | 9ee54e8a960729486e17ab26826da3bbc18063c2 /tools/flags | |
parent | 3d3a65c488162ef1db0b35adf3235d012b04c88d (diff) |
Populate ALL copies of a command line flag during parsing
Now that we're declaring flags statically per-tool, we were only
setting the value on one of them (randomly) in the linked list.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3881
Change-Id: I448cb7f42ee01a16daa65986b14aee9f1a2a3588
Reviewed-on: https://skia-review.googlesource.com/3881
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools/flags')
-rw-r--r-- | tools/flags/SkCommandLineFlags.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index fd7c8ff09b..bbbc397c2b 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -288,11 +288,18 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { helpPrinted = true; } if (!helpPrinted) { - bool flagMatched = false; + SkFlagInfo* matchedFlag = nullptr; SkFlagInfo* flag = gHead; + int startI = i; while (flag != nullptr) { - if (flag->match(argv[i])) { - flagMatched = true; + if (flag->match(argv[startI])) { + i = startI; + if (matchedFlag) { + // Don't redefine the same flag with different types. + SkASSERT(matchedFlag->getFlagType() == flag->getFlagType()); + } else { + matchedFlag = flag; + } switch (flag->getFlagType()) { case SkFlagInfo::kBool_FlagType: // Can be handled by match, above, but can also be set by the next @@ -330,11 +337,10 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { default: SkDEBUGFAIL("Invalid flag type"); } - break; } flag = flag->next(); } - if (!flagMatched) { + if (!matchedFlag) { #if defined(SK_BUILD_FOR_MAC) if (SkStrStartsWith(argv[i], "NSDocumentRevisions") || SkStrStartsWith(argv[i], "-NSDocumentRevisions")) { |