aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-09 14:16:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-09 14:16:37 +0200
commitb860110cd454d3f83163d76b0bda835af0b38bea (patch)
tree5fd738f7d06952c298ec2f50e069fd5345713a12
parentaccbdae9b6e985d663d8af57375c7861ecd755a1 (diff)
Fix bug in command line variable override depth calculation
-rw-r--r--build2/scope.cxx18
1 files changed, 11 insertions, 7 deletions
diff --git a/build2/scope.cxx b/build2/scope.cxx
index 49263d4..feac2fe 100644
--- a/build2/scope.cxx
+++ b/build2/scope.cxx
@@ -373,7 +373,8 @@ namespace build2
stem_proj = root_scope ();
}
- // For implied target/rule-specific lookup.
+ // Depth at which we found the override (with implied target/rule-specific
+ // lookup counts).
//
size_t ovr_depth (target ? (rule ? 3 : 2) : 0);
@@ -496,21 +497,24 @@ namespace build2
// variable itself is typed. We also pass the original variable for
// diagnostics.
//
- auto l (find (o, ".__prefix"));
+ auto lp (find (o, ".__prefix"));
+ auto ls (find (o, ".__suffix"));
if (cl)
{
- if (l) // No sense to prepend/append if NULL.
+ // Note: if we have both, then the prefix is already in the stem.
+ //
+ if (lp) // No sense to prepend/append if NULL.
{
- cv.prepend (names (cast<names> (l)), &var);
+ cv.prepend (names (cast<names> (lp)), &var);
}
- else if ((l = find (o, ".__suffix")))
+ else if (ls)
{
- cv.append (names (cast<names> (l)), &var);
+ cv.append (names (cast<names> (ls)), &var);
}
}
- if (l.defined ())
+ if (lp.defined () || ls.defined ())
{
// If we had no stem, use the first override as a surrogate stem.
//