summaryrefslogtreecommitdiffstats
path: root/src/includes_normalize-win32.cc
diff options
context:
space:
mode:
authorScott Graham <scottmg@chromium.org>2015-06-09 00:17:55 (GMT)
committerScott Graham <scottmg@chromium.org>2015-06-09 00:17:55 (GMT)
commit1493c6a0b0f779294b870ae8ee4a8515087ac64e (patch)
treef46ba40a191693e81d0ee3c55ce0eea2b127553d /src/includes_normalize-win32.cc
parenta2d1cf2f26bdd7a326a3ef6186ee507fd87868d0 (diff)
downloadNinja-1493c6a0b0f779294b870ae8ee4a8515087ac64e.zip
Ninja-1493c6a0b0f779294b870ae8ee4a8515087ac64e.tar.gz
Ninja-1493c6a0b0f779294b870ae8ee4a8515087ac64e.tar.bz2
push error to caller and abort on failure
Diffstat (limited to 'src/includes_normalize-win32.cc')
-rw-r--r--src/includes_normalize-win32.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/includes_normalize-win32.cc b/src/includes_normalize-win32.cc
index 066f512..ca35012 100644
--- a/src/includes_normalize-win32.cc
+++ b/src/includes_normalize-win32.cc
@@ -94,19 +94,18 @@ string IncludesNormalize::Relativize(StringPiece path, const string& start) {
return Join(rel_list, '/');
}
-string IncludesNormalize::Normalize(const string& input,
- const char* relative_to) {
+bool IncludesNormalize::Normalize(const string& input, const char* relative_to,
+ string* result, string* err) {
char copy[_MAX_PATH + 1];
size_t len = input.size();
if (len > _MAX_PATH) {
- Warning("path too long '%s'\n", input.c_str());
- return input;
+ *err = "path too long";
+ return false;
}
strncpy(copy, input.c_str(), input.size() + 1);
- string err;
unsigned int slash_bits;
- if (!CanonicalizePath(copy, &len, &slash_bits, &err))
- Warning("couldn't canonicalize '%s': %s\n", input.c_str(), err.c_str());
+ if (!CanonicalizePath(copy, &len, &slash_bits, err))
+ return false;
StringPiece partially_fixed(copy, len);
string curdir;
@@ -114,7 +113,10 @@ string IncludesNormalize::Normalize(const string& input,
curdir = AbsPath(".");
relative_to = curdir.c_str();
}
- if (!SameDrive(partially_fixed, relative_to))
- return partially_fixed.AsString();
- return Relativize(partially_fixed, relative_to);
+ if (!SameDrive(partially_fixed, relative_to)) {
+ *result = partially_fixed.AsString();
+ return true;
+ }
+ *result = Relativize(partially_fixed, relative_to);
+ return true;
}