Skip to content

RegularExpression: Add an optional offset parameter to find()

Nikita Nemkin requested to merge nnemkin/kwsys:regex into master

This is the KWSys part of cmake/cmake!10221 that fixes cmake/cmake#16899.

The first commit ensures that RegularExpressionMatch::start/end return std::string::npos for unmatched groups. This is for https://gitlab.kitware.com/cmake/cmake/-/blob/f2082cc660340cb6eb99a181a5f98d22cd95c889/Source/cmStringReplaceHelper.cxx#L56, which currently triggers UB (nullptr - searchstring) when accessing unmatched groups.

The second commit adds RegularExpression::find(str, offset=0). The offset parameter clearly separates the "^" anchor position from the match start position.

Edited by Nikita Nemkin

Merge request reports

Loading