Skip to content
Closed
Changes from 1 commit
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
6 changes: 1 addition & 5 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,7 @@ public:
template <class _Iter>
char_class_type lookup_classname(_Iter _First, _Iter _Last, bool _Icase = false) const {
// map [_First, _Last) to character class mask value
#define _REGEX_CHAR_CLASS_NAME(n, c) \
{ \
n, L##n, static_cast<unsigned int>(_STD size(n) - 1), c \
}
#define _REGEX_CHAR_CLASS_NAME(n, c) {n, L##n, static_cast<unsigned int>(_STD size(n) - 1), c}
static constexpr _Cl_names _Names[] = {
// map class names to numeric constants
_REGEX_CHAR_CLASS_NAME("alnum", _Ch_alnum),
Expand Down Expand Up @@ -3610,7 +3607,6 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Match_pat(_Node_base* _Nx) { // c
_Node_end_group* _Node = static_cast<_Node_end_group*>(_Nx);
_Node_capture* _Node0 = static_cast<_Node_capture*>(_Node->_Back);
if (_Cap || _Node0->_Idx != 0) { // update capture data
_Tgt_state._Grp_valid[_Node0->_Idx] = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deletion does not just correct the matches for negative assertions. With this change, no capture group at all will ever be matched.

Changes to fix #5245 actually have to be applied here:

STL/stl/inc/regex

Lines 3575 to 3590 in fc15609

case _N_neg_assert:
case _N_assert:
{ // check assert
_It _Ch = _Tgt_state._Cur;
bool _Neg = _Nx->_Kind == _N_neg_assert;
_Bt_state_t<_It> _St = _Tgt_state;
if (_Match_pat(static_cast<_Node_assert*>(_Nx)->_Child) == _Neg) {
// restore initial state and indicate failure
_Tgt_state = _St;
_Failed = true;
} else {
_Tgt_state._Cur = _Ch;
}
break;
}

Specifically, _Tgt_state._Cur = _Ch; insufficiently resets the state after a successful negative assertion. (But it is the appropriate reset for positive assertions.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have restored the initial state after a successful negative assertion.

_Tgt_state._Grps[_Node0->_Idx]._End = _Tgt_state._Cur;
}
break;
Expand Down
Loading