Simplify running edges status

Store the number of running edges instead of trying to compute it
from the started and finshed edge counts, which may be different
for starting and ending status messages.  Allows removing the status
parameter to PrintStatus and the EdgeStatus enum.
diff --git a/src/build.cc b/src/build.cc
index f04e2f2..3b1a3f4 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -81,7 +81,7 @@
 
 BuildStatus::BuildStatus(const BuildConfig& config)
     : config_(config),
-      started_edges_(0), finished_edges_(0), total_edges_(0),
+      started_edges_(0), finished_edges_(0), total_edges_(0), running_edges_(0),
       time_millis_(0), progress_status_format_(NULL),
       current_rate_(config.parallelism) {
   // Don't do anything fancy in verbose mode.
@@ -103,7 +103,7 @@
   time_millis_ = start_time_millis;
 
   if (edge->use_console() || printer_.is_smart_terminal())
-    PrintStatus(edge, start_time_millis, kEdgeStarted);
+    PrintStatus(edge, start_time_millis);
 
   if (edge->use_console())
     printer_.SetConsoleLocked(true);
@@ -122,7 +122,12 @@
     return;
 
   if (!edge->use_console())
-    PrintStatus(edge, end_time_millis, kEdgeFinished);
+    PrintStatus(edge, end_time_millis);
+
+  // Update running_edges_ after PrintStatus so that the number of running
+  // edges doesn't oscillate between config.parallelism_ and
+  // config.parallelism_ - 1.
+  --running_edges_;
 
   // Print the command that is spewing before printing its output.
   if (!success) {
@@ -185,6 +190,9 @@
 }
 
 void BuildStatus::BuildStarted() {
+  started_edges_ = 0;
+  finished_edges_ = 0;
+  running_edges_ = 0;
 }
 
 void BuildStatus::BuildFinished() {
@@ -193,7 +201,7 @@
 }
 
 string BuildStatus::FormatProgressStatus(
-    const char* progress_status_format, int64_t time, EdgeStatus status) const {
+    const char* progress_status_format, int64_t time) const {
   string out;
   char buf[32];
   for (const char* s = progress_status_format; *s != '\0'; ++s) {
@@ -218,11 +226,7 @@
 
         // Running edges.
       case 'r': {
-        int running_edges = started_edges_ - finished_edges_;
-        // count the edge that just finished as a running edge
-        if (status == kEdgeFinished)
-          running_edges++;
-        snprintf(buf, sizeof(buf), "%d", running_edges);
+        snprintf(buf, sizeof(buf), "%d", running_edges_);
         out += buf;
         break;
       }
@@ -278,7 +282,7 @@
   return out;
 }
 
-void BuildStatus::PrintStatus(const Edge* edge, int64_t time, EdgeStatus status) {
+void BuildStatus::PrintStatus(const Edge* edge, int64_t time) {
   if (config_.verbosity == BuildConfig::QUIET)
     return;
 
@@ -288,7 +292,7 @@
   if (to_print.empty() || force_full_command)
     to_print = edge->GetBinding("command");
 
-  to_print = FormatProgressStatus(progress_status_format_, time, status) + to_print;
+  to_print = FormatProgressStatus(progress_status_format_, time) + to_print;
 
   printer_.Print(to_print,
                  force_full_command ? LinePrinter::FULL : LinePrinter::ELIDE);
diff --git a/src/build.h b/src/build.h
index 6935086..265723a 100644
--- a/src/build.h
+++ b/src/build.h
@@ -252,25 +252,20 @@
   void BuildStarted();
   void BuildFinished();
 
-  enum EdgeStatus {
-    kEdgeStarted,
-    kEdgeFinished,
-  };
-
   /// Format the progress status string by replacing the placeholders.
   /// See the user manual for more information about the available
   /// placeholders.
   /// @param progress_status_format The format of the progress status.
   /// @param status The status of the edge.
   std::string FormatProgressStatus(const char* progress_status_format,
-                                   int64_t time, EdgeStatus status) const;
+                                   int64_t time) const;
 
  private:
-  void PrintStatus(const Edge* edge, int64_t time, EdgeStatus status);
+  void PrintStatus(const Edge* edge, int64_t time);
 
   const BuildConfig& config_;
 
-  int started_edges_, finished_edges_, total_edges_;
+  int started_edges_, finished_edges_, total_edges_, running_edges_;
   int64_t time_millis_;
 
   /// Prints progress output.
diff --git a/src/build_test.cc b/src/build_test.cc
index 4ccb2c4..1baec65 100644
--- a/src/build_test.cc
+++ b/src/build_test.cc
@@ -1400,8 +1400,7 @@
   ASSERT_EQ("", err);
   EXPECT_TRUE(builder_.Build(&err));
   ASSERT_EQ("", err);
-  EXPECT_EQ("[3/3]", builder_.status_->FormatProgressStatus("[%s/%t]", 0,
-      BuildStatus::kEdgeStarted));
+  EXPECT_EQ("[3/3]", builder_.status_->FormatProgressStatus("[%s/%t]", 0));
   command_runner_.commands_ran_.clear();
   state_.Reset();
 
@@ -1843,14 +1842,12 @@
   status_.BuildStarted();
   // Before any task is done, the elapsed time must be zero.
   EXPECT_EQ("[%/e0.000]",
-            status_.FormatProgressStatus("[%%/e%e]", 0,
-                BuildStatus::kEdgeStarted));
+            status_.FormatProgressStatus("[%%/e%e]", 0));
 }
 
 TEST_F(BuildTest, StatusFormatReplacePlaceholder) {
   EXPECT_EQ("[%/s0/t0/r0/u0/f0]",
-            status_.FormatProgressStatus("[%%/s%s/t%t/r%r/u%u/f%f]", 0,
-                BuildStatus::kEdgeStarted));
+            status_.FormatProgressStatus("[%%/s%s/t%t/r%r/u%u/f%f]", 0));
 }
 
 TEST_F(BuildTest, FailedDepsParse) {