Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -3818,8 +3814,7 @@ template <class _BidIt, class _Elem, class _RxTraits, class _It, class _Alloc>
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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
13 changes: 5 additions & 8 deletions tests/std/tests/VSO_0000000_regex_use/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,23 +910,20 @@ 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-"
L"123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-"
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");
}
}

Expand Down