Commit 6d122e33ae5 for php
commit 6d122e33ae5c128b6790addd598d38cac655f556
Merge: ed20c860a5a 31014f24d42
Author: David Carlier <devnexen@gmail.com>
Date: Sun Dec 6 03:36:43 2026 +0000
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/intl: Fix grapheme searches with an offset inside a contraction
diff --cc ext/intl/grapheme/grapheme_util.cpp
index 33ebde25458,1404806e093..a3509fc352c
--- a/ext/intl/grapheme/grapheme_util.cpp
+++ b/ext/intl/grapheme/grapheme_util.cpp
@@@ -101,9 -92,29 +101,29 @@@ U_CFUNC void grapheme_substr_ascii(cha
goto finish; \
}
+ /* Find the next match that starts at or after "from". When "from" falls inside
+ * a contraction, such as a Thai prevowel and its consonant, ICU returns the match
+ * that starts at the contraction, before "from". Search again from each following
+ * grapheme boundary, so that a match overlapping the skipped one is not missed. */
+ static int32_t grapheme_usearch_next_from(UStringSearch *src, UBreakIterator *bi, int32_t from, UErrorCode *status)
+ {
+ int32_t pos = usearch_next(src, status);
+ int32_t boundary = from;
+
+ while (U_SUCCESS(*status) && pos != USEARCH_DONE && pos < from) {
+ boundary = ubrk_following(bi, boundary);
+ if (boundary == UBRK_DONE) {
+ return USEARCH_DONE;
+ }
+ usearch_setOffset(src, boundary, status);
+ pos = usearch_next(src, status);
+ }
+
+ return pos;
+ }
/* {{{ grapheme_strpos_utf16 - strrpos using utf16*/
-int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char *needle, size_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last, const char* locale)
+U_CFUNC int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char *needle, size_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last, const char* locale)
{
UChar *uhaystack = NULL, *uneedle = NULL;
int32_t uhaystack_len = 0, uneedle_len = 0, char_pos, ret_pos, offset_pos = 0;