aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script/builtin-options.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/script/builtin-options.cxx')
-rw-r--r--libbuild2/script/builtin-options.cxx33
1 files changed, 31 insertions, 2 deletions
diff --git a/libbuild2/script/builtin-options.cxx b/libbuild2/script/builtin-options.cxx
index c27f266..56e7f24 100644
--- a/libbuild2/script/builtin-options.cxx
+++ b/libbuild2/script/builtin-options.cxx
@@ -15,6 +15,7 @@
#include <set>
#include <string>
#include <vector>
+#include <utility>
#include <ostream>
#include <sstream>
@@ -160,6 +161,7 @@ namespace build2
else
++i_;
+ ++start_position_;
return r;
}
else
@@ -170,11 +172,20 @@ namespace build2
skip ()
{
if (i_ < argc_)
+ {
++i_;
+ ++start_position_;
+ }
else
throw eos_reached ();
}
+ std::size_t argv_scanner::
+ position ()
+ {
+ return start_position_;
+ }
+
// vector_scanner
//
bool vector_scanner::
@@ -210,6 +221,12 @@ namespace build2
throw eos_reached ();
}
+ std::size_t vector_scanner::
+ position ()
+ {
+ return start_position_ + i_;
+ }
+
template <typename X>
struct parser
{
@@ -262,6 +279,17 @@ namespace build2
};
template <typename X>
+ struct parser<std::pair<X, std::size_t> >
+ {
+ static void
+ parse (std::pair<X, std::size_t>& x, bool& xs, scanner& s)
+ {
+ x.second = s.position ();
+ parser<X>::parse (x.first, xs, s);
+ }
+ };
+
+ template <typename X>
struct parser<std::vector<X> >
{
static void
@@ -299,6 +327,7 @@ namespace build2
if (s.more ())
{
+ std::size_t pos (s.position ());
std::string ov (s.next ());
std::string::size_type p = ov.find ('=');
@@ -318,14 +347,14 @@ namespace build2
if (!kstr.empty ())
{
av[1] = const_cast<char*> (kstr.c_str ());
- argv_scanner s (0, ac, av);
+ argv_scanner s (0, ac, av, false, pos);
parser<K>::parse (k, dummy, s);
}
if (!vstr.empty ())
{
av[1] = const_cast<char*> (vstr.c_str ());
- argv_scanner s (0, ac, av);
+ argv_scanner s (0, ac, av, false, pos);
parser<V>::parse (v, dummy, s);
}