mirror of
https://github.com/google/googletest.git
synced 2026-09-25 04:09:59 +03:00
Previously, non-Abseil builds of GoogleTest used either the POSIX <regex.h> header, or a hand-rolled bare-bones regex engine in GoogleTest.
This commit removes the custom regex engine and switches to the C++11 <regex> header instead, which primarily affects Windows builds. Correspondingly, the GTEST_USES_SIMPLE_RE macro is removed and GTEST_USES_STD_RE is defined in its place, so users that depend on the macro should update their code accordingly.
This commit may break on any exotic toolchains or platforms that lack all of these libraries, but these have been long unsupported, as GoogleTest requires C++17.
Note: MSVC's engine can be prone to overflowing the stack on some patterns and inputs. As a trivial example:
#include <regex>
int main() {
std::string corpus;
for (size_t i = 0; i < 1000; ++i) {
corpus += "a\n";
}
// Stack overflow
std::regex_match(corpus, std::regex("(\n|.)*", std::regex_constants::ECMAScript));
}
In such cases, it is recommended to use alternative patterns accomplishing the same goal, such as checking for pieces of a pattern independently.
PiperOrigin-RevId: 978659894
Change-Id: I4594285e696af12a008e1e4cee300f292bbdbf32