Repository navigation
Resume std::regex searches on libc++ without its ^ at the range start, and name the legacy-anchor cases libc++ cannot parse in the native unit - #12
Conversation
…: the pattern's caret-free form answers wherever no ^ can hold, its own form only from a position where one can
…side a lookahead, which libc++ rejects, out of the native unit on libc++, each named
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
|
|
Superseded by c0abb2d ("Resume regex searches correctly on libc++", released in 1.0.40), which fixes the same libc++ |
Two regex failures on macOS (Apple clang 21, libc++ 210106) that exist on main:
test/runtime/regexp-anchors-line-terminators.tsand the native unitregexp-legacy-anchors-runtime. CI runs on Ubuntu, where neither shows.^at a resumed search. libc++'sbasic_regex::__searchclearsmatch_not_bolwhenevermatch_prev_availis set, and its^accepts the first position of any search range outright, so a search resumed atlastIndexmatched^there after any code unit:'aa\na'.match(/^a/g)found two matches,'a\nb'.replace(/^|$/g, '<>')gave<>a<>\n<>b<>, a sticky/^a/yat 2 matched inx\na. libstdc++ honours the flag. The runtime now resumes throughPattern::searchFrom: on libc++ a pattern with a^outside a class is searched in a caret-free form (each such^replaced by[^\s\S]) wherever no^can hold, and in its own form only from a position where one can -- position 0, or after a line terminator withm. Every other library takes the plain call it took before. The three resumed searches (exec,split, and the legacy path's unrewritten form) go through it.The native unit. The rewrite a library without
multilineneeds checks a^reached after consuming with(?=\1). libc++ parses a lookahead as a pattern of its own, so a back reference to an outer group inside one is rejected, and the unit, which simulates that library by compiling every pattern multiline, aborted ona\n^b. libc++ hasmultilineand never takes the rewrite outside the simulation; the unit now names the cases that need that form and leaves them out on libc++ (14 of 87), running the rest.Verified on this Mac:
scripts/check-runtime-header.mjspasses; all 18regexp*runtime programs pass including the one above; the native unit passes 73 of 87 with 14 named;npm run gatereports 0 drift. Verified in the Linux (libstdc++) container: the same 18 programs pass, and the unit passes all 87 cases (built without sanitizers there, the container has no ASan runtime for clang 18).