Skip to content

Commit 67f5df7

Browse files
Revert "[libc++] Fix regex_search to match $ alone with match_default flag" (llvm#78349)
The behavior of `std::regex_search` for patterns anchored both to the start and to the end of the input went wrong after merging llvm#77256 . Patterns like `"^b*$"` started matching the strings such as `"a"`, which is not expected. Reverts the PR: llvm#77256
1 parent 5e8def2 commit 67f5df7

File tree

2 files changed

+0
-17
lines changed

2 files changed

+0
-17
lines changed

libcxx/include/regex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,9 +1889,6 @@ void __r_anchor_multiline<_CharT>::__exec(__state& __s) const {
18891889
if (__s.__current_ == __s.__last_ && !(__s.__flags_ & regex_constants::match_not_eol)) {
18901890
__s.__do_ = __state::__accept_but_not_consume;
18911891
__s.__node_ = this->first();
1892-
} else if (__s.__current_ == __s.__first_ && !(__s.__flags_ & regex_constants::match_not_eol)) {
1893-
__s.__do_ = __state::__accept_but_not_consume;
1894-
__s.__node_ = this->first();
18951892
} else if (__multiline_ && std::__is_eol(*__s.__current_)) {
18961893
__s.__do_ = __state::__accept_but_not_consume;
18971894
__s.__node_ = this->first();

libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,5 @@ int main(int, char**)
4747
assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
4848
}
4949

50-
{
51-
std::string target = "foo";
52-
std::regex re("$");
53-
assert(std::regex_search(target, re));
54-
assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
55-
}
56-
57-
{
58-
std::string target = "foo";
59-
std::regex re("$");
60-
assert(!std::regex_match(target, re));
61-
assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
62-
}
63-
6450
return 0;
6551
}

0 commit comments

Comments
 (0)