aboutsummaryrefslogtreecommitdiff
path: root/build/diagnostics.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-04 16:33:51 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-04 16:33:51 +0200
commit7eed858cac7e8ff78626bdc5d63a7f36ca8f8010 (patch)
tree225dd25e354c4f6234dbf2c02608ec6545dcd688 /build/diagnostics.cxx
parentc76fe316122969986103d243706dc7fa7ab6ddc1 (diff)
Move roots and bases to appropriate scopes
Diffstat (limited to 'build/diagnostics.cxx')
-rw-r--r--build/diagnostics.cxx25
1 files changed, 21 insertions, 4 deletions
diff --git a/build/diagnostics.cxx b/build/diagnostics.cxx
index 34bbee8..f5802de 100644
--- a/build/diagnostics.cxx
+++ b/build/diagnostics.cxx
@@ -21,14 +21,31 @@ namespace build
if (p == work)
return ".";
- path rp (relative_work (p));
+#ifndef _WIN32
+ if (p == home)
+ return "~";
+#endif
+
+ path rw (relative_work (p));
#ifndef _WIN32
- if (rp.absolute () && rp.sub (home))
- return "~/" + rp.leaf (home).string ();
+ if (rw.relative ())
+ {
+ // See if the original path with the ~/ shortcut is better
+ // that the relative to work.
+ //
+ if (p.sub (home))
+ {
+ path rh (p.leaf (home));
+ if (rw.string ().size () > rh.string ().size () + 2) // 2 for '~/'
+ return "~/" + rh.string ();
+ }
+ }
+ else if (rw.sub (home))
+ return "~/" + rw.leaf (home).string ();
#endif
- return rp.string ();
+ return rw.string ();
}
return p.string ();