Skip to content
Closed
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
10 changes: 3 additions & 7 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 @@ -3575,15 +3572,14 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Match_pat(_Node_base* _Nx) { // c
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

Pre-existing: This state reset after a match failure is both unnecessary and pointless, so I think it should be removed. No caller of _Match_pat() can assume that the match state hasn't changed after failure, because the function does not fully reset the state after trying to match two or more NFA nodes anyway.

_Failed = true;
} else {
_Tgt_state._Cur = _Ch;
} else if (!_Neg) {
_Tgt_state._Cur = _St._Cur;
Comment on lines +3581 to +3582
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not equivalent to the prior commit. Now the state is no longer being reset for a successful negative lookahead assertion at all.

(My comment about a superfluous _Tgt_state = _St; statement points a different line, namely the one in the failure case. The one removed by the last commit in the successful case isn't superfluous at all.)

This suggests we really need more test coverage for negative assertions if no test catches this.

}

break;
Expand Down