@@ -1187,8 +1187,6 @@ _NODISCARD bool operator!=(const match_results<_BidIt, _Alloc>& _Left, const mat
1187
1187
}
1188
1188
#endif // !_HAS_CXX20
1189
1189
1190
- _INLINE_VAR constexpr unsigned int _BRE_MAX_GRP = 9U;
1191
-
1192
1190
_INLINE_VAR constexpr unsigned int _Bmp_max = 256U; // must fit in an unsigned int
1193
1191
_INLINE_VAR constexpr unsigned int _Bmp_shift = 3U;
1194
1192
_INLINE_VAR constexpr unsigned int _Bmp_chrs = 1U << _Bmp_shift; // # of bits to be stored in each char
@@ -1705,7 +1703,7 @@ private:
1705
1703
1706
1704
// parsing
1707
1705
int _Do_digits(int _Base, int _Count, regex_constants::error_type _Error_type);
1708
- bool _DecimalDigits (regex_constants::error_type _Error_type);
1706
+ bool _DecimalDigits2 (regex_constants::error_type _Error_type, int _Count = INT_MAX );
1709
1707
void _HexDigits(int);
1710
1708
bool _OctalDigits();
1711
1709
void _Do_ex_class(_Meta_type);
@@ -3943,9 +3941,9 @@ int _Parser<_FwdIt, _Elem, _RxTraits>::_Do_digits(
3943
3941
}
3944
3942
3945
3943
template <class _FwdIt, class _Elem, class _RxTraits>
3946
- bool _Parser<_FwdIt, _Elem, _RxTraits>::_DecimalDigits (
3947
- regex_constants::error_type _Error_type) { // check for decimal value
3948
- return _Do_digits(10, INT_MAX , _Error_type) != INT_MAX ;
3944
+ bool _Parser<_FwdIt, _Elem, _RxTraits>::_DecimalDigits2 (
3945
+ const regex_constants::error_type _Error_type, const int _Count /* = INT_MAX */ ) { // check for decimal value
3946
+ return _Do_digits(10, _Count , _Error_type) != _Count ;
3949
3947
}
3950
3948
3951
3949
template <class _FwdIt, class _Elem, class _RxTraits>
@@ -4034,7 +4032,7 @@ _Prs_ret _Parser<_FwdIt, _Elem, _RxTraits>::_ClassEscape2() { // check for class
4034
4032
return _Prs_chr;
4035
4033
} else if ((_L_flags & _L_esc_wsd) && _CharacterClassEscape(false)) {
4036
4034
return _Prs_set;
4037
- } else if (_DecimalDigits (regex_constants::error_escape)) { // check for invalid value
4035
+ } else if (_DecimalDigits2 (regex_constants::error_escape)) { // check for invalid value
4038
4036
if (_Val != 0) {
4039
4037
_Error(regex_constants::error_escape);
4040
4038
}
@@ -4332,15 +4330,17 @@ bool _Parser<_FwdIt, _Elem, _RxTraits>::_CharacterEscape() { // check for valid
4332
4330
4333
4331
template <class _FwdIt, class _Elem, class _RxTraits>
4334
4332
void _Parser<_FwdIt, _Elem, _RxTraits>::_AtomEscape() { // check for valid atom escape
4335
- if ((_L_flags & _L_bckr) && _DecimalDigits(regex_constants::error_backref)) { // check for valid back reference
4333
+ constexpr int _Bre_max_backref_digits = 1;
4334
+ if ((_L_flags & _L_bckr)
4335
+ && _DecimalDigits2(regex_constants::error_backref,
4336
+ (_L_flags & _L_lim_bckr) ? _Bre_max_backref_digits : INT_MAX)) { // check for valid back reference
4336
4337
if (_Val == 0) { // handle \0
4337
4338
if (!(_L_flags & _L_bzr_chr)) {
4338
4339
_Error(regex_constants::error_escape);
4339
4340
} else {
4340
4341
_Nfa._Add_char(static_cast<_Elem>(_Val));
4341
4342
}
4342
- } else if (((_L_flags & _L_lim_bckr) && _BRE_MAX_GRP < static_cast<size_t>(_Val))
4343
- || _Grp_idx < static_cast<size_t>(_Val) || _Finished_grps.size() <= static_cast<size_t>(_Val)
4343
+ } else if (_Grp_idx < static_cast<size_t>(_Val) || _Finished_grps.size() <= static_cast<size_t>(_Val)
4344
4344
|| !_Finished_grps[static_cast<size_t>(_Val)]) {
4345
4345
_Error(regex_constants::error_backref);
4346
4346
} else {
@@ -4364,7 +4364,7 @@ void _Parser<_FwdIt, _Elem, _RxTraits>::_Quantifier() { // check for quantifier
4364
4364
_Max = 1;
4365
4365
} else if (_Mchar == _Meta_lbr) { // check for valid bracketed value
4366
4366
_Next();
4367
- if (!_DecimalDigits (regex_constants::error_badbrace)) {
4367
+ if (!_DecimalDigits2 (regex_constants::error_badbrace)) {
4368
4368
_Error(regex_constants::error_badbrace);
4369
4369
}
4370
4370
@@ -4374,7 +4374,7 @@ void _Parser<_FwdIt, _Elem, _RxTraits>::_Quantifier() { // check for quantifier
4374
4374
} else { // check for decimal constant following comma
4375
4375
_Next();
4376
4376
if (_Mchar != _Meta_rbr) {
4377
- if (!_DecimalDigits (regex_constants::error_badbrace)) {
4377
+ if (!_DecimalDigits2 (regex_constants::error_badbrace)) {
4378
4378
_Error(regex_constants::error_badbrace);
4379
4379
}
4380
4380
0 commit comments