From be43097c383845fe5cfd63295d58de0a2837f456 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 28 Oct 2024 15:16:28 +0200 Subject: Make warning matching code in worker not to match empty substrings in non empty strings --- bbot/worker/worker.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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; -- cgit v1.1