diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-12-13 12:26:58 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-12-13 13:54:43 +0200 |
commit | fa8b8d73968055d9bb4c9e18e2dc10e5f77e223d (patch) | |
tree | 832f0df42a340a240c8ead95494da6e5ccce9340 /libbuild2/functions-regex.cxx | |
parent | 588be7603f7e7841717312109a524f8e5f063a26 (diff) |
Return all subexpressions in $regex.{match,search}(), not only matched
The old semantics was unusable for optional groups (e.g., `(...)?`).
Diffstat (limited to 'libbuild2/functions-regex.cxx')
-rw-r--r-- | libbuild2/functions-regex.cxx | 10 |
1 files 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)); |