diff --git a/stl/inc/regex b/stl/inc/regex index 2409ce9bd5..489dbf34f4 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -48,11 +48,7 @@ _STL_DISABLE_CLANG_WARNINGS #endif // !defined(_REGEX_MAX_COMPLEXITY_COUNT) #ifndef _REGEX_MAX_STACK_COUNT -#ifdef _WIN64 -#define _REGEX_MAX_STACK_COUNT 600L // set to 0 to disable -#else // ^^^ defined(_WIN64) / !defined(_WIN64) vvv #define _REGEX_MAX_STACK_COUNT 1000L // set to 0 to disable -#endif // ^^^ !defined(_WIN64) ^^^ #endif // !defined(_REGEX_MAX_STACK_COUNT) #ifndef _ENHANCED_REGEX_VISUALIZER @@ -1675,7 +1671,7 @@ public: }; enum class _Rx_unwind_ops { - _After_assert = _N_end + 1, + _After_assert = 1, _After_neg_assert, _Disjunction_eval_alt_on_failure, _Disjunction_eval_alt_always, @@ -1814,7 +1810,7 @@ private: vector<_Rx_state_frame_t<_It>> _Frames; size_t _Frames_count; - size_t _Push_frame(_Rx_unwind_ops _Code = {}, _Node_base* _Node = nullptr); + size_t _Push_frame(_Rx_unwind_ops _Code, _Node_base* _Node); void _Pop_frame(size_t); void _Increase_stack_usage_count(); @@ -3818,8 +3814,7 @@ template bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _Nx) { // check for match _Increase_stack_usage_count(); - bool _Failed = false; - const size_t _Initial_frames_count = _Frames_count; + bool _Failed = false; while (_Nx) { do { // match current node @@ -3994,7 +3989,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N auto& _Sav = _Loop_vals[_Node->_Loop_number]; if (_Node->_Simple_loop == 1) { - _Sav._Loop_frame_idx = _Push_frame(_Rx_unwind_ops::_Do_nothing); + _Sav._Loop_frame_idx = _Push_frame(_Rx_unwind_ops::_Do_nothing, nullptr); _Increase_complexity_count(); if (_Node->_Min > 0 || (_Greedy && !_Longest && _Node->_Max != 0)) { // try a rep first _Sav._Loop_idx = 1; @@ -4179,7 +4174,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N } } while (_Nx); - while (_Frames_count > _Initial_frames_count && !_Nx) { + while (_Frames_count > 0 && !_Nx) { auto& _Frame = _Frames[--_Frames_count]; switch (_Frame._Code) { diff --git a/tests/std/tests/VSO_0000000_regex_use/test.cpp b/tests/std/tests/VSO_0000000_regex_use/test.cpp index 794e3ffd06..c24d555302 100644 --- a/tests/std/tests/VSO_0000000_regex_use/test.cpp +++ b/tests/std/tests/VSO_0000000_regex_use/test.cpp @@ -910,12 +910,12 @@ void test_gh_997() { assert(ex.code() == error_stack); } - wregex rgx(LR"(^http[s]?://([^.]+\.)*example\.com/.*$)", icase); + { + test_wregex rgx(&g_regexTester, LR"(^http[s]?://([^.]+\.)*example\.com/.*$)", icase); - assert(regex_match(L"https://www.example.com/meow", rgx)); + rgx.should_search_match(L"https://www.example.com/meow", L"https://www.example.com/meow"); - try { - assert(!regex_match( + rgx.should_search_fail( L"https://www.bogus.invalid/" L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-" L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-" @@ -923,10 +923,7 @@ void test_gh_997() { L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-" L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456.89-123456789-123456789." L"123456789-12345678.-123456789-123456789-1.3456789-123456789-123456789-123456789-123456789-123456789-" - L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234", - rgx)); - } catch (const regex_error& ex) { - assert(ex.code() == error_stack); + L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234"); } }