Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sgraham committed Sep 20, 2012
1 parent 21046b4 commit 32f8ed1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/msvc_helper-win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ bool EndsWith(const string& input, const string& needle) {
input.substr(input.size() - needle.size()) == needle);
}

void Replace(string& in_out, const string& find, const string& replace) {
string Replace(const string& input, const string& find, const string& replace) {
string result = input;
size_t start_pos = 0;
while ((start_pos = in_out.find(find, start_pos)) != std::string::npos) {
in_out.replace(start_pos, find.length(), replace);
while ((start_pos = result.find(find, start_pos)) != string::npos) {
result.replace(start_pos, find.length(), replace);
start_pos += replace.length();
}
return result;
}

string Escape(const string& path) {
string result = path;
// TODO: very strange format, should we escape \ too?
//Replace(result, "\\", "\\\\");
Replace(result, " ", "\\ ");
return result;
string EscapeForDepfile(const string& path) {
// Depfiles don't escape single \ because they're common in paths.
return Replace(path, " ", "\\ ");
}

} // anonymous namespace
Expand Down Expand Up @@ -182,7 +181,7 @@ int CLWrapper::Run(const string& command, string* extra_output) {
vector<string> CLWrapper::GetEscapedResult() {
vector<string> result;
for (set<string>::iterator i = includes_.begin(); i != includes_.end(); ++i) {
result.push_back(Escape(*i));
result.push_back(EscapeForDepfile(*i));
}
return result;
}

0 comments on commit 32f8ed1

Please sign in to comment.