diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-04 18:04:50 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-04 18:04:50 +0200 |
commit | 9ef25ab2f9da89ab48ecce3fe1b8cbb0bc5f1e09 (patch) | |
tree | d378fd3b684daf8b5d517ad7f8c88a6c767ea397 /build/name.cxx | |
parent | 7eed858cac7e8ff78626bdc5d63a7f36ca8f8010 (diff) |
Treat names that end with directory separators as directories
Diffstat (limited to 'build/name.cxx')
-rw-r--r-- | build/name.cxx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/build/name.cxx b/build/name.cxx index 4ffc848..6280676 100644 --- a/build/name.cxx +++ b/build/name.cxx @@ -15,28 +15,34 @@ namespace build ostream& operator<< (ostream& os, const name& n) { - if (!n.type.empty ()) + bool ht (!n.type.empty ()); + bool hv (!n.value.empty ()); + + if (ht) os << n.type << '{'; if (!n.dir.empty ()) { string s (diag_relative_work (n.dir)); - if (s != ".") + // If both type and value are empty, there will be nothing printed. + // + if (s != "." || (!ht && !hv)) { os << s; - if (!n.value.empty () && - s.back () != path::traits::directory_separator) + // 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; } - else if (n.value.empty () && n.type.empty ()) - os << s; // Otherwise nothing gets printed. } os << n.value; - if (!n.type.empty ()) + if (ht) os << '}'; return os; |