aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/functions-regex.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/functions-regex.cxx')
-rw-r--r--libbuild2/functions-regex.cxx31
1 files changed, 27 insertions, 4 deletions
diff --git a/libbuild2/functions-regex.cxx b/libbuild2/functions-regex.cxx
index c46f6f5..cac4e54 100644
--- a/libbuild2/functions-regex.cxx
+++ b/libbuild2/functions-regex.cxx
@@ -138,12 +138,19 @@ namespace build2
//
string s (to_string (move (v)));
+ // Match flags.
+ //
+ regex_constants::match_flag_type mf (regex_constants::match_default);
+
+ if (!s.empty ())
+ mf |= regex_constants::match_not_null;
+
if (!match && !subs)
- return value (regex_search (s, rge)); // Return boolean value.
+ return value (regex_search (s, rge, mf)); // Return boolean value.
match_results<string::const_iterator> m;
- if (regex_search (s, m, rge))
+ if (regex_search (s, m, rge, mf))
{
assert (!m.empty ());
@@ -483,7 +490,16 @@ namespace build2
for (auto& n: ns)
{
- if (regex_search (convert<string> (move (n)), rge))
+ string s (convert<string> (move (n)));
+
+ // Match flags.
+ //
+ regex_constants::match_flag_type mf (regex_constants::match_default);
+
+ if (!s.empty ())
+ mf |= regex_constants::match_not_null;
+
+ if (regex_search (s, rge, mf))
return true;
}
@@ -516,7 +532,14 @@ namespace build2
bool s (n.simple ());
string v (convert<string> (s ? move (n) : name (n)));
- if (regex_search (v, rge) == matching)
+ // Match flags.
+ //
+ regex_constants::match_flag_type mf (regex_constants::match_default);
+
+ if (!v.empty ())
+ mf |= regex_constants::match_not_null;
+
+ if (regex_search (v, rge, mf) == matching)
r.emplace_back (s ? name (move (v)) : move (n));
}