aboutsummaryrefslogtreecommitdiff
path: root/build/b.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build/b.cxx')
-rw-r--r--build/b.cxx23
1 files changed, 17 insertions, 6 deletions
diff --git a/build/b.cxx b/build/b.cxx
index 3a37b68..0443b4b 100644
--- a/build/b.cxx
+++ b/build/b.cxx
@@ -318,14 +318,25 @@ main (int argc, char* argv[])
path out_base (tn.dir);
if (out_base.empty ())
{
- // See if there is a directory part in value. We cannot
- // assume it is a valid filesystem name so we will have
- // to do the splitting manually.
+ const string& v (tn.value);
+
+ // Handle a few common cases as special: empty name, '.',
+ // '..', as well as dir{foo/bar} (without trailing '/').
+ // This code must be consistent with target_type_map::find().
//
- path::size_type i (path::traits::rfind_separator (tn.value));
+ if (v.empty () || v == "." || v == ".." || tn.type == "dir")
+ out_base = path (v);
+ else
+ {
+ // See if there is a directory part in value. We cannot
+ // assume it is a valid filesystem name so we will have
+ // to do the splitting manually.
+ //
+ path::size_type i (path::traits::rfind_separator (v));
- if (i != string::npos)
- out_base = path (tn.value, i != 0 ? i : 1); // Special case: "/".
+ if (i != string::npos)
+ out_base = path (v, i != 0 ? i : 1); // Special case: "/".
+ }
}
if (out_base.relative ())