aboutsummaryrefslogtreecommitdiff
path: root/build2/context.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-28 07:17:29 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-28 13:53:22 +0200
commitb11aaa16d404ce7dc55de6b7338dccbf053a72bd (patch)
treebe5a63a170f9de7318e91d79c4784badb8a4488f /build2/context.cxx
parentad7d4bd0722aa70ba634900cebf93a1b1814fed9 (diff)
Adjust to new path implementation, use to support reversibility
Diffstat (limited to 'build2/context.cxx')
-rw-r--r--build2/context.cxx34
1 files changed, 8 insertions, 26 deletions
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 "<stdin>";
@@ -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<const path&> (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.