|
176 | 176 | // GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with |
177 | 177 | // GTEST_HAS_POSIX_RE (see above) which users can |
178 | 178 | // define themselves. |
179 | | -// GTEST_USES_SIMPLE_RE - our own simple regex is used; |
| 179 | +// GTEST_USES_STD_RE - std::regex from the C++ standard library is used; |
180 | 180 | // the above RE\b(s) are mutually exclusive. |
181 | 181 | // GTEST_HAS_ABSL - Google Test is compiled with Abseil. |
182 | 182 |
|
@@ -438,8 +438,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; |
438 | 438 | #include <regex.h> // NOLINT |
439 | 439 | #define GTEST_USES_POSIX_RE 1 |
440 | 440 | #else |
441 | | -// Use our own simple regex implementation. |
442 | | -#define GTEST_USES_SIMPLE_RE 1 |
| 441 | +// Use std::regex from the C++ standard library. |
| 442 | +#include <regex> // NOLINT |
| 443 | +#define GTEST_USES_STD_RE 1 |
443 | 444 | #endif |
444 | 445 |
|
445 | 446 | #ifndef GTEST_HAS_EXCEPTIONS |
@@ -992,12 +993,11 @@ class GTEST_API_ [[nodiscard]] RE { |
992 | 993 | RE2 regex_; |
993 | 994 | }; |
994 | 995 |
|
995 | | -#elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_SIMPLE_RE) |
| 996 | +#elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_STD_RE) |
996 | 997 | GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ |
997 | 998 | /* class A needs to have dll-interface to be used by clients of class B */) |
998 | 999 |
|
999 | | -// A simple C++ wrapper for <regex.h>. It uses the POSIX Extended |
1000 | | -// Regular Expression syntax. |
| 1000 | +// A simple C++ wrapper for <regex.h> or <regex>. |
1001 | 1001 | class GTEST_API_ [[nodiscard]] RE { |
1002 | 1002 | public: |
1003 | 1003 | // A copy constructor is required by the Standard to initialize object |
@@ -1037,9 +1037,9 @@ class GTEST_API_ [[nodiscard]] RE { |
1037 | 1037 | regex_t full_regex_; // For FullMatch(). |
1038 | 1038 | regex_t partial_regex_; // For PartialMatch(). |
1039 | 1039 |
|
1040 | | -#else // GTEST_USES_SIMPLE_RE |
| 1040 | +#else // GTEST_USES_STD_RE |
1041 | 1041 |
|
1042 | | - std::string full_pattern_; // For FullMatch(); |
| 1042 | + std::regex regex_; |
1043 | 1043 |
|
1044 | 1044 | #endif |
1045 | 1045 | }; |
@@ -1755,14 +1755,16 @@ class [[nodiscard]] MutexBase { |
1755 | 1755 | #define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ |
1756 | 1756 | extern ::testing::internal::MutexBase mutex |
1757 | 1757 |
|
| 1758 | +#if defined(PTHREAD_NULL) |
| 1759 | +#define GTEST_INTERNAL_PTHREAD_NULL PTHREAD_NULL |
| 1760 | +#else |
| 1761 | +#define GTEST_INTERNAL_PTHREAD_NULL (pthread_t{}) |
| 1762 | +#endif |
| 1763 | + |
1758 | 1764 | // Defines and statically (i.e. at link time) initializes a static mutex. |
1759 | | -// The initialization list here does not explicitly initialize each field, |
1760 | | -// instead relying on default initialization for the unspecified fields. In |
1761 | | -// particular, the owner_ field (a pthread_t) is not explicitly initialized. |
1762 | | -// This allows initialization to work whether pthread_t is a scalar or struct. |
1763 | | -// The flag -Wmissing-field-initializers must not be specified for this to work. |
1764 | | -#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ |
1765 | | - ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, 0} |
| 1765 | +#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ |
| 1766 | + ::testing::internal::MutexBase mutex = {PTHREAD_MUTEX_INITIALIZER, false, \ |
| 1767 | + GTEST_INTERNAL_PTHREAD_NULL} |
1766 | 1768 |
|
1767 | 1769 | // The Mutex class can only be used for mutexes created at runtime. It |
1768 | 1770 | // shares its API with MutexBase otherwise. |
|
0 commit comments