From d730f40440e213bc08cce4587439960c80ad9aa5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Oct 2019 09:33:45 +0200 Subject: 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. --- libbuild2/utility.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'libbuild2/utility.cxx') 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; } -- cgit v1.1