aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/common-options.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/common-options.cxx')
-rw-r--r--libbuild2/common-options.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/libbuild2/common-options.cxx b/libbuild2/common-options.cxx
index 5c58a62..4be0289 100644
--- a/libbuild2/common-options.cxx
+++ b/libbuild2/common-options.cxx
@@ -587,10 +587,31 @@ namespace build2
struct parser<bool>
{
static void
- parse (bool& x, scanner& s)
+ parse (bool& x, bool& xs, scanner& s)
{
- s.next ();
- x = true;
+ const char* o (s.next ());
+
+ if (s.more ())
+ {
+ const char* v (s.next ());
+
+ if (std::strcmp (v, "1") == 0 ||
+ std::strcmp (v, "true") == 0 ||
+ std::strcmp (v, "TRUE") == 0 ||
+ std::strcmp (v, "True") == 0)
+ x = true;
+ else if (std::strcmp (v, "0") == 0 ||
+ std::strcmp (v, "false") == 0 ||
+ std::strcmp (v, "FALSE") == 0 ||
+ std::strcmp (v, "False") == 0)
+ x = false;
+ else
+ throw invalid_value (o, v);
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
}
};
@@ -707,6 +728,14 @@ namespace build2
parser<T>::parse (x.*M, s);
}
+ template <typename X, bool X::*M>
+ void
+ thunk (X& x, scanner& s)
+ {
+ s.next ();
+ x.*M = true;
+ }
+
template <typename X, typename T, T X::*M, bool X::*S>
void
thunk (X& x, scanner& s)
@@ -718,7 +747,6 @@ namespace build2
}
#include <map>
-#include <cstring>
namespace build2
{