summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Graham <scottmg@chromium.org>2012-09-20 16:36:37 (GMT)
committerScott Graham <scottmg@chromium.org>2012-09-20 16:36:37 (GMT)
commit32f8ed1178089a4c3b88b95c717e0399d9da957b (patch)
tree5018805546561372017636f72e7a8f852d2eacac
parent21046b4a3e153754ab8f632c0b65ec1c61f7b828 (diff)
downloadNinja-32f8ed1178089a4c3b88b95c717e0399d9da957b.zip
Ninja-32f8ed1178089a4c3b88b95c717e0399d9da957b.tar.gz
Ninja-32f8ed1178089a4c3b88b95c717e0399d9da957b.tar.bz2
review fixes
-rw-r--r--src/msvc_helper-win32.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/msvc_helper-win32.cc b/src/msvc_helper-win32.cc
index e2a121d..0eb807a 100644
--- a/src/msvc_helper-win32.cc
+++ b/src/msvc_helper-win32.cc
@@ -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
@@ -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;
}