aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbuild2/script/parser.cxx19
-rw-r--r--tests/recipe/buildscript/testscript34
2 files changed, 43 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);
diff --git a/tests/recipe/buildscript/testscript b/tests/recipe/buildscript/testscript
index 6d33888..4299fb5 100644
--- a/tests/recipe/buildscript/testscript
+++ b/tests/recipe/buildscript/testscript
@@ -1101,6 +1101,40 @@ if $posix
$* clean 2>-
}
+ : pair
+ :
+ {
+ mkdir -p src/build;
+ echo 'bar' >=src/bar;
+ echo 'baz' >=src/baz;
+
+ echo 'project =' >=src/build/bootstrap.build;
+
+ cat <<EOI >=src/buildfile;
+ foo: file{bar}@./ file{baz}@./
+ {{
+ p = $path($>)
+ rm -f $p
+
+ for f: $<
+ cat $path($f) >>$p
+ end
+ }}
+ EOI
+
+ $* src/@out/ 2>>/EOE;
+ mkdir fsdir{out/}
+ cat out/file{foo}
+ EOE
+
+ cat <<<out/foo >>EOO;
+ bar
+ baz
+ EOO
+
+ $* 'clean:' src/@out/ 2>-
+ }
+
: special-var
:
{