summaryrefslogtreecommitdiffstats
path: root/src/util.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2011-10-06 00:51:06 (GMT)
committerEvan Martin <martine@danga.com>2011-10-06 00:51:06 (GMT)
commite54d2b6c8bbb78b238160c7f31ae8515c15183d9 (patch)
tree2566a133dfda2675b55c896dbf22f95a7bbfced5 /src/util.cc
parent06ab305be33ff4899016c746ee8a3557291ebe09 (diff)
downloadNinja-e54d2b6c8bbb78b238160c7f31ae8515c15183d9.zip
Ninja-e54d2b6c8bbb78b238160c7f31ae8515c15183d9.tar.gz
Ninja-e54d2b6c8bbb78b238160c7f31ae8515c15183d9.tar.bz2
make CanonicalizePath report an error on empty path
Fixes part of issue 121, but the fix exposed a further issue.
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util.cc b/src/util.cc
index 0ad470e..e2b20d6 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -64,10 +64,15 @@ void Error(const char* msg, ...) {
fprintf(stderr, "\n");
}
-void CanonicalizePath(string* path) {
+bool CanonicalizePath(string* path, string* err) {
// WARNING: this function is performance-critical; please benchmark
// any changes you make to it.
+ if (path->empty()) {
+ *err = "empty path";
+ return false;
+ }
+
const int kMaxPathComponents = 30;
char* components[kMaxPathComponents];
int component_count = 0;
@@ -120,6 +125,7 @@ void CanonicalizePath(string* path) {
}
path->resize(dst - path->c_str() - 1);
+ return true;
}
int MakeDir(const string& path) {