aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/utility.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-08 09:33:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-08 09:33:45 +0200
commitd730f40440e213bc08cce4587439960c80ad9aa5 (patch)
treeec0d488f7dd83238accaab33db8660ae32b60870 /libbuild2/utility.cxx
parent2c8b400010ffedec596969f64e79144f99d73f62 (diff)
Redo bin pattern as PATH-like search paths rather than fallback directory
Also, unlike the fallback directory, the search paths are searched first rather than last.
Diffstat (limited to 'libbuild2/utility.cxx')
-rw-r--r--libbuild2/utility.cxx22
1 files changed, 12 insertions, 10 deletions
diff --git a/libbuild2/utility.cxx b/libbuild2/utility.cxx
index 16bbd85..d6a32ab 100644
--- a/libbuild2/utility.cxx
+++ b/libbuild2/utility.cxx
@@ -186,9 +186,10 @@ namespace build2
try_run_search (const path& f,
bool init,
const dir_path& fallback,
- bool path_only)
+ bool path_only,
+ const char* paths)
{
- return process::try_path_search (f, init, fallback, path_only);
+ return process::try_path_search (f, init, fallback, path_only, paths);
}
process
@@ -477,17 +478,18 @@ namespace build2
}
string
- apply_pattern (const char* s, const string* p)
+ apply_pattern (const char* stem, const char* pat)
{
- if (p == nullptr || p->empty ())
- return s;
+ if (pat == nullptr || *pat == '\0')
+ return stem;
- size_t i (p->find ('*'));
- assert (i != string::npos);
+ size_t n (string::traits_type::length (pat));
+ const char* p (string::traits_type::find (pat, n, '*'));
+ assert (p != nullptr);
- string r (*p, 0, i++);
- r.append (s);
- r.append (*p, i, p->size () - i);
+ string r (pat, p++ - pat);
+ r.append (stem);
+ r.append (p, n - (p - pat));
return r;
}