Repository navigation
Fix grapheme searches with an offset inside a contraction - #26101
Closed
ChrisAbner wants to merge 1 commit into
Closed
ChrisAbner wants to merge 1 commit into
ChrisAbner wants to merge 1 commit into
Conversation
When the search position falls inside a contraction that spans graphemes, such as a Thai prevowel and its consonant, usearch_next() returns the match that starts at the contraction. grapheme_strpos() then returned a position before the offset, and the negative offset loop of grapheme_strrpos() set the same position again forever. The search now starts again from the following grapheme boundaries, so a match that overlaps the skipped one is still found.
devnexen
approved these changes
Dec 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the search position falls inside a contraction that spans graphemes, such as a Thai prevowel and its consonant, usearch_next() returns the match that starts at the contraction, before that position:
The first one also makes the usual loop over all matches (
$offset = $pos + 1) never end. The second one comes from the negative offset loop added in GH-24028, which sets the same position again forever. It is in 8.4.27 and later.The search now starts again from the following grapheme boundaries, so a match that overlaps the skipped one is still found. This affects Thai, Lao and other scripts with prevowels. On 8.5, a $locale with such tailorings, like Danish "aa", reaches it too. Tests added.