From b11aaa16d404ce7dc55de6b7338dccbf053a72bd Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jul 2016 07:17:29 +0200 Subject: Adjust to new path implementation, use to support reversibility --- build2/context.cxx | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) (limited to 'build2/context.cxx') diff --git a/build2/context.cxx b/build2/context.cxx index f756bfc..e50a74a 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -368,7 +368,7 @@ namespace build2 const dir_path* relative_base = &work; string - diag_relative (const path& p) + diag_relative (const path& p, bool cur) { if (p.string () == "-") return ""; @@ -378,11 +378,11 @@ namespace build2 if (p.absolute ()) { if (p == b) - return "."; + return cur ? "." + p.separator_string () : string (); #ifndef _WIN32 if (p == home) - return "~"; + return "~" + p.separator_string (); #endif path rb (relative (p)); @@ -396,36 +396,18 @@ namespace build2 if (p.sub (home)) { path rh (p.leaf (home)); - if (rb.string ().size () > rh.string ().size () + 2) // 2 for '~/' - return "~/" + rh.string (); + if (rb.size () > rh.size () + 2) // 2 for '~/' + return "~/" + move (rh).representation (); } } else if (rb.sub (home)) - return "~/" + rb.leaf (home).string (); + return "~/" + rb.leaf (home).representation (); #endif - return rb.string (); + return move (rb).representation (); } - return p.string (); - } - - string - diag_relative (const dir_path& d, bool cur) - { - string r (diag_relative (static_cast (d))); - - // Translate "." to empty. - // - if (!cur && d.absolute () && r == ".") - r.clear (); - - // Add trailing '/'. - // - if (!r.empty () && !dir_path::traits::is_separator (r.back ())) - r += '/'; - - return r; + return p.representation (); } // diag_do(), etc. -- cgit v1.1