From f30508e79dad5c9e8903214a6b9d578e10318960 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 10 Jul 2015 12:15:00 -0700 Subject: win: print right slashes in 'unknown target' message --- src/graph.cc | 7 ++++--- src/graph.h | 7 ++++++- src/ninja.cc | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/graph.cc b/src/graph.cc index 355285c..9e65675 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -347,12 +347,13 @@ bool Edge::use_console() const { return pool() == &State::kConsolePool; } -string Node::PathDecanonicalized() const { - string result = path_; +// static +string Node::PathDecanonicalized(const string& path, unsigned int slash_bits) { + string result = path; #ifdef _WIN32 unsigned int mask = 1; for (char* c = &result[0]; (c = strchr(c, '/')) != NULL;) { - if (slash_bits_ & mask) + if (slash_bits & mask) *c = '\\'; c++; mask <<= 1; diff --git a/src/graph.h b/src/graph.h index 5f8d41a..cf15123 100644 --- a/src/graph.h +++ b/src/graph.h @@ -72,8 +72,13 @@ struct Node { const string& path() const { return path_; } /// Get |path()| but use slash_bits to convert back to original slash styles. - string PathDecanonicalized() const; + string PathDecanonicalized() const { + return PathDecanonicalized(path_, slash_bits_); + } + static string PathDecanonicalized(const string& path, + unsigned int slash_bits); unsigned int slash_bits() const { return slash_bits_; } + TimeStamp mtime() const { return mtime_; } bool dirty() const { return dirty_; } diff --git a/src/ninja.cc b/src/ninja.cc index e5bf98d..3756123 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -260,7 +260,7 @@ bool NinjaMain::RebuildManifest(const char* input_file, string* err) { Node* NinjaMain::CollectTarget(const char* cpath, string* err) { string path = cpath; - unsigned int slash_bits; // Unused because this path is only used for lookup. + unsigned int slash_bits; if (!CanonicalizePath(&path, &slash_bits, err)) return NULL; @@ -287,8 +287,8 @@ Node* NinjaMain::CollectTarget(const char* cpath, string* err) { } return node; } else { - *err = "unknown target '" + path + "'"; - + *err = + "unknown target '" + Node::PathDecanonicalized(path, slash_bits) + "'"; if (path == "clean") { *err += ", did you mean 'ninja -t clean'?"; } else if (path == "help") { -- cgit v1.2.1