[FIX][libc++][Regex] Using regex_constants match_prev_avail | match_not_bol | match_not_bow
Summary:
pr42199
When using regex_constants::match_prev_avail, it is defined that
--first is valid, and match_not_bol and match_not_bow should be
ignored. At the moment these flags are not ignored. This fixis that.
Reviewers: ldionne, miyuki, EricWF, mclow.lists, #libc
Reviewed By: ldionne, miyuki, #libc
Subscribers: broadwaylamb, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D75622
Cr-Mirrored-From: https://chromium.googlesource.com/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: c14ac8043ed1d8128e515c88e78186dd1ca5a655
diff --git a/include/regex b/include/regex
index c917c40..433ba0f 100644
--- a/include/regex
+++ b/include/regex
@@ -5940,6 +5940,9 @@
match_results<const _CharT*, _Allocator>& __m,
regex_constants::match_flag_type __flags) const
{
+ if (__flags & regex_constants::match_prev_avail)
+ __flags &= ~(regex_constants::match_not_bol | regex_constants::match_not_bow);
+
__m.__init(1 + mark_count(), __first, __last,
__flags & regex_constants::__no_update_pos);
if (__match_at_start(__first, __last, __m, __flags,