From 7c3eada02a3a22ff109ef0631e75586308ab2587 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 4 Dec 2017 13:24:37 +0200 Subject: Recognize empty cc.pattern --- build2/cc/guess.cxx | 4 ++-- build2/cc/guess.hxx | 6 +++--- build2/cc/module.cxx | 2 +- build2/utility.cxx | 2 +- build2/utility.hxx | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build2/cc/guess.cxx b/build2/cc/guess.cxx index 627283f..df7899b 100644 --- a/build2/cc/guess.cxx +++ b/build2/cc/guess.cxx @@ -1189,7 +1189,7 @@ namespace build2 } path - guess_default (lang xl, const string& c, const string* pat) + guess_default (lang xl, const string& c, const string& pat) { const char* s (nullptr); @@ -1217,7 +1217,7 @@ namespace build2 } } - return path (apply_pattern (s, pat)); + return path (apply_pattern (s, &pat)); } } } diff --git a/build2/cc/guess.hxx b/build2/cc/guess.hxx index e3a4d8c..86c9793 100644 --- a/build2/cc/guess.hxx +++ b/build2/cc/guess.hxx @@ -166,13 +166,13 @@ namespace build2 const strings* c_coptions, const strings* x_coptions); - // Given a language, toolchain id, and optionally a pattern, return an - // appropriate default compiler path. + // Given a language, toolchain id, and optionally (empty) a pattern, + // return an appropriate default compiler path. // // For example, for (lang::cxx, gcc, *-4.9) we will get g++-4.9. // path - guess_default (lang, const string& cid, const string* pattern); + guess_default (lang, const string& cid, const string& pattern); } } diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index d806583..196c2ce 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -88,7 +88,7 @@ namespace build2 path d (cc_loaded ? guess_default (x_lang, cast (rs["cc.id"]), - cast_null (rs["cc.pattern"])) + cast (rs["cc.pattern"])) : path (x_default)); // If this value was hinted, save it as commented out so that if the diff --git a/build2/utility.cxx b/build2/utility.cxx index 36f8a4d..4945514 100644 --- a/build2/utility.cxx +++ b/build2/utility.cxx @@ -452,7 +452,7 @@ namespace build2 string apply_pattern (const char* s, const string* p) { - if (p == nullptr) + if (p == nullptr || p->empty ()) return s; size_t i (p->find ('*')); diff --git a/build2/utility.hxx b/build2/utility.hxx index af26acd..7d1ffc6 100644 --- a/build2/utility.hxx +++ b/build2/utility.hxx @@ -469,8 +469,8 @@ namespace build2 const cstrings&, bool = false); - // Apply the specified substitution (stem) to a '*'-pattern. If pattern - // is NULL, then return the stem itself. Assume the pattern is valid, + // Apply the specified substitution (stem) to a '*'-pattern. If pattern is + // NULL or empty, then return the stem itself. Assume the pattern is valid, // i.e., contains a single '*' character. // string -- cgit v1.1