@@ -1202,16 +1202,17 @@ _INLINE_VAR constexpr unsigned int _Bmp_size = (_Bmp_max + _Bmp_chrs - 1U) / _B
1202
1202
_INLINE_VAR constexpr unsigned int _ARRAY_THRESHOLD = 4U;
1203
1203
1204
1204
enum _Node_flags : int { // flags for nfa nodes with special properties
1205
- _Fl_none = 0x000,
1206
- _Fl_negate = 0x001,
1207
- _Fl_greedy = 0x002,
1208
- _Fl_longest = 0x008, // TRANSITION, ABI: 0x004 is unused; the parser previously marked some nodes with it
1209
- _Fl_class_negated_w = 0x100,
1210
- _Fl_class_negated_s = 0x200,
1211
- _Fl_class_negated_d = 0x400,
1212
- _Fl_begin_needs_w = 0x100,
1213
- _Fl_begin_needs_s = 0x200,
1214
- _Fl_begin_needs_d = 0x400
1205
+ _Fl_none = 0x000,
1206
+ _Fl_negate = 0x001,
1207
+ _Fl_greedy = 0x002,
1208
+ _Fl_longest = 0x008, // TRANSITION, ABI: 0x004 is unused; the parser previously marked some nodes with it
1209
+ _Fl_class_negated_w = 0x100,
1210
+ _Fl_class_negated_s = 0x200,
1211
+ _Fl_class_negated_d = 0x400,
1212
+ _Fl_class_cl_all_bits = 0x800, // TRANSITION, ABI: GH-5242
1213
+ _Fl_begin_needs_w = 0x100,
1214
+ _Fl_begin_needs_s = 0x200,
1215
+ _Fl_begin_needs_d = 0x400
1215
1216
};
1216
1217
1217
1218
_BITMASK_OPS(_EMPTY_ARGUMENT, _Node_flags)
@@ -2986,11 +2987,19 @@ template <class _FwdIt, class _Elem, class _RxTraits>
2986
2987
void _Builder<_FwdIt, _Elem, _RxTraits>::_Add_named_class(
2987
2988
typename _RxTraits::char_class_type _Cl, const _Rx_char_class_kind _Kind) {
2988
2989
// add contents of named class to bracket expression
2990
+ using _Char_class_type = typename _RxTraits::char_class_type;
2989
2991
_Node_class<_Elem, _RxTraits>* _Node = static_cast<_Node_class<_Elem, _RxTraits>*>(_Current);
2990
2992
_Add_elts(_Node, _Cl, _Kind != _Rx_char_class_kind::_Positive);
2991
2993
if (_Bmp_max <= _STD _Max_limit<typename _RxTraits::_Uelem>()) {
2992
2994
if (_Kind == _Rx_char_class_kind::_Positive) {
2993
- _Node->_Classes = static_cast<typename _RxTraits::char_class_type>(_Node->_Classes | _Cl);
2995
+ auto _Cl_all_bits_set = static_cast<_Char_class_type>(-1);
2996
+ if ((_Node->_Classes != _Cl_all_bits_set && _Cl != _Cl_all_bits_set)
2997
+ || _Node->_Classes == _Char_class_type{}) {
2998
+ _Node->_Classes = static_cast<_Char_class_type>(_Node->_Classes | _Cl);
2999
+ } else if (_Node->_Classes != _Cl) {
3000
+ _Node->_Classes = static_cast<_Char_class_type>(_Node->_Classes & _Cl);
3001
+ _Node->_Flags |= _Fl_class_cl_all_bits;
3002
+ }
2994
3003
} else {
2995
3004
auto _Node_flag = static_cast<_Node_flags>(_Kind);
2996
3005
_Node->_Flags |= _Node_flag;
@@ -3529,6 +3538,9 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Do_class(_Node_base* _Nx) { // ap
3529
3538
_Found = true;
3530
3539
} else if (_Node->_Classes != typename _RxTraits::char_class_type{} && _Traits.isctype(_Ch, _Node->_Classes)) {
3531
3540
_Found = true;
3541
+ } else if ((_Node->_Flags & _Fl_class_cl_all_bits)
3542
+ && _Traits.isctype(_Ch, static_cast<typename _RxTraits::char_class_type>(-1))) {
3543
+ _Found = true;
3532
3544
} else if (_Node->_Equiv && _STD _Lookup_equiv2(_Ch, _Node->_Equiv, _Traits)) {
3533
3545
_Found = true;
3534
3546
} else if ((_Node->_Flags & _Fl_class_negated_w)
@@ -3905,6 +3917,9 @@ _BidIt _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Skip(_BidIt _First_arg, _BidIt
3905
3917
} else if (_Node->_Classes != typename _RxTraits::char_class_type{}
3906
3918
&& _Traits.isctype(_Ch, _Node->_Classes)) {
3907
3919
_Found = true;
3920
+ } else if ((_Node->_Flags & _Fl_class_cl_all_bits)
3921
+ && _Traits.isctype(_Ch, static_cast<typename _RxTraits::char_class_type>(-1))) {
3922
+ _Found = true;
3908
3923
} else if (_Node->_Equiv && _STD _Lookup_equiv2(_Ch, _Node->_Equiv, _Traits)) {
3909
3924
_Found = true;
3910
3925
} else if ((_Node->_Flags & _Fl_class_negated_w)
0 commit comments