Add code to honor the match_not_bol and match_not_eol regex flats. Fixes PR#22651. Thanks to Jim Porter for the report and suggested fix.
llvm-svn: 232733
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 8fa8e5fc74c604092707f35eb50859cdc886ae41
diff --git a/include/regex b/include/regex
index fb0f7d8..bd48fb8 100644
--- a/include/regex
+++ b/include/regex
@@ -1947,7 +1947,8 @@
void
__l_anchor<_CharT>::__exec(__state& __s) const
{
- if (__s.__at_first_ && __s.__current_ == __s.__first_)
+ if (__s.__at_first_ && __s.__current_ == __s.__first_ &&
+ !(__s.__flags_ & regex_constants::match_not_bol))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
@@ -1981,7 +1982,8 @@
void
__r_anchor<_CharT>::__exec(__state& __s) const
{
- if (__s.__current_ == __s.__last_)
+ if (__s.__current_ == __s.__last_ &&
+ !(__s.__flags_ & regex_constants::match_not_eol))
{
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();