aboutsummaryrefslogtreecommitdiff
path: root/build/name.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-13 15:50:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-13 15:50:17 +0200
commitace1743f7f78bb13f99553d6e97ad1beecf1ba99 (patch)
tree595bc9dad989e44f4be9a67e351219f3248dc5f0 /build/name.cxx
parent534f9d8db025d58c9ce23f3b81a37e8c34386a27 (diff)
Add separate type to represent directory paths
Diffstat (limited to 'build/name.cxx')
-rw-r--r--build/name.cxx48
1 files changed, 17 insertions, 31 deletions
diff --git a/build/name.cxx b/build/name.cxx
index ebc7372..4d30684 100644
--- a/build/name.cxx
+++ b/build/name.cxx
@@ -15,42 +15,28 @@ namespace build
ostream&
operator<< (ostream& os, const name& n)
{
- bool ht (!n.type.empty ());
- bool hv (!n.value.empty ());
- bool hd (false);
-
- if (ht)
+ // If the value is empty, then we want to print the directory
+ // inside {}, e.g., dir{bar/}, not bar/dir{}. We also want to
+ // print {} for an empty name.
+ //
+ bool d (!n.dir.empty ());
+ bool v (!n.value.empty ());
+ bool t (!n.type.empty () || (!d && !v));
+
+ if (v)
+ os << n.dir;
+
+ if (t)
os << n.type << '{';
- if (!n.dir.empty ())
- {
- string s (diag_relative (n.dir));
-
- // If both type and value are empty, there will be nothing printed.
- //
- if (s != "." || (!ht && !hv))
- {
- os << s;
-
- // Add the directory separator unless it is already there
- // or we have type but no value. The idea is to print foo/
- // or dir{foo}.
- //
- if (s.back () != path::traits::directory_separator && (hv || !ht))
- os << path::traits::directory_separator;
+ if (v)
+ os << n.value;
+ else
+ os << n.dir;
- hd = true;
- }
- }
-
- os << n.value;
-
- if (ht)
+ if (t)
os << '}';
- if (!ht && !hv && !hd)
- os << "{}"; // Nothing got printed.
-
return os;
}