aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-10-28 15:16:28 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2024-10-28 15:16:28 +0200
commitbe43097c383845fe5cfd63295d58de0a2837f456 (patch)
treeebfb830e6112b1a7295209834af0137b34480118
parent642956288d5a6f59ebc45a7d1e6e47e1be131778 (diff)
Make warning matching code in worker not to match empty substrings in non empty strings
-rw-r--r--bbot/worker/worker.cxx18
1 files changed, 17 insertions, 1 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 69a0f28..fae83b9 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -717,6 +717,21 @@ run_cmd (step_id step,
//
if (r != result_status::warning)
{
+ // Match flags.
+ //
+ // Note that by default std::regex_search() matches the empty
+ // substrings in non-empty strings for all the major
+ // implementations (see the butl::regex_replace_search()
+ // function implementation for details). While it's unlikely
+ // that the warning regex will match the empty substrings, let's
+ // keep it consistent with the other regex_search() call sites.
+ //
+ regex_constants::match_flag_type mf (
+ regex_constants::match_default);
+
+ if (!l.empty ())
+ mf |= regex_constants::match_not_null;
+
for (const regex& re: warn_detect)
{
// Only examine the first 512 bytes. Long lines (e.g., linker
@@ -728,7 +743,8 @@ run_cmd (step_id step,
(l.size () < 512
? l.end ()
: l.begin () + 512),
- re))
+ re,
+ mf))
{
r = result_status::warning;
break;