From 38db461e03e949916221f7ae99b06751a3d05cce Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 6 Jun 2022 11:30:04 +0200 Subject: Add another config::origin() overload --- libbuild2/config/utility.cxx | 9 +++++++-- libbuild2/config/utility.hxx | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'libbuild2/config') diff --git a/libbuild2/config/utility.cxx b/libbuild2/config/utility.cxx index 243c03a..a64d4d5 100644 --- a/libbuild2/config/utility.cxx +++ b/libbuild2/config/utility.cxx @@ -177,14 +177,19 @@ namespace build2 origin (const scope& rs, const variable& var) { // Make sure this is a config.* variable. This could matter since we - // reply on the semantics of value::extra. We could also detect + // rely on the semantics of value::extra. We could also detect // special variables like config.booted, some config.config.*, etc., // (see config_save() for details) but that seems harmless. // if (var.name.compare (0, 7, "config.") != 0) throw invalid_argument ("config.* variable expected"); - pair org (rs.lookup_original (var)); + return origin (rs, var, rs.lookup_original (var)); + } + + pair + origin (const scope& rs, const variable& var, pair org) + { pair ovr (var.overrides == nullptr ? org : rs.lookup_override (var, org)); diff --git a/libbuild2/config/utility.hxx b/libbuild2/config/utility.hxx index b998e3c..1e33568 100644 --- a/libbuild2/config/utility.hxx +++ b/libbuild2/config/utility.hxx @@ -514,6 +514,14 @@ namespace build2 LIBBUILD2_SYMEXPORT pair origin (const scope& rs, const variable&); + + // As above but using the result of scope::lookup_original() or + // semantically equivalent (e.g., lookup_namespace()). + // + // Note that this version does not check that the variable is config.*. + // + LIBBUILD2_SYMEXPORT pair + origin (const scope& rs, const variable&, pair original); } } -- cgit v1.1