aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/script
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-10-20 20:38:40 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-10-21 11:50:52 +0300
commit27342e7a1066a3f1426a624a35e52c23bdedeed9 (patch)
treebc7cf4c125e9e1a987e4d6b74acf14b4e6deb4d6 /libbuild2/script
parent4881a227779a78db1de2a7723e2a86f2b61453b3 (diff)
Add support for pairs in script 'for x:...' loop
Diffstat (limited to 'libbuild2/script')
-rw-r--r--libbuild2/script/parser.cxx19
1 files changed, 9 insertions, 10 deletions
diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx
index 2a213ab..bc433e4 100644
--- a/libbuild2/script/parser.cxx
+++ b/libbuild2/script/parser.cxx
@@ -2660,20 +2660,19 @@ namespace build2
size_t fli (li);
iteration_index fi {1, ii};
+ names& ns (val.as<names> ());
- // @@ Handle pairs.
- //
- // Do we need to always lex the variable values (for-loop
- // and var lines) pair-character aware?
- //
- // Can there be any harm if a value with pairs is
- // substituted into the command line?
- //
- for (name& n: val.as<names> ())
+ for (auto ni (ns.begin ()), ne (ns.end ()); ni != ne; ++ni)
{
li = fli;
- value v (names {move (n)}); // Untyped.
+ // Set the variable value.
+ //
+ bool pair (ni->pair);
+ names n;
+ n.push_back (move (*ni));
+ if (pair) n.push_back (move (*++ni));
+ value v (move (n)); // Untyped.
if (etype != nullptr)
typify (v, *etype, var);