aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script/builtin-options.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-08-03 15:03:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-08-03 15:03:52 +0200
commitf7573d6fba84c596e02d6aae9f1e4c0bdada823a (patch)
tree01557a090399464bc1c653cbe046e329a04b2966 /libbuild2/script/builtin-options.cxx
parentdc3349218483292587047ccf3b8d61e9a3c9cca0 (diff)
Regenerate options parsing files
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);
}