From dfb7da35642368718ba7ac18216511bdfd496a19 Mon Sep 17 00:00:00 2001 From: mtklein Date: Sat, 14 Feb 2015 18:56:31 -0800 Subject: [PATCH] Negative numbers are not flags. tested: d dm --matrix 1 -0.3 0 0.7 1 0 0 0 1 --src gm --config matrix-8888 -w bad BUG=skia: Review URL: https://codereview.chromium.org/924343002 --- tools/flags/SkCommandLineFlags.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp index 50c193fdf2..6f1491bf1c 100644 --- a/tools/flags/SkCommandLineFlags.cpp +++ b/tools/flags/SkCommandLineFlags.cpp @@ -282,7 +282,12 @@ void SkCommandLineFlags::Parse(int argc, char** argv) { case SkFlagInfo::kString_FlagType: flag->resetStrings(); // Add all arguments until another flag is reached. - while (i+1 < argc && !SkStrStartsWith(argv[i+1], '-')) { + while (i+1 < argc) { + char* end = NULL; + (void)strtod(argv[i+1], &end); // Negative numbers aren't flags. + if (end == argv[i+1] && SkStrStartsWith(argv[i+1], '-')) { + break; + } i++; flag->append(argv[i]); }