mruby-regexp: test a lookbehind over a class that holds a stray byte - #7219
Conversation
Two changes compose here and the composition has no test. A character
class may hold a byte that starts no character, and a lookbehind rewinds
over characters rather than bytes. They already agree on the unit: such a
byte is a character of its own, which is the step the forward match takes
for it, so a class holding one is one character wide like any other class.
Nothing pinned that. The class rows nearby all hold characters, and the
stray-byte rows all write the byte into the pattern literally rather than
into a class.
Three readings, because the answer depends on what reads the subject:
- A binary subject rewinds by bytes in either build, which is where the
stray byte can be put to a subject at all: a subject whose bytes spell
no character is refused wherever an encoding reads them.
- Reading by character, the class is asked about a character even when it
holds a byte: the rewind steps back over the whole of A-macron, so the
class is handed U+0100 and neither C4 nor 80 matches it.
- Reading by byte, there is one character per byte, so the same class does
see the continuation byte, and only that one.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change adds regression tests for regular-expression lookbehind over character classes containing invalid bytes. The tests cover binary subjects, UTF-8 errors, multibyte rewinding, and non-UTF-8 byte behavior. ChangesRegexp lookbehind regression coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change adds regression coverage for regexp lookbehind behavior without changing production behavior or runtime configuration; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
A character class may hold a byte that starts no character, and a lookbehind rewinds over characters rather than bytes. The two agree on the unit already: such a byte is a character of its own, which is the step the forward match takes for it, so a class holding one is one character wide like any other class. Nothing pinned that.
The class rows nearby all hold characters, and the stray-byte rows all write the byte into the pattern literally rather than into a class. The one existing crossing is a binary subject, which rewinds by bytes; the character reading of the same question has no row.
Three readings, because the answer depends on what reads the subject:
Ā, so the class is handed U+0100 and neitherC4nor80matches it.Tests only. The block carries no
skip, so it runs everywhere rather than skipping silently on the builds that read by byte: every build below reports one test more thanmasterwith its skip count unchanged, KO 0.masterbuild_config/default.rbci/gcc-clang,full-debugci/gcc-clang,bintestci/gcc-clang,cxx_abici/gcc-clang,byte-stringci/gcc-clang,ascii-casebuild_config/asan.rbEnvironment
Details
The line each build actually compiles
src/string.cwith, taken fromrake --verbosewith-MMD -c,-Iand-odropped:-g -O3is what thegcctoolchain sets.full-debugand the sanitizer build then append-g3 -O0throughenable_debug(), so those two are-O0, not-O3.cxx_abiis the C compiler driven as C++ with-x c++ -std=gnu++03, andg++links it.Summary by CodeRabbit