From f7573d6fba84c596e02d6aae9f1e4c0bdada823a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 3 Aug 2021 15:03:52 +0200 Subject: Regenerate options parsing files --- build2/b-options.cxx | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'build2/b-options.cxx') diff --git a/build2/b-options.cxx b/build2/b-options.cxx index 096aebc..182dfb0 100644 --- a/build2/b-options.cxx +++ b/build2/b-options.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -199,6 +200,7 @@ namespace build2 else ++i_; + ++start_position_; return r; } else @@ -209,11 +211,20 @@ namespace build2 skip () { if (i_ < argc_) + { ++i_; + ++start_position_; + } else throw eos_reached (); } + std::size_t argv_scanner:: + position () + { + return start_position_; + } + // argv_file_scanner // int argv_file_scanner::zero_argc_ = 0; @@ -324,6 +335,7 @@ namespace build2 { hold_[i_ == 0 ? ++i_ : --i_].swap (args_.front ().value); args_.pop_front (); + ++start_position_; return hold_[i_].c_str (); } } @@ -337,7 +349,10 @@ namespace build2 if (args_.empty ()) return base::skip (); else + { args_.pop_front (); + ++start_position_; + } } const argv_file_scanner::option_info* argv_file_scanner:: @@ -350,6 +365,12 @@ namespace build2 return 0; } + std::size_t argv_file_scanner:: + position () + { + return start_position_; + } + void argv_file_scanner:: load (const std::string& file) { @@ -567,6 +588,23 @@ namespace build2 }; template + struct parser > + { + static void + parse (std::pair& x, bool& xs, scanner& s) + { + x.second = s.position (); + parser::parse (x.first, xs, s); + } + + static void + merge (std::pair& b, const std::pair& a) + { + b = a; + } + }; + + template struct parser > { static void @@ -616,6 +654,7 @@ namespace build2 if (s.more ()) { + std::size_t pos (s.position ()); std::string ov (s.next ()); std::string::size_type p = ov.find ('='); @@ -635,14 +674,14 @@ namespace build2 if (!kstr.empty ()) { av[1] = const_cast (kstr.c_str ()); - argv_scanner s (0, ac, av); + argv_scanner s (0, ac, av, false, pos); parser::parse (k, dummy, s); } if (!vstr.empty ()) { av[1] = const_cast (vstr.c_str ()); - argv_scanner s (0, ac, av); + argv_scanner s (0, ac, av, false, pos); parser::parse (v, dummy, s); } -- cgit v1.1