aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/algorithm.cxx2
-rw-r--r--build/path-map4
-rw-r--r--build/prefix-map59
-rw-r--r--build/target.cxx8
4 files changed, 34 insertions, 39 deletions
diff --git a/build/algorithm.cxx b/build/algorithm.cxx
index 4c3ae08..5be5cad 100644
--- a/build/algorithm.cxx
+++ b/build/algorithm.cxx
@@ -54,7 +54,7 @@ namespace build
const string& n (i->first);
const rule& ru (i->second);
- void* m;
+ void* m (nullptr);
{
auto g (
make_exception_guard (
diff --git a/build/path-map b/build/path-map
index c422dde..ee2dd79 100644
--- a/build/path-map
+++ b/build/path-map
@@ -29,12 +29,12 @@ namespace build
{
typedef basic_path<C> K;
- typedef C char_type;
+ typedef C delimiter_type;
typedef std::basic_string<C> string_type;
typedef compare_prefix<std::basic_string<C>> base;
explicit
- compare_prefix (C d): base (d) {}
+ compare_prefix (delimiter_type d): base (d) {}
bool
operator() (const K& x, const K& y) const
diff --git a/build/prefix-map b/build/prefix-map
index d98c842..5214fae 100644
--- a/build/prefix-map
+++ b/build/prefix-map
@@ -12,6 +12,19 @@
namespace build
{
+ // A map of hierarchical "paths", e.g., 'foo.bar' or 'foo/bar' with
+ // the ability to retrieve a range of entries that have a specific
+ // prefix. The '.' and '/' above are the delimiter characters.
+ //
+ // Note that as a special rule, the default implementation of
+ // compare_prefix treats empty key as everyone's prefix even if
+ // the paths don't start with the delimiter (useful to represent
+ // a "root path").
+ //
+ // Implementation-wise, the idea is to pretend that each key ends
+ // with the delimiter. This way we automatically avoid matching
+ // 'foobar' as having a prefix 'foo'.
+ //
template <typename K>
struct compare_prefix;
@@ -20,12 +33,12 @@ namespace build
{
typedef std::basic_string<C> K;
- typedef C char_type;
+ typedef C delimiter_type;
typedef typename K::size_type size_type;
typedef typename K::traits_type traits_type;
explicit
- compare_prefix (C d): d_ (d) {}
+ compare_prefix (delimiter_type d): d_ (d) {}
bool
operator() (const K& x, const K& y) const
@@ -71,22 +84,9 @@ namespace build
}
private:
- C d_;
+ delimiter_type d_;
};
- // A map of hierarchical "paths", e.g., 'foo.bar' or 'foo/bar' with
- // the ability to retrieve a range of entries that have a specific
- // prefix. The '.' and '/' above are the delimiter characters.
- //
- // Note that as a special rule, the default implementation of
- // compare_prefix treats empty key as everyone's prefix even if
- // the paths don't start with the delimiter (useful to represent
- // a "root path").
- //
- // Implementation-wise, the idea is to pretend that each key ends
- // with the delimiter. This way we automatically avoid matching
- // 'foobar' as having a prefix 'foo'.
- //
template <typename M>
struct prefix_map_common: M
{
@@ -94,18 +94,17 @@ namespace build
typedef typename map_type::key_type key_type;
typedef typename map_type::value_type value_type;
typedef typename map_type::key_compare compare_type;
- typedef typename compare_type::char_type char_type;
+ typedef typename compare_type::delimiter_type delimiter_type;
typedef typename map_type::iterator iterator;
typedef typename map_type::const_iterator const_iterator;
explicit
- prefix_map_common (char_type delimiter)
- : map_type (compare_type (delimiter)) {}
+ prefix_map_common (delimiter_type d)
+ : map_type (compare_type (d)) {}
- prefix_map_common (std::initializer_list<value_type> init,
- char_type delimiter)
- : map_type (std::move (init), compare_type (delimiter)) {}
+ prefix_map_common (std::initializer_list<value_type> i, delimiter_type d)
+ : map_type (std::move (i), compare_type (d)) {}
std::pair<iterator, iterator>
find_prefix (const key_type&);
@@ -114,30 +113,24 @@ namespace build
find_prefix (const key_type&) const;
};
- template <typename M, typename prefix_map_common<M>::char_type D = 0>
+ template <typename M, typename prefix_map_common<M>::delimiter_type D>
struct prefix_map_impl: prefix_map_common<M>
{
typedef typename prefix_map_common<M>::value_type value_type;
prefix_map_impl (): prefix_map_common<M> (D) {}
- prefix_map_impl (std::initializer_list<value_type> init)
- : prefix_map_common<M> (std::move (init), D) {}
- };
-
- template <typename M>
- struct prefix_map_impl<M, 0>: prefix_map_common<M>
- {
- using prefix_map_common<M>::prefix_map_common;
+ prefix_map_impl (std::initializer_list<value_type> i)
+ : prefix_map_common<M> (std::move (i), D) {}
};
template <typename K,
typename T,
- typename compare_prefix<K>::char_type D = 0>
+ typename compare_prefix<K>::delimiter_type D>
using prefix_map = prefix_map_impl<std::map<K, T, compare_prefix<K>>, D>;
template <typename K,
typename T,
- typename compare_prefix<K>::char_type D = 0>
+ typename compare_prefix<K>::delimiter_type D>
using prefix_multimap =
prefix_map_impl<std::multimap<K, T, compare_prefix<K>>, D>;
}
diff --git a/build/target.cxx b/build/target.cxx
index b4c4481..4168991 100644
--- a/build/target.cxx
+++ b/build/target.cxx
@@ -159,10 +159,12 @@ namespace build
// since it will do nothing and it most likely not what the author
// intended.
//
- if (target* t = search_existing_target (p))
- return t;
+ target* t (search_existing_target (p));
+
+ if (t == nullptr)
+ fail << "no explicit target for prerequisite " << p;
- fail << "no explicit target for prerequisite " << p;
+ return t;
}
// type info