Skip to content

Commit cf36aa9

Browse files
authored
<regex>: Small cleanups after completion of non-recursive matcher (#5818)
1 parent 1118f37 commit cf36aa9

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

stl/inc/regex

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ _STL_DISABLE_CLANG_WARNINGS
4848
#endif // !defined(_REGEX_MAX_COMPLEXITY_COUNT)
4949

5050
#ifndef _REGEX_MAX_STACK_COUNT
51-
#ifdef _WIN64
52-
#define _REGEX_MAX_STACK_COUNT 600L // set to 0 to disable
53-
#else // ^^^ defined(_WIN64) / !defined(_WIN64) vvv
5451
#define _REGEX_MAX_STACK_COUNT 1000L // set to 0 to disable
55-
#endif // ^^^ !defined(_WIN64) ^^^
5652
#endif // !defined(_REGEX_MAX_STACK_COUNT)
5753

5854
#ifndef _ENHANCED_REGEX_VISUALIZER
@@ -1675,7 +1671,7 @@ public:
16751671
};
16761672

16771673
enum class _Rx_unwind_ops {
1678-
_After_assert = _N_end + 1,
1674+
_After_assert = 1,
16791675
_After_neg_assert,
16801676
_Disjunction_eval_alt_on_failure,
16811677
_Disjunction_eval_alt_always,
@@ -1814,7 +1810,7 @@ private:
18141810
vector<_Rx_state_frame_t<_It>> _Frames;
18151811
size_t _Frames_count;
18161812

1817-
size_t _Push_frame(_Rx_unwind_ops _Code = {}, _Node_base* _Node = nullptr);
1813+
size_t _Push_frame(_Rx_unwind_ops _Code, _Node_base* _Node);
18181814
void _Pop_frame(size_t);
18191815

18201816
void _Increase_stack_usage_count();
@@ -3818,8 +3814,7 @@ template <class _BidIt, class _Elem, class _RxTraits, class _It, class _Alloc>
38183814
bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _Nx) { // check for match
38193815
_Increase_stack_usage_count();
38203816

3821-
bool _Failed = false;
3822-
const size_t _Initial_frames_count = _Frames_count;
3817+
bool _Failed = false;
38233818

38243819
while (_Nx) {
38253820
do { // match current node
@@ -3994,7 +3989,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N
39943989
auto& _Sav = _Loop_vals[_Node->_Loop_number];
39953990

39963991
if (_Node->_Simple_loop == 1) {
3997-
_Sav._Loop_frame_idx = _Push_frame(_Rx_unwind_ops::_Do_nothing);
3992+
_Sav._Loop_frame_idx = _Push_frame(_Rx_unwind_ops::_Do_nothing, nullptr);
39983993
_Increase_complexity_count();
39993994
if (_Node->_Min > 0 || (_Greedy && !_Longest && _Node->_Max != 0)) { // try a rep first
40003995
_Sav._Loop_idx = 1;
@@ -4179,7 +4174,7 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N
41794174
}
41804175
} while (_Nx);
41814176

4182-
while (_Frames_count > _Initial_frames_count && !_Nx) {
4177+
while (_Frames_count > 0 && !_Nx) {
41834178
auto& _Frame = _Frames[--_Frames_count];
41844179

41854180
switch (_Frame._Code) {

tests/std/tests/VSO_0000000_regex_use/test.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -910,23 +910,20 @@ void test_gh_997() {
910910
assert(ex.code() == error_stack);
911911
}
912912

913-
wregex rgx(LR"(^http[s]?://([^.]+\.)*example\.com/.*$)", icase);
913+
{
914+
test_wregex rgx(&g_regexTester, LR"(^http[s]?://([^.]+\.)*example\.com/.*$)", icase);
914915

915-
assert(regex_match(L"https://www.example.com/meow", rgx));
916+
rgx.should_search_match(L"https://www.example.com/meow", L"https://www.example.com/meow");
916917

917-
try {
918-
assert(!regex_match(
918+
rgx.should_search_fail(
919919
L"https://www.bogus.invalid/"
920920
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-"
921921
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-"
922922
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-"
923923
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-"
924924
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456.89-123456789-123456789."
925925
L"123456789-12345678.-123456789-123456789-1.3456789-123456789-123456789-123456789-123456789-123456789-"
926-
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234",
927-
rgx));
928-
} catch (const regex_error& ex) {
929-
assert(ex.code() == error_stack);
926+
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-1234");
930927
}
931928
}
932929

0 commit comments

Comments
 (0)