Skip to content
Merged
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
37 changes: 21 additions & 16 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,10 @@ public:
}
};

enum class _Rx_unwind_ops { _After_assert = _N_end + 1 };
enum class _Rx_unwind_ops {
_After_assert = _N_end + 1,
_After_neg_assert,
};

template <class _BidIt>
class _Rx_state_frame_t {
Expand Down Expand Up @@ -1807,7 +1810,6 @@ private:
void _Increase_stack_usage_count();
void _Decrease_stack_usage_count();

bool _Do_neg_assert(_Node_assert*);
bool _Do_if(_Node_if*);
bool _Do_rep0(_Node_rep*, bool);
bool _Do_rep(_Node_rep*, bool, int);
Expand Down Expand Up @@ -3400,19 +3402,6 @@ void _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Decrease_stack_usage_cou
}
}

template <class _BidIt, class _Elem, class _RxTraits, class _It, class _Alloc>
bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Do_neg_assert(_Node_assert* _Node) {
// apply negative assert node
const size_t _Frame_idx = _Push_frame();
bool _Succeeded = !_Match_pat(_Node->_Child);
if (_Succeeded) {
const _Bt_state_t<_It>& _St = _Frames[_Frame_idx]._Match_state;
_Tgt_state = _St;
}
_Pop_frame(_Frame_idx);
return _Succeeded;
}

template <class _BidIt, class _Elem, class _RxTraits, class _It, class _Alloc>
bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Do_if(_Node_if* _Node) { // apply if node
const size_t _Frame_idx = _Push_frame();
Expand Down Expand Up @@ -4130,7 +4119,11 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N

case _N_neg_assert:
{ // check negative assert
_Failed = !_Do_neg_assert(static_cast<_Node_assert*>(_Nx));
auto _Node = static_cast<_Node_assert*>(_Nx);
_Push_frame(_Rx_unwind_ops::_After_neg_assert, _Node);
_Next = _Node->_Child;

_Increase_stack_usage_count();
break;
}

Expand Down Expand Up @@ -4256,6 +4249,18 @@ bool _Matcher3<_BidIt, _Elem, _RxTraits, _It, _Alloc>::_Match_pat(_Node_base* _N
break;
}

case _Rx_unwind_ops::_After_neg_assert:
{ // negative assert completed
_Decrease_stack_usage_count();
if (_Failed) {
const _Bt_state_t<_It>& _St = _Frame._Match_state;
_Tgt_state = _St;
_Nx = _Frame._Node->_Next;
}
_Failed = !_Failed;
break;
}

default:
#if _ITERATOR_DEBUG_LEVEL != 0
_STL_REPORT_ERROR("internal stack of regex matcher corrupted");
Expand Down