From b860110cd454d3f83163d76b0bda835af0b38bea Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 9 Nov 2018 14:16:37 +0200 Subject: Fix bug in command line variable override depth calculation --- build2/scope.cxx | 18 +++++++++++------- 1 file 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 (l)), &var); + cv.prepend (names (cast (lp)), &var); } - else if ((l = find (o, ".__suffix"))) + else if (ls) { - cv.append (names (cast (l)), &var); + cv.append (names (cast (ls)), &var); } } - if (l.defined ()) + if (lp.defined () || ls.defined ()) { // If we had no stem, use the first override as a surrogate stem. // -- cgit v1.1