aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-01-11 08:05:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-01-11 08:18:40 +0200
commit63ea58a2889cd54f32749abf2d10f9a5ea5640ad (patch)
treee0323de39f4f55f4eb542d3a5940fa7628003763 /libbuild2
parentd853d416fd3ad00c283c54fd09a881dbb50e52f5 (diff)
Fix name recomposition bug in $name.filter*() functions
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/functions-name.cxx13
-rw-r--r--libbuild2/scope.cxx2
2 files changed, 13 insertions, 2 deletions
diff --git a/libbuild2/functions-name.cxx b/libbuild2/functions-name.cxx
index 17a8adb..fcb492f 100644
--- a/libbuild2/functions-name.cxx
+++ b/libbuild2/functions-name.cxx
@@ -131,7 +131,16 @@ namespace build2
name& n (*i);
bool p (n.pair);
- const target_type* ntt (to_target_type (s, n, p ? *++i : name ()).first);
+ // to_target_type() splits the name into the target name and extension.
+ // While we could try to reconstitute it with combine_name(), there are
+ // murky corner cases (see the default_extension argument) which won't
+ // be easy to handle. So let's just make a copy. Looking at the
+ // implementation of scope::find_target_type(), we can optimize for the
+ // (common) typed case by only copying the type.
+ //
+ name c (n.typed () ? name (n.type, "") : n);
+
+ const target_type* ntt (to_target_type (s, c, p ? *++i : name ()).first);
if (ntt == nullptr)
fail << "unknown target type " << n.type << " in " << n;
@@ -376,7 +385,7 @@ namespace build2
sort (ns.begin (), ns.end ());
if (functions_sort_flags (move (fs)))
- ns.erase (unique (ns.begin(), ns.end()), ns.end ());
+ ns.erase (unique (ns.begin (), ns.end ()), ns.end ());
return ns;
};
diff --git a/libbuild2/scope.cxx b/libbuild2/scope.cxx
index be2669d..c1c5ed7 100644
--- a/libbuild2/scope.cxx
+++ b/libbuild2/scope.cxx
@@ -685,6 +685,8 @@ namespace build2
pair<const target_type*, optional<string>> scope::
find_target_type (name& n, const location& loc, const target_type* tt) const
{
+ // NOTE: see also functions-name.cxx:filter() if changing anything here.
+
optional<string> ext;
string& v (n.value);