summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/build.cc4
-rw-r--r--src/msvc_helper-win32.cc2
-rw-r--r--src/msvc_helper.h5
3 files changed, 8 insertions, 3 deletions
diff --git a/src/build.cc b/src/build.cc
index fcde626..e4820d0 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -849,8 +849,10 @@ bool Builder::ExtractDeps(CommandRunner::Result* result,
#ifdef _WIN32
if (deps_type == "msvc") {
CLParser parser;
- if (!parser.Parse(result->output, deps_prefix, &result->output, err))
+ string output;
+ if (!parser.Parse(result->output, deps_prefix, &output, err))
return false;
+ result->output = output;
for (set<string>::iterator i = parser.includes_.begin();
i != parser.includes_.end(); ++i) {
// ~0 is assuming that with MSVC-parsed headers, it's ok to always make
diff --git a/src/msvc_helper-win32.cc b/src/msvc_helper-win32.cc
index 78b79b0..d516240 100644
--- a/src/msvc_helper-win32.cc
+++ b/src/msvc_helper-win32.cc
@@ -15,6 +15,7 @@
#include "msvc_helper.h"
#include <algorithm>
+#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <windows.h>
@@ -85,6 +86,7 @@ bool CLParser::FilterInputFilename(string line) {
bool CLParser::Parse(const string& output, const string& deps_prefix,
string* filtered_output, string* err) {
// Loop over all lines in the output to process them.
+ assert(&output != filtered_output);
size_t start = 0;
while (start < output.size()) {
size_t end = output.find_first_of("\r\n", start);
diff --git a/src/msvc_helper.h b/src/msvc_helper.h
index 08c0ad5..30f87f3 100644
--- a/src/msvc_helper.h
+++ b/src/msvc_helper.h
@@ -40,8 +40,9 @@ struct CLParser {
/// Exposed for testing.
static bool FilterInputFilename(string line);
- /// Parse the full output of cl, returning the output (if any) that
- /// should printed. Returns true on success, or false with err filled.
+ /// Parse the full output of cl, filling filtered_output with the text that
+ /// should be printed (if any). Returns true on success, or false with err
+ /// filled. output must not be the same object as filtered_object.
bool Parse(const string& output, const string& deps_prefix,
string* filtered_output, string* err);