From 9ef25ab2f9da89ab48ecce3fe1b8cbb0bc5f1e09 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 4 Mar 2015 18:04:50 +0200 Subject: Treat names that end with directory separators as directories --- build/name.cxx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'build/name.cxx') 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; -- cgit v1.1