Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<regex>: Implement collating ranges #5238

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

muellerj2
Copy link
Contributor

Resolves #5204. Follow-up to #5164 and #5209.

When compiled under /MD or /MDd, the new test cases specific to collating ranges are skipped:

Drive-by changes:

  • Mark _Parser::_Error() as [[noreturn]].
  • In _Matcher::_Skip() and _Matcher::_Do_class(), _STD qualify calls to some free functions and clean up the control flow that translates the current character and converts it to an unsigned value.

@muellerj2 muellerj2 requested a review from a team as a code owner January 15, 2025 18:28
@@ -2917,7 +2917,8 @@ void _Builder<_FwdIt, _Elem, _RxTraits>::_Add_range2(const _Elem _Arg0, const _E

_Node->_Small->_Mark(_Ex0);
}
if (_Ex1 >= _Ex0) {

if (_Flags & regex_constants::collate || _Ex1 >= _Ex0) {
Copy link
Contributor Author

@muellerj2 muellerj2 Jan 15, 2025

Choose a reason for hiding this comment

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

The control flow is subtle around here but the function ends up doing the right thing: When the collate flag is set, the _Builder constructor sets the member variables such that _Get_tmax() and _Get_bmax() return 0. This means that the preceding loop is skipped and the inner if condition is false (even if _Ex1 < _Ex0, because _Ex1 - _Ex0 computes an unsigned integer). So in the end, the code just adds the bounds to _Node->_Ranges.

@CaseyCarter CaseyCarter added the bug Something isn't working label Jan 15, 2025
@StephanTLavavej StephanTLavavej added the regex Everyone's favorite header label Jan 15, 2025
@StephanTLavavej StephanTLavavej self-assigned this Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regex Everyone's favorite header
Projects
Status: Initial Review
Development

Successfully merging this pull request may close these issues.

<regex>: Collating ranges are broken
3 participants