From 9a218d7909ad4747fb4de31842bd97f6f4fd3709 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Fri, 9 Sep 2011 14:09:25 -0700 Subject: [PATCH] verify -k param is numeric Fixes issue #85. --- src/build.cc | 4 ++-- src/ninja.cc | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/build.cc b/src/build.cc index e0118ef..9adce8f 100644 --- a/src/build.cc +++ b/src/build.cc @@ -439,8 +439,8 @@ bool Builder::Build(string* err) { --pending_commands; FinishEdge(edge, success, output); if (!success) { - if (--failures_allowed < 0) { - if (config_.swallow_failures > 0) + if (failures_allowed-- == 0) { + if (config_.swallow_failures != 0) *err = "subcommands failed"; else *err = "subcommand failed"; diff --git a/src/ninja.cc b/src/ninja.cc index fbee6d9..ae9c534 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -383,11 +383,17 @@ int main(int argc, char** argv) { case 'j': config.parallelism = atoi(optarg); break; - case 'k': + case 'k': { + char* end; + int value = strtol(optarg, &end, 10); + if (*end != 0) + Fatal("-k parameter not numeric; did you mean -k0?"); + // We want to go until N jobs fail, which means we should ignore // the first N-1 that fail and then stop. - config.swallow_failures = atoi(optarg) - 1; + config.swallow_failures = value - 1; break; + } case 'n': config.dry_run = true; break; -- 2.7.4