diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-25 15:14:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-25 15:14:06 +0200 |
commit | 9c02d307d69faa6e3c7056d8e07f16c75c189f92 (patch) | |
tree | ba8e94ab0d63194253f88365ea8993c797f30de6 /build | |
parent | cd75e06a87aa74aa6968113107afa53d401d20bc (diff) |
Recognize common cases (., .., and dir{}) when deriving out_base
Diffstat (limited to 'build')
-rw-r--r-- | build/b.cxx | 23 |
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 ()) |