aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-03-31 08:07:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-03-31 08:07:02 +0200
commitb679b1452d6513c0769928a2238ccd367c2b78f7 (patch)
treecbaaab7b6a59d5abe0e23dd856f2a61276136822 /libbuild2/parser.cxx
parent9024e707e82f80230caa488a499ecaae563f585e (diff)
Handle duplicate config directives for same variable
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 532b357..797a484 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -1885,7 +1885,24 @@ namespace build2
if (l.var != nullptr)
{
- config_report.push_back (make_pair (l, move (*report)));
+ auto r (make_pair (l, move (*report)));
+
+ // If we have a duplicate, update it (it could be useful to have
+ // multiple config directives to "probe" the value before calculating
+ // the default; see lookup_config() for details).
+ //
+ auto i (find_if (config_report.begin (),
+ config_report.end (),
+ [&l] (const pair<lookup, string>& p)
+ {
+ return p.first.var == l.var;
+ }));
+
+ if (i == config_report.end ())
+ config_report.push_back (move (r));
+ else
+ *i = move (r);
+
config_report_new = config_report_new || new_val;
}
}