Skip to content

Commit

Permalink
Refer egrep mode with multiline captures
Browse files Browse the repository at this point in the history
  • Loading branch information
cpp11nullptr committed Dec 23, 2020
1 parent 654db2a commit b565824
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -3407,21 +3407,6 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Better_match() { // check for bet
unsigned int _Res_valid_count = 0;
unsigned int _Tgt_state_valid_count = 0;

for (unsigned int _Ix = 0; _Ix < _Get_ncap(); ++_Ix) {
if (_Res._Grp_valid[_Ix]) {
++_Res_valid_count;
}

if (_Tgt_state._Grp_valid[_Ix]) {
++_Tgt_state_valid_count;
}
}

// more captured groups means a better match
if (_Tgt_state_valid_count != _Res_valid_count) {
return _Tgt_state_valid_count > _Res_valid_count;
}

for (unsigned int _Ix = 0; _Ix < _Get_ncap(); ++_Ix) { // check each capture group
if (_Res._Grp_valid[_Ix] && _Tgt_state._Grp_valid[_Ix]) {
if (_Res._Grps[_Ix]._Begin != _Tgt_state._Grps[_Ix]._Begin) {
Expand All @@ -3433,8 +3418,18 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Better_match() { // check for bet
return _STD distance(_Begin, _Res._Grps[_Ix]._End) < _STD distance(_Begin, _Tgt_state._Grps[_Ix]._End);
}
}

if (_Res._Grp_valid[_Ix]) {
++_Res_valid_count;
}

if (_Tgt_state._Grp_valid[_Ix]) {
++_Tgt_state_valid_count;
}
}
return false;

// more captured groups means a better match
return _Tgt_state_valid_count > _Res_valid_count;
}

template <class _BidIt, class _Elem, class _RxTraits, class _It>
Expand Down

0 comments on commit b565824

Please sign in to comment.