From fa8b8d73968055d9bb4c9e18e2dc10e5f77e223d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 13 Dec 2022 12:26:58 +0200 Subject: Return all subexpressions in $regex.{match,search}(), not only matched The old semantics was unusable for optional groups (e.g., `(...)?`). --- libbuild2/functions-regex.cxx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libbuild2/functions-regex.cxx b/libbuild2/functions-regex.cxx index f0fee8d..a7dadd7 100644 --- a/libbuild2/functions-regex.cxx +++ b/libbuild2/functions-regex.cxx @@ -92,10 +92,7 @@ namespace build2 names r; for (size_t i (1); i != m.size (); ++i) - { - if (m[i].matched) - r.emplace_back (m.str (i)); - } + r.emplace_back (m[i].matched ? m.str (i) : string ()); return value (move (r)); } @@ -161,10 +158,7 @@ namespace build2 if (subs) { for (size_t i (1); i != m.size (); ++i) - { - if (m[i].matched) - r.emplace_back (m.str (i)); - } + r.emplace_back (m[i].matched ? m.str (i) : string ()); } return value (move (r)); -- cgit v1.1