aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-04-03 17:36:45 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-04-03 17:36:45 +0300
commit2b281d5ec758d3bddbf27c4098f0767e2471227a (patch)
tree78eda9c7da62445bda57bfede5bf14d52cf56849 /libbuild2
parent0fb42229a5bf13170667701ad6cb468d58348007 (diff)
Skip unmatched lines in $regex.replace_lines() if format_no_copy flag is specified
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/functions-regex.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/libbuild2/functions-regex.cxx b/libbuild2/functions-regex.cxx
index 6a8c83a..10067a4 100644
--- a/libbuild2/functions-regex.cxx
+++ b/libbuild2/functions-regex.cxx
@@ -275,6 +275,7 @@ namespace build2
is.exceptions (istringstream::badbit);
const string& efmt (fmt ? *fmt : "");
+ bool no_copy ((fl.second & regex_constants::format_no_copy) != 0);
for (string l; !eof (getline (is, l)); )
{
@@ -282,9 +283,10 @@ namespace build2
string& s (rr.first);
// Skip the empty replacement for a matched line if the format is
- // absent.
+ // absent and an unmatched line if the format_no_copy flag is
+ // specified.
//
- if (!fmt && rr.second && s.empty ())
+ if (rr.second ? !fmt && s.empty () : no_copy)
continue;
if (!rls)
@@ -553,7 +555,7 @@ namespace build2
//
// return_lines - return the simple name (rather than a name list)
// containing the unmatched lines and line replacements
- // seperated with newlines.
+ // separated with newlines.
//
// Note that if format_no_copy is specified, unmatched lines are not
// copied either.