aboutsummaryrefslogtreecommitdiff
path: root/build/path.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-08 13:27:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-08 13:27:15 +0200
commitab4421747146aa7995f0cfb1a639c9121c82c915 (patch)
treedeb08893c02ed0238f73becbbe80ede5568b946e /build/path.txx
parentd3e624ef7c0fb274e62b81c4c7bd59640770520a (diff)
Implement tracing support
Also use to-relative path translation in diagnostics.
Diffstat (limited to 'build/path.txx')
-rw-r--r--build/path.txx30
1 files changed, 28 insertions, 2 deletions
diff --git a/build/path.txx b/build/path.txx
index 6a01547..3e952d8 100644
--- a/build/path.txx
+++ b/build/path.txx
@@ -117,8 +117,12 @@ namespace build
if (m < n || path_.compare (0, n, d.path_) != 0)
throw invalid_basic_path<C> (path_);
- if (n != m)
- n++; // Skip the directory separator.
+ if (n != m
+#ifndef _WIN32
+ && !d.root ()
+#endif
+ )
+ n++; // Skip the directory separator (unless it is POSIX root).
return basic_path (path_.c_str () + n, m - n);
}
@@ -144,6 +148,28 @@ namespace build
}
template <typename C>
+ basic_path<C> basic_path<C>::
+ relative (basic_path<C> d) const
+ {
+ basic_path r;
+
+ for (;; d = d.directory ())
+ {
+ if (sub (d))
+ break;
+
+ r /= path ("..");
+
+ // Roots of the paths do not match.
+ //
+ if (d.root ())
+ throw invalid_basic_path<C> (path_);
+ }
+
+ return r / leaf (d);
+ }
+
+ template <typename C>
basic_path<C>& basic_path<C>::
normalize ()
{