aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-03-25 15:14:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-03-25 15:14:06 +0200
commit9c02d307d69faa6e3c7056d8e07f16c75c189f92 (patch)
treeba8e94ab0d63194253f88365ea8993c797f30de6
parentcd75e06a87aa74aa6968113107afa53d401d20bc (diff)
Recognize common cases (., .., and dir{}) when deriving out_base
-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 ())