[libcxx-commits] [libcxx] Revert "[libc++] Fix `regex_search` to match `$` alone with `match_default` flag" (PR #78349)
Sanjay Marreddi via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 16 13:25:40 PST 2024
https://github.com/SanjayMarreddi created https://github.com/llvm/llvm-project/pull/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 #77256 . Patterns like `"^b*$"` started matching the strings such as `"a"`, which is not expected.
Reverts the PR: #77256
>From cf7b32b74031e121c30532777096bafef48134c7 Mon Sep 17 00:00:00 2001
From: SanjayMarreddi <sanjay.mareddi at gmail.com>
Date: Tue, 16 Jan 2024 21:16:30 +0000
Subject: [PATCH] Revert "[libc++] Fix `regex_search` to match `$` alone with
`match_default` flag"
This reverts commit 8badd8a06d2f92cd46f6333fa4cf4d908a789c21.
---
libcxx/include/regex | 3 ---
.../re.const/re.matchflag/match_not_eol.pass.cpp | 14 --------------
2 files changed, 17 deletions(-)
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 0761d9de54a95c..b575a267583b5f 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1889,9 +1889,6 @@ void __r_anchor_multiline<_CharT>::__exec(__state& __s) const {
if (__s.__current_ == __s.__last_ && !(__s.__flags_ & regex_constants::match_not_eol)) {
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
- } else if (__s.__current_ == __s.__first_ && !(__s.__flags_ & regex_constants::match_not_eol)) {
- __s.__do_ = __state::__accept_but_not_consume;
- __s.__node_ = this->first();
} else if (__multiline_ && std::__is_eol(*__s.__current_)) {
__s.__do_ = __state::__accept_but_not_consume;
__s.__node_ = this->first();
diff --git a/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp b/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
index ce00d6ee79fc85..edeea517d2537a 100644
--- a/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
+++ b/libcxx/test/std/re/re.const/re.matchflag/match_not_eol.pass.cpp
@@ -47,19 +47,5 @@ int main(int, char**)
assert( std::regex_search(target, re, std::regex_constants::match_not_eol));
}
- {
- std::string target = "foo";
- std::regex re("$");
- assert(std::regex_search(target, re));
- assert(!std::regex_search(target, re, std::regex_constants::match_not_eol));
- }
-
- {
- std::string target = "foo";
- std::regex re("$");
- assert(!std::regex_match(target, re));
- assert(!std::regex_match(target, re, std::regex_constants::match_not_eol));
- }
-
return 0;
}
More information about the libcxx-commits
mailing list